Open System Services Programmer's Guide

13 Using the POSIX User Thread (PUT) Model Library
The POSIX User Model Thread library is a user-space implementation of IEEE Std 1003.1, 2004,
POSIX System Application Program Interface for use by native C and C++ TNS/E-targeted
applications in the OSS environment on NonStop servers. This library is supported on systems
running H06.21 and later H-series RVUs and J06.10 and later J-series RVUs.
Throughout the rest of this chapter:
The POSIX User Model Thread library is referred to as the PUT Model library
The Standard POSIX Threads library is referred to as the SPT library.
To use the PUT Model library, you should be familiar with programming in the OSS environment
and with writing threaded applications. See About This Document” (page 15) for a list of books
on programming with threads. See the Open System Services Porting Guide for information about
porting existing threaded applications and for differences between the standard and the PUT Model
library.
Threads are scheduled for execution by the PUT Model library, not by the NonStop operating
system. All threads created within a process share the same process address space.
With the PUT Model library, one thread can never be preempted by another thread. You must
ensure that threads relinquish control either by explicitly calling the sched_yield() function, by
waiting on a mutex or condition variable, or by calling a thread-aware library function.
Compiling and Linking Considerations
Header Files
Include the following header file:
/usr/include/pthread.h
The pthread.h file contains prototypes of the PUT Model library interfaces.
Linking to the POSIX User Thread Model Library
Specify ZPUTDLL, the PUT Model library DLL, when linking with eld. These libraries are located
in the current sysnn subvolume.
You cannot use both the PUT Model library and the SPT library in the same application. If the
Common Run-Time Environment (CRE) detects that a combination of incompatible public libraries
is linked into an application, it displays a diagnostic message (run-time error 19) on the standard
log file (stderr) and terminates process execution. For example, the message reporting that
incompatible libraries ZSPTDLL and ZPUTDLL are both present is:
*** Run-time error 019 ***
Incompatible runtime libraries ZSPTDLL vs. ZPUTDLL
The recovery action is to identify which library is the correct one and rebuild the application such
that the conflicting one is excluded.
Defines
_PUT_MODEL_
(Required) You must use the _PUT_MODEL_ define when building a threaded application based
on the PUT Model library. Because thread-aware signal handling is always enabled in the PUT
Model library, the alarm() and signal() functions are mapped to the PUT Model library
versions of these functions (similar to what the SPT_THREAD_SIGNAL and
SPT_THREAD_PRAGMA_SIGNAL defines do for the SPT library). For more information about
thread-aware signal handling, see “Thread-Aware Signal Handling” (page 427).
380 Using the POSIX User Thread (PUT) Model Library