Open System Services Programmer's Guide

Example 69 File Stream Thread-Aware Function Usage
...
fs = fopen(path, mode);
fd = fileno(fs);
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
...
// Call thread-aware functions.
...
fclose(fs);
...
Example 70 (page 349) shows opening a file descriptor for use with a thread-aware function. If the
file descriptor is to be used with a nonblocking thread-aware function, it is not necessary to set the
O_NONBLOCK flag.
Example 70 File Descriptor Thread-Aware Function Usage
...
filedes = open(path, oflag, mode | O_NONBLOCK);
...
// Call thread-aware functions.
...
close(filedes);
...
Example 71 (page 349) shows preparing an open file descriptor for use with a thread-aware
function. If the file descriptor is to be used with a nonblocking thread-aware function, it is not
necessary to set the O_NONBLOCK flag.
Example 71 Open File Descriptor Thread-Aware Function Usage
...
fcntl(filedes, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
...
// Call thread-aware functions.
...
Example 72 (page 350) is a multithreaded program that performs I/O on multiple OSS regular files
using the nonblocking thread-aware functions and guardian nowaited I/O.
NOTE: For systems running J06.04 or later J-series RVUs or H06.15 or later H-series RVUs, using
Guardian nowait I/O to perform I/O operations that block only the calling thread is not necessary
if you change the define used in the sample program in Example 72 (page 350) from
SPT_THREAD_AWARE_NONBLOCK to SPT_THREAD_AWARE_XNONBLOCK. See Example 73
(page 360).
Thread-Aware and Nonblocking OSS Functions 349