DCE Application Programming Guide

HP NonStop DCE Application Programming Guide429551-003
3-1
3
Application Programming With
NonStop DCE Threads
NonStop DCE threads is a user space implementation of OSF DCE threads for use by
OSS processes. This section provides guidelines for developing NonStop DCE
applications and assumes that the reader is familiar with the information in the volumes
of the OSF DCE Application Development Guide.
NonStop DCE Threads
Threads are scheduled for execution by the threads library, not the NonStop operating
system. All threads created within a process share the same process address space.
With NonStop DCE, one thread can never be preempted by another thread. Each
thread executes until it relinquishes control. Control is relinquished when the thread
either waits on a mutex or condition variable, issues an RPC, or explicitly calls the
pthread_yield() function.
All resources of a process—for example, open files or memory—belong to one of the
two categories: global or shared, as outlined in Table 3-1. Private resources can be
accessed only by a specific thread. Global resources can be accessed by all threads.
Access to global resources should be synchronized using mutex or condition variables.
Table 3-1. Process Resource Types (page 1 of 2)
Resource Type Description
Thread stack Private for
TNS
applications;
global for
TNS/R and
TNS/E
applications
The memory where all thread-local
variables are stored
Thread program counter Private The address of the instruction that the
thread is about to execute
Thread context Private The data maintained by the thread library
on behalf of a thread
All external data Global Includes process and module global
resources
All static internal variables Global
Heap Global
File descriptors and file state Global Includes file and record locks