pthread_lock_global_np(3-thr) pthread_lock_global_np(3-thr)
NAME
pthreadlockglobalnp - locks the global mutex
SYNOPSIS
#include <pthread.h>
void pthreadlockglobalnp();
DESCRIPTION
The pthreadlockglobalnp() routine locks the global mutex. If the
global mutex is currently held by another thread when a thread calls
this routine, the thread waits for the global mutex to become avail-
able.
The thread that has locked the global mutex becomes its current owner
and remains the owner until the same thread has unlocked it. This rou-
tine returns with the global mutex in the locked state and with the
current thread as the global mutex's current owner.
Use the global mutex when calling a library package that is not
designed to run in a multithreaded environment. (Unless the documenta-
tion for a library function specifically states that it is compatible
with multithreading, assume that it is not compatible; in other words,
assume it is nonreentrant.)
The global mutex is one lock. Any code that calls any function that is
not known to be reentrant uses the same lock. This prevents dependen-
cies among threads calling library functions and those functions cal-
ling other functions, and so on.
The global mutex is a recursive mutex. A thread that has locked the
global mutex can relock it without deadlocking. (The locking thread
must call pthreadunlockglobalnp() as many times as it called this
routine to allow another thread to lock the global mutex.)
This routine is a new primitive.
RETURN VALUES
No value is returned.
SEE ALSO
pthreadmutexlock(3-thr), pthreadmutexunlock(3-thr),
pthreadmutexattrsetkindnp(3-thr), pthreadunlockglobalnp(3-thr).
Page 1 Reliant UNIX 5.44 Printed 11/98