The
Compiler Parallel Support Library (CPSlib) is a library of thread
management and synchronization routines that was initially developed
to control parallelism on HP's legacy
multinode systems. Most programs fully exploited their parallelism
using higher-level devices such as automatic parallelization, compiler
directives, and message-passing.
CPSlib, however, provides a lower-level interface for the few cases
that required it.
With the introduction of the V2250 series server, HP recommends
the use of
POSIX threads (pthreads) for purposes of thread management and parallelism.
Pthreads provide portability for programmers who want to use their
applications on multiple platforms.
This appendix describes how CPSlib functions map to pthread
functions, and how to write a pthread program to perform the same
tasks as CPSlib functions. Topics included in this chapter include:
If you are running on a server released prior to the V2250
and require explicit information on CPSlib, refer to the Exemplar Programming Guide for HP-UX systems.
Accessing pthreads |
 |
When you use pthreads routines, your program must include
the <
pthread.h> header file
and the pthreads library must be explicitly linked to your program.
For example, assume the program prog.c contains calls to pthreads
routines. To compile the program so that it links in the pthreads
library, issue the following command:
% cc -D_POSIX_C_SOURCE=199506L
prog.c -lpthread
The -D_POSIX_C_SOURCE=199506L
string indicates the appropriate POSIX revision level. In the example
above, the level is indicated as 199506L.