DCE for the HP e3000 (B3821-90002)

Programming with Kernel Threads
Writing Threaded Applications
Chapter 5
55
thread is waiting on to be masked. Instead, use _setjmp and _longjmp; these routines
do not manipulate the signal mask.
When executing _longjmp be aware of the following:
Ensure you are returning to a state saved within the context of the same thread.
If you _longjmp over a TRY clause, an exception could try to _longjmp to a stack
frame that no longer exists; and vice versa.
Do not _longjmp out of a signal handler.
Use pthread_yield to allow other threads processor time — If your application is
running on a single-processor machine, and you want to permit other threads access
to the processor, you can use pthread_yield to notify the scheduler that the current
thread is willing to release the processor to other threads of the same or higher
priority. If no threads of the same or higher priority are ready to execute, the thread
continues.
An example of the use of pthread_yield is to avoid spinning in a tight loop, such as:
while (!flag);
by using pthread_yield as:
while (!flag) pthread_yield();
Use pthread_yield with caution; misuse can cause unnecessary context switching and
increasing overhead with no increase in “fairness.” For example, it is counterproductive
for a thread to yield while it has a needed resource locked.