DCE Application Programming Guide
Application Programming With NonStop DCE
Threads
HP NonStop DCE Application Programming Guide—429551-003
3-7
Using Nowait Input or Output
•
Inspect, Native Inspect, and Visual Inspect symbolic debuggers. Each of these
debuggers can block a process indefinitely.
Applications that make calls that block the process for significant periods of time
should use the TCP connection protocol.
Using Nowait Input or Output
Programs that use threads cannot call the Guardian AWAITIO or AWAITIOX procedure
with -1 as a file parameter. (AWAITIOX can be used to poll for completion on a specific
file, although a NonStop DCE thread must complete all nowait input or output
operations before yielding control to another thread.)
Yielding Control
Because NonStop DCE threads are never preempted, programmers should consider
when to call the pthread_yield() function to increase scheduling equity. This
function releases the processor to another thread of the same or higher priority.
Be careful when using the pthread_yield() function. Overuse causes unnecessary
context switching, which increases overhead without increasing equity. For example, a
thread should not yield control while it has a needed resource locked.
Using Signals
The longjmp() function causes a thread to jump to the execution context saved by a
call to the setjmp() function. The longjump() function does not restore the signal
mask of the process. If the longjmp() function is used from within a signal handler,
the signal mask used in the handler is retained when execution resumes after the
setjmp() location. The exception mechanism uses the setjmp() and longjmp()
functions and behaves similarly.
The sigsetjmp() and siglongjmp() functions have an option to save and restore
the signal mask. This option can cause signals that were enabled by another thread to
be inadvertently masked.
When handling signals:
•
Do not use the raise() function for an exception and do not use the longjmp()
function to exit a synchronous signal handler. Simply returning from a signal
handler is safe and is the recommended practice.
•
Use exception handlers in place of the setjmp() and longjmp() functions for
NonStop DCE applications.
•
Do not use the feature of the sigsetjmp() and siglongjmp() functions that
allows the signal mask to be saved and restored. Doing so can cause signals
enabled by another thread to be masked.