1_lwp_mutex_lock(2)               System Calls               _lwp_mutex_lock(2)
2
3
4

NAME

6       _lwp_mutex_lock,  _lwp_mutex_unlock, _lwp_mutex_trylock - mutual exclu‐
7       sion
8

SYNOPSIS

10       #include <sys/lwp.h>
11
12       int _lwp_mutex_lock(lwp_mutex_t *mp);
13
14
15       int _lwp_mutex_trylock(lwp_mutex_t *mp);
16
17
18       int _lwp_mutex_unlock(lwp_mutex_t *mp);
19
20

DESCRIPTION

22       These functions serialize the execution of lightweight processes.  They
23       are useful for ensuring that only one lightweight process can execute a
24       critical section of code  at  any  one  time  (mutual  exclusion).  LWP
25       mutexes must be initialized to 0 before use.
26
27
28       The _lwp_mutex_lock() function locks the LWP mutex pointed to by mp. If
29       the mutex is already locked, the calling LWP  blocks  until  the  mutex
30       becomes  available. When _lwp_mutex_lock() returns, the mutex is locked
31       and the calling LWP is the "owner".
32
33
34       The _lwp_mutex_trylock() function attempts to lock the  mutex.  If  the
35       mutex  is  already  locked  it  returns  with an error. If the mutex is
36       unlocked, it is locked and _lwp_mutex_trylock() returns.
37
38
39       The _lwp_mutex_unlock() function unlocks a locked mutex. The mutex must
40       be  locked  and  the  calling  LWP must be the one that last locked the
41       mutex (the owner). If any other LWPs  are  waiting  for  the  mutex  to
42       become available, one of them is unblocked.
43

RETURN VALUES

45       Upon  successful  completion, 0 is returned. A non-zero value indicates
46       an error.
47

ERRORS

49       If any of the following  conditions  are  detected,  _lwp_mutex_lock(),
50       _lwp_mutex_trylock(),  and _lwp_mutex_unlock() fail and return the cor‐
51       responding value:
52
53       EINVAL    The mp argument points to an invalid LWP mutex.
54
55
56       EFAULT    The mp argument points to an illegal address.
57
58
59
60       If any of the following conditions  occur,  _lwp_mutex_trylock()  fails
61       and returns the corresponding value:
62
63       EBUSY    The mp argument points to a locked mutex.
64
65

SEE ALSO

67       Intro(2), _lwp_cond_wait(2)
68
69
70
71SunOS 5.11                        30 Jul 1992               _lwp_mutex_lock(2)
Impressum