Open System Services Programmer's Guide

other threads in the process are nonblocking functions. Nonblocking I/O functions are sometimes
called asynchronous I/O functions.
The behavior of an OSS I/O library function can vary according to these factors:
Whether the file descriptor is for a regular file or a non-regular file.
Whether the function was designed to be process-blocking, thread-aware (thread-blocking),
or nonblocking for that type of file.
Whether the file descriptor passed to the function is nonblocking. A file descriptor is
nonblocking when one of these conditions is true:
The file descriptor has the O_NONBLOCK flag set.
The file descriptor has been set to non-blocking mode by setting the argument to the
request parameter to F_SETFL when calling the fcntl() function.
NOTE: In this section, thread-aware and nonblocking thread-aware functions are listed
explicitly. However, instead of calling these functions directly, HP recommends that you use
preprocessor directives when compiling your application. See “Preprocessor Directives
Automatically Map Standard System Calls to Thread-Aware or Nonblocking Thread-Aware
System Calls” (page 346).
Regular Files
For regular files, the spt_*z() set of functions are thread-aware. The spt_*z() set of functions
block the calling thread but allow the other threads to run, whether or not the file descriptor is
nonblocking. These functions never return the errors EAGAIN, EINPROGRESS, or EWOULDBLOCK
for regular files, so there are no nonblocking thread-aware functions for regular files.
In contrast, the spt_*() and spt_*x() sets of functions are not thread-aware for regular files.
For regular files, these functions are always process-blocking.
The spt_*z() set of functions are supported on systems running J06.04 and later J-series RVUs
and H06.15 and later H-series RVUs, and are listed in the rightmost column, labeled Thread-Aware
(Regular Files) and Nonblocking Thread-Aware (Non-Regular Files) Functions, of Table 59 (page 344).
In addition to the functions listed in Table 59 (page 344), these additional functions, athough not
thread-aware, support the use of spt_*z() set of thread-aware functions by serializing file
operations on an open file:
spt_fstat64z()
spt_fstatz()
spt_lseek64z()
spt_lseekz()
Serialization of File Operations On an Open File
The version of the Standard POSIX Threads library that supports the spt_*z() set of functions
serializes file operations on an open file. If a thread calls one of the spt_*z() set of functions to
access a file that already has a file operation in progress by a different thread, the calling thread
is blocked until the prior file operation is complete. For example:
1. Thread A calls spt_readz() to read the open file MyDataFile. The file does not have an
operation in progress, so thread A starts reading the file.
2. Thread B calls spt_writez() to write to the same open file MyDataFile. Because the
read operation started by thread A is still in progress, thread B is blocked and must wait for
thread A’s read operation to complete.
Thread-Aware and Nonblocking OSS Functions 341