HP-UX Reference (11i v1 05/09) - 5 Miscellaneous Topics (vol 9)
p
pthread_stubs(5) pthread_stubs(5)
pthread_mutexattr_setprotocol(3T)
pthread_mutexattr_setpshared(3T)
pthread_mutexattr_settype(3T)
pthread_once(3T)
pthread_rwlock_destroy(3T)
pthread_rwlock_init(3T)
pthread_rwlock_rdlock(3T)
pthread_rwlock_tryrdlock(3T)
pthread_rwlock_trywrlock(3T)
pthread_rwlock_unlock(3T)
pthread_rwlock_wrlock(3T)
pthread_rwlockattr_destroy(3T)
pthread_rwlockattr_getpshared(3T)
pthread_rwlockattr_init(3T)
pthread_rwlockattr_setpshared(3T)
pthread_self(3T)
pthread_setcancelstate(3T)
pthread_setcanceltype(3T)
pthread_setconcurrency(3T)
pthread_setschedparam(3T)
pthread_sigmask(3T)
pthread_suspend(3T)
pthread_testcancel(3T)
The stubs for the following pthread calls have full functionality. Refer to pthread(3T) for more details.
pthread_key_create(3T)
pthread_getspecific(3T)
pthread_setspecific(3T)
pthread_key_delete(3T)
pthread_exit(3T)
In calls to the stubs listed below,
pthread_self(3T) always returns 1.
pthread_equal(3T):
pthread_equal(
arg1,arg2) returns (arg1==arg2).
pthread_create(3T) and pthread_attr_init(3T) return [ENOSYS].
The above mentioned stubs are provided in libc because on HP-UX if a non-threaded application links to a
thread-safe library, calls to thread-safe routines from the application fail at run time due to unresolved
symbols of the form of pthread_*. To resolve these symbols it is necessary to link the non-threaded applica-
tion to a threads library (
libpthread or libcma). However, linking to a threads library forces the
application to use thread-safe features even if it creates no threads, resulting in a subsequent loss of perfor-
mance.
To overcome the above problem, stubs for POSIX.1c APIs have been provided in the C library. Providing
stubs for POSIX.1c API’s in the HP-UX C language library have two direct effects for non-threaded appli-
cations:
• POSIX.1c thread symbols are resolved if a non-threaded application links to a thread-safe library.
• Avoids the overhead of a real thread library. Especially the overhead associated with mutexes when the
non-threaded application uses thread stubs rather than the real thread library procedures.
Link Order Problems
An application may inadvertently pick up the stubs present in libc when it intended to use the real pthread
APIs, or cma APIs, due to link order issues. An application that needs cma behavior must link to libcma
and must do so in the supported link order, that is, the link line should only be shared and should not con-
tain -lc before -lcma. As long as this condition is met, the correct cma functions will be referenced.
Similarly, a multithreaded application that needs pthread library behavior must link to libpthread and
must do so in a supported link order, and only use shared libc and libpthread.
HP-UX 11i Version 1: September 2005 − 2 − Hewlett-Packard Company Section 5−−287