Open System Services Programmer's Guide
Yielding Control
Because Standard POSIX Threads are never preempted, a call to the sched_yield() function
might be needed to allow time-critical run-time threads to execute. This function releases the processor
to another thread of the same or higher priority. The calling thread may get control immediately
if no threads of the same or higher priority are ready to run.
Be careful using the sched_yield() function. Misuse causes unnecessary context switching,
which increases overhead without allowing the other threads to execute. For example, it is
counterproductive for a thread to yield control while it has a needed resource locked.
Using Signals
• The following signal features are not supported:
Job Control Signals. The stop a process or continue a process actions implied by these
signals are also not supported.
◦
◦ The Real-time Signals Extension option.
• Use the sigaction() function, not the signal() function, to specify the action to be taken
when a given signal is received.
• The threads library contains jacket routines for the following OSS system and library functions:
sigaction()
sigpending()
sigsuspend()
pause()
sleep()
In addition, spt_alarm() and spt_signal() are provided for thread aware signal
handling (see “Thread-Aware Signal Handling” (page 317)).
• The pthread_kill() function provides a mechanism for synchronously directing a signal
to a thread in the calling process.
• A signal is handled in the context of the given thread. However, the signal action (terminating
or stopping) might affect the process as a whole. See “Thread-Aware Signal Handling”
(page 317).
• Signals sent with the pthread_kill() function are queued in FIFO order for the target
thread. More than one instance of the same signal might be pending for a thread. However,
applications should not rely on this ordering.
• You must specify whether a signal listed in Table 56 (page 316) as generating a saveabend
actually generates a saveabend by specifying the -Wsaveabend flag in c89 or c99, or
saveabend in nld, ld, or eld.
• If a signal is delivered to a thread waiting on a condition variable, then upon return from the
signal handler, the thread will resume waiting for the condition variable as if it were not
interrupted.
Using Signals With the setjmp() and longjmp() Functions
Using the setjmp() and longjmp() functions can interfere with signal handling. The longjmp()
function causes a thread to jump to the execution context saved by a previous call to the setjmp()
function, but it does not restore the signal mask of the process. If the longjmp() function is called
within a signal handler, the signal mask used in the signal handler is retained when execution
resumes at the setjmp() location. The exception mechanism uses the setjmp() and longjmp()
functions and behaves similarly.
330 Using the Standard POSIX Threads Library