Open System Services Programmer's Guide
Example 79 Example READX() Function Used In Thread-Aware Manner
{
spt_error_t spte;
long error;
_cc_status cc;
long tag;
tag = spt_generateTag();
cc = READX(filenum, buffer, read_count, , tag);
/* If READX() failed. */
if (_status_lt(cc))
{
short short_error;
(void) FILE_GETINFO_(filenum, &short_error);
return short_error;
}
/* Loop forever. */
while (1)
{
spte = spt_awaitio(filenum, tag, timelimit, count_read,
&error, NULL);
/* If spte is SPT_INTERRUPTED then try again. */
if (spte != SPT_INTERRUPTED) break;
}
/* If spt_awaitio() was unsuccessful.*/
if (spte != SPT_SUCCESS) (void) CANCELREQ(filenum, tag);
return error;
}
Caveats to Using the Thread-Aware Toolkit
Proper operation of the thread-aware toolkit depends on the following conditions:
• No calls to AWAITIO[X] () with a file number of -1 are made.
• No calls to put_awaitio() with a file number of -1 are made.
• No calls to AWAITIO[X] () with a file number registered with the PUT library are made. Use
put_awaitio() instead.
• No calls to FILE_COMPLETE_SET_ () are made.
• No calls to FILE_COMPLETE_ () are made using the permanent set.
Thread-Aware $RECEIVE I/O Functions
$RECEIVE thread-aware functions (Table 62) integrate the following basic $RECEIVE I/O functions
with the POSIX thread engine and support.
• Read $RECEIVE (similar to READUPDATEX) so that it is thread-blocking, but not process-blocking.
• Read $RECEIVE from one or multiple threads and returning all pertinent information
(FILE_GETRECEIVEINFO) in a thread-safe form.
• Inherit transactions on $RECEIVE and properly associating or disassociating the transaction
with the calling thread.
• Block a reading thread if the number of messages read has exceeded receive depth.
372 Using the Standard POSIX Threads Library