Open System Services Programmer's Guide
Table 69 System and Equivalent Thread-Aware Functions (continued)
Thread aware in PUT Model
library (functions not related to
file I/O)
Nonblocking and thread aware
in PUT Model library for
non-regular files
Nonblocking and thread
aware in PUT Model
library for regular files
Standard
(Process-Blocking) OSS
Functions
—yesyeswrite()
yes——writev()
The Set of Thread-Aware I/O Functions Must Be Used Together
The PUT Model library serializes I/O functions on open files only for the thread-aware regular I/O
set of functions the PUT Model library provides. Using modules that were not compiled to use the
PUT Model library can cause unexpected results. For example, compiling a module so that it calls
the unmapped standard function close() directly, instead of the PUT Model library version of
close(), might leave a thread with a pending thread-aware regular file request suspended with
no mechanism available to reschedule it for execution. For example, if you compile one module
to use the PUT Model library and another module to not use the PUT Model library, you can get
errors when the two modules operate on the same open file:
1. Thread A calls the PUT Model library version (a thread-aware version of read() 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 standard read() system function (you did not use the PUT Model library),
which is not thread-aware, to read to the same open file MyDataFile. Because the standard
read() function does not support serialization, the standard version of read() attempts to
do the read and fails, returning the error EALREADY. The EALREADY error indicates that an
operation is already in progress.
Using Thread-Aware Functions
Example 90 (page 399) shows using thread-aware functions with a file stream. It is not necessary
to set the O_NONBLOCK flag.
Example 90 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 91 (page 400) shows opening a file descriptor for use with a thread-aware function. It is
not necessary to set the O_NONBLOCK flag.
Thread-Aware and Nonblocking OSS Functions 399