| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- mutual exclusion
#include <sys/lwp.h>int_lwp_mutex_lock(lwp_mutex_t *mp);
int_lwp_mutex_trylock(lwp_mutex_t *mp);
int_lwp_mutex_unlock(lwp_mutex_t *mp);
These functions serialize the execution of lightweight processes. They are useful forensuring that only one lightweight process can execute a critical section ofcode at any one time (mutual exclusion). LWP mutexes must be initialized to0 before use.
The_lwp_mutex_lock() function locks the LWP mutex pointed to bymp. Ifthe mutex is already locked, the calling LWP blocks until the mutexbecomes available. When_lwp_mutex_lock() returns, the mutex is locked and the calling LWPis the "owner".
The_lwp_mutex_trylock() function attempts to lock the mutex. If the mutex isalready locked it returns with an error. If the mutex is unlocked,it is locked and_lwp_mutex_trylock() returns.
The_lwp_mutex_unlock() function unlocks a locked mutex. The mutex must be lockedand the calling LWP must be the one that last locked themutex (the owner). If any other LWPs are waiting for the mutex tobecome available, one of them is unblocked.
Upon successful completion,0 is returned. A non-zero value indicates an error.
If any of the following conditions are detected,_lwp_mutex_lock(),_lwp_mutex_trylock(), and_lwp_mutex_unlock()fail and return the corresponding value:
Themp argument points to an invalid LWP mutex.
Themp argument points to an illegal address.
If any of the following conditions occur,_lwp_mutex_trylock() fails and returns thecorresponding value:
Themp argument points to a locked mutex.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |