DCE Application Programming Guide

Application Programming With NonStop DCE
Threads
HP NonStop DCE Application Programming Guide429551-003
3-4
Threading Considerations for NonStop DCE
Applications
Threading Considerations for NonStop DCE
Applications
Application designers must be aware of several general threading considerations when
developing a NonStop DCE application. These considerations are summarized and
discussed in Table 3-2.
Sharing Process Resources
Access to shared process resources such as global data, the heap, and files must be
synchronized.
Table 3-2. General Threading Considerations
Consideration Summary
Sharing Process
Resources
Access to shared process resources such as global data, the
heap, and files must be synchronized.
Using Standard
Libraries
With NonStop DCE, special jackets or header files are not needed.
With NonStop DCE, you do not need to disable thread
cancelability before calling into the library.
Be careful when using pointers to library data.
Be careful of context maintained across library calls.
Addressing the Thread
Stack
In a TNS application, data allocated on the thread stack cannot be
shared with other threads.
In TNS/R and TNS/E applications, data allocated on the thread
stack can be shared with other threads.
Making Process-
Blocking Calls
Process-blocking calls can prevent execution of time-critical run-
time functions.
Using Nowait Input or
Output
Programs cannot call the Guardian AWAITIO or AWAITIOX
procedures 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
Consider using the pthread_yield() function to allow run-time
threads or other application threads to execute.
Using Signals
Using the setjmp() and longjmp() functions can interfere with
signal handling.
Spawning a New
Process
Be careful when using any of the fork, exec, or tdm_spawn
sets of functions.
Isolating Faults
No address space protection exists between the application
threads in a process.