Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (n - p) pthread_lock_global_np(2)
NAME
pthread_lock_global_np
- Locks the global mutex for threads
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
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 mutexs 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 specically 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 functionscalling 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.
RETURN VALUES
Possible return values are as follows:
0 Successful completion.
RELATED INFORMATION
Functions: pthread_unlock_global_np(2).
STANDARDS CONFORMANCE
This function is an extension to the XPG4 Version 2 specication and to the following industry
standards:
IEEE Std 1003.1c-1995, POSIX System Application Program Interface
527186-003 Hewlett-Packard Company 575