Locks the global mutex.
Threads Library (libpthreads.a)
void pthread_lock_global_np ()
The pthread_lock_global_np subroutine locks the global mutex. If the global mutex is currently held by another thread, the calling thread waits until the global mutex is unlocked. The subroutine returns with the global mutex locked by the calling thread.
Use the global mutex when calling a library package that is not designed to run in a multithreaded environment. (Unless the documentation 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 dependencies among threads calling library functions and those functions calling 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 thread must then call the pthread_unlock_global_np subroutine as many times as it called this routine to allow another thread to lock the global mutex.
- The pthread.h header file must be the first included file of each source file using the threads library. Otherwise, the -D_THREAD_SAFE compilation flag should be used, or the cc_r compiler used. In this case, the flag is automatically set.
- The pthread_lock_global_np subroutine is not portable.
This subroutine is part of the Base Operating System (BOS) Runtime.
This subroutine is not POSIX compliant and is provided only for compatibility with DCE threads. It should not be used when writing new applications.
The pthread_mutex_lock (pthread_mutex_lock, pthread_mutex_trylock, or pthread_mutex_unlock Subroutine) subroutine, pthread_unlock_global_np (pthread_unlock_global_np Subroutine) subroutine.
Using Mutexes in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.