pthread_stubs.5 (2010 09)

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)
Calls to the stubs listed below,
pthread_self (3T) always returns 1.
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
application 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
performance.
To overcome the above problem, stubs for
POSIX.1c APIs have been provided in the C library. Provid-
ing stubs for POSIX.1c API’s in the HP-UX C language library have two direct effects for non-threaded
applications:
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, i.e. the link line should only be shared and should
not contain -lc before -lcma. As long as this condition is met, the correct cma functions will be refer-
enced. 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.
EXAMPLES
Below are examples of potential link order problems.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010