DCE Application Programming Guide

Application Programming With NonStop DCE
Threads
HP NonStop DCE Application Programming Guide429551-003
3-14
Programs With Multiple Independent Application
Threads
application thread can use the TMF transaction-demarcation API without concern
that another thread might change the current transaction of the process.
One application thread cannot block another.
The thread cannot block other application threads from executing, which minimizes
the effect of process-blocking operations.
One application thread cannot corrupt another.
The thread does not share its address space with any other application threads.
The application thread is protected by the address-space protection provided for
the process, which offers fault isolation.
The following general threading considerations affect single-threaded applications, but
these considerations have a smaller effect on these applications than they do on
processes with multiple application threads:
Making process-blocking calls
Although process-blocking calls will not affect other application threads, they can
interfere with time-critical run-time threads.
Yielding control
If the application thread can execute for long periods (more than a second) without
relinquishing control, the application might need to use the pthread_yield()
function to allow time-critical run-time threads to execute.
The following general threading considerations do apply to single-threaded
applications:
Using nowait input or output
Single-threaded applications cannot call the Guardian AWAITIO and 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.
Spawning a new process
Be careful when you use the fork, exec, or tdm_spawn sets of functions, as
discussed in Spawning a New Process on page 3-8.
Programs With Multiple Independent Application Threads
Programs containing multiple threads can improve performance by providing
concurrent execution. If the application threads are independent, they do not explicitly
share application resources that exist in the process environment, such as application
file opens, SQL cursors, or modifiable application data structures.
An example of this type of application is a simple DCE server that maintains the
application state in a database. Maintaining application state in a database greatly
simplifies server design because the server does not need to maintain the application