Open System Services Programmer's Guide
Thread-Aware Toolkit Functions and Types
Functions written using the thread-aware toolkit (Table 70) allow one or more threads to perform
work on one or more files without any one thread unnecessarily blocking another thread. To enable
these functions, you must include the pthread.h header file. You can use these functions with
the thread-aware functions in the PUT Model library.
For details on each function, see the appropriate reference page in the Open System Services
System Calls Reference Manual.
Table 70 Thread-Aware Toolkit Functions and Types
DescriptionFunction
Unregister the file number as one you will manage. Any threads waiting
on file number I/O will awaken with put_ERROR and system error 16.
put_unregFile()
Callback type required by put_regFileIOHandler(). A callback
is executed in the context of the last running thread; that is, it executes
on the stack of the last running thread.
put_FileIOHandler_p()
Register the file number as one you will manage through a user-supplied
callback. Invoke this callback immediately after each I/O on filenum
completes.
put_regFileIOHandler()
Wake up a thread awaiting the tagged I/O on file number. The
awakened thread returns from put_awaitio() with put_SUCCESS.
put_wakeup()
Default callback used by put_regFile(). It calls put_wakeup()
and passes on the supplied parameters.
put_defaultCallback()
Register the file number as one you will manage through the default
callback.
put_regFile()
Await a tagged IO on file number to complete, timeout, or be interrupted.
I/O is never canceled by this function. and completes only if
put_awaitio()
put_SUCCESS is returned. Multiple threads should not await the same
tagged I/O on any given file number.
Interrupt all threads awaiting I/O on file number. I/O is not cancelled
by this function. Interrupted threads will return from put_awaitio()
with a return value of put_ERROR.
put_interrupt()
Interrupt the thread awaiting the tagged IO on file number. I/O is not
cancelled by this function. Interrupted threads will return from
put_awaitio() with a return value of put_ERROR.
put_interruptTag()
Increment and return a static long appropriate for use as a tag. This
long will eventually wrap and therefore return tags that may still be in
put_generateTag()
use. For example, if a process calls put_generateTag() 100 times
every second, the wrap will occur on the 248th day.
Wait on a file descriptor to be read ready or have an exception pending.put_fd_read_ready()
Wait on a file descriptor to be write ready or have an exception
pending.
put_fd_write_ready()
Using Thread-Aware Toolkit Functions
The following examples show using thread-aware toolkit functions:
• Thread-aware toolkit program flow — Example 95 (page 412).
• Simplified program flow for a thread-aware function — Example 96 (page 412)
• Nonblocking thread-aware read() function — Example 97 (page 413)
• Function using put_READX() — Example 98 (page 414)
Reentrant OSS Functions 411