HP OpenVMS Systems Documentation |
Guide to the POSIX Threads Library
tis_setspecific
Changes the value associated with the specified thread-specific data key. Syntaxtis_setspecific(C Binding #include <tis.h>
int
Arguments
DescriptionThis routine sets the value associated with the specified thread-specific data key. If a value is defined for the key (that is, the current value is not NULL), the new value is substituted for it. The key is obtained by a previous call to tis_key_create() . Return Values If an error condition occurs, this routine returns an integer indicating the type of error. Possible return values are as follows:
Associated Routinestis_getspecific() tis_sync
Used as the synchronization point for asynchronous I/O system services. This routine is for OpenVMS systems only. Syntaxtis_sync(C Binding #include <tis.h>
int
Arguments
DescriptionReturn Values This routine has the same return values as the OpenVMS $SYNC() routine. Associated Routinestis_io_complete() tis_testcancel
Creates a cancelation point in the calling thread. Syntaxtis_testcancel( );C Binding #include <tis.h>
void
ArgumentsNone DescriptionThis routine requests delivery of a pending cancelation request to the calling thread. Thus, this routine creates a cancelation point in the calling thread. The cancelation request is delivered only if a request is pending for the calling thread and the calling thread's cancelability state is enabled. (A thread disables delivery of cancelation requests to itself by calling tis_setcancelstate() .)Return Values None Associated Routinestis_setcancelstate() tis_unlock_global
Unlocks the Threads Library global mutex. Syntaxtis_unlock_global( );C Binding #include <tis.h>
int
ArgumentsNone DescriptionThis routine unlocks the global mutex. Because the global mutex is recursive, the unlock occurs when each call to tis_lock_global() has been matched by a call to this routine. For example, if your program called tis_lock_global() three times, tis_unlock_global() unlocks the global mutex when you call it the third time.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Associated Routinestis_lock_global() tis_write_lock
Acquires a read-write lock for write access. Syntaxtis_write_lock(C Binding #include <tis.h>
int
Arguments
DescriptionThis routine acquires a read-write lock for write access. This routine waits for any other active locks (for either read or write access) to be unlocked before this acquisition request is granted.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Associated Routinestis_read_lock() tis_write_trylock
Attempts to acquire a read-write lock for write access. Syntaxtis_write_trylock(C Binding #include <tis.h>
int
Arguments
DescriptionThis routine attempts to acquire a read-write lock for write access. The routine attempts to immediately acquire the lock. If the lock is acquired, zero (0) is returned. If the lock is held by another thread (for either read or write access), [EBUSY] is returned and the calling thread does not wait for the write-access lock to be acquired.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Associated Routinestis_read_lock() tis_write_unlock
Unlocks a read-write lock that was acquired for write access. Syntaxtis_write_unlock(C Binding #include <tis.h>
int
Arguments
DescriptionThis routine unlocks a read-write lock that was acquired for write access.Return Values If an error condition occurs, this routine returns an integer value indicating the type error. Possible return values are as follows:
Associated Routinestis_read_lock() tis_yield
Notifies the scheduler that the current thread is willing to release its processor to other threads of the same or higher priority. Syntaxtis_yield( );C Binding int tis_yield (void); ArgumentsNone DescriptionWhen threads are not present, this routine has no effect.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Part 4
Part 4 contains appendixes that provide supporting information
about the POSIX Threads Library, such as operating system-specific
information, debugging information, and additional reference
information.
|
Header File | Interface |
---|---|
pthread.h | POSIX routines |
tis.h | Thread-independent services routines |
Do not include more than one of these header files in your module.
A.2.2 Building Multithreaded Applications from Threads Libraries
Multithreaded applications are built using shared libraries. For a description of shared libraries, see the Tru64 UNIX Programmer's Guide.
Table A-2 contains the libraries supported for multithreaded programming.
libpthreads.so | Shared version of Threads Library "legacy" package, implementing the Compaq-proprietary CMA (or cma) and POSIX 1003.4a/Draft 4 ( d4 or DCEthreads) interfaces. |
libpthread.so | Shared version of the POSIX threads package. Requires libexc.so and libc.so |
libexc.so | Shared version of Tru64 UNIX exception support package. |
libc.so | Shared version of the C language run-time library ( libc.so ). |
Build a multithreaded application using shared versions of libexc , libpthread , and libc using this command:
% cc -o myprog myprog.c -pthread |
If you use a compiler front-end or other (not C) language environment
that does not support the
-pthread
compilation switch, you must provide the
-D_REENTRANT
compilation switch (or equivalent) at compilation, and link as shown in
Section A.2.3.
A.2.3 Linking Multithreaded Shared Libraries
The ld command does not support the -pthread or -threads switch. Normally, programs can be compiled and linked from the cc command. If you must link using the ld command, you must list the shared libraries in the proper order. The libc library should be the last library referenced, libexc should immediately precede libc , and the thread libraries should precede libexc .
For libraries that use only the pthread interface, use the following:
ld <...> -lpthread -lexc -lc |
If using the cma or d4 interfaces, use the following:
ld <...> -lpthreads -lpthread -lexc -lc |
Also, cc -pthread (or cc -threads ) causes the compiler to replace any libraries that have special thread-safe alternatives. These libraries have the same name ending in -r . For example, cc -pthread -o foo -lbar , if there is a libbar.so and libbar_r.so , would use the latter. When linking with the ld command, you must perform that search and replacement yourself.
If you build software (whether applications or libraries) that links against the static version of a Threads library, you must not require developers who use your software to link against any library that dynamically loads any Threads shared library, such as libpthread.so . |
Previous | Next | Contents | Index |