Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
pthread_lock_global_np(2) OSS System Calls Reference Manual
NAME
pthread_lock_global_np - Locks the global mutex for threads
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
H-series and J-series OSS processes that use the Standard POSIX Threads library:
/G/system/zdllnnn/zsptdll
SYNOPSIS
#include <pthread.h> | #include <spthread.h>
/* pthread.h is required to use POSIX User Thread Model library */
/* spthread.h is required to use Standard POSIX Threads library */
int pthread_lock_global_np(void);
DESCRIPTION
This function locks the threads global mutex. If the threads global mutex is currently held by
another thread when this function is called, the calling thread waits for the threads global mutex
to become available and then locks it.
The thread that locks the threads global mutex becomes its current owner and remains its owner
until the same thread unlocks it. This function returns with the threads global mutex in the
locked state and the calling thread as the threads global mutex’s current owner.
Use the threads global mutex when calling a library package that is not designed to run in a mul-
tithreaded environment. Unless documentation specifically states that a function is thread-safe,
assume that the function is not compatible; in other words, assume it is nonreentrant.
The threads global mutex is one lock. Any code that calls any function that is not known to be
reentrant should use the same lock to prevent problems resulting from dependencies among
threads that call library functions, those functions’ calling other functions, and so on.
The threads global mutex is a recursive mutex. A thread that locks the threads global mutex can
relock it without deadlocking. The locking thread must call the pthread_unlock_global_np( )
function as many times as it called this function, to allow another thread to lock the threads glo-
bal mutex.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks:
• Include the pthread.h header file in the application.
• Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
• Link the application to the zputdll library (/G/system/zdllnnn/zputdll).
On systems running H06.24 or later H-series RVUs or J06.13 or later J-series RVUs, you can use
the POSIX User Thread Model library with 32-bit or 64-bit threaded applications.
To use this function in a 32-bit threaded application that uses the POSIX User Thread Model
library on systems running H06.24 or later RVUs or J06.13 or later RVUs, perform the same
5−138 Hewlett-Packard Company 527186-023