Add to git.
[pthrlib.git] / doc / mutex_enter.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>new_mutex</title>
6 </head>
7 <body>
8
9 <h1 align=center>new_mutex</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#BUGS">BUGS</a><br>
14 <a href="#AUTHOR">AUTHOR</a><br>
15 <a href="#LICENSE">LICENSE</a><br>
16 <a href="#VERSION">VERSION</a><br>
17
18 <hr>
19 <!-- Creator     : groff version 1.17.2 -->
20 <!-- CreationDate: Fri Aug 30 16:16:29 2002 -->
21 <a name="NAME"></a>
22 <h2>NAME</h2>
23 <table width="100%" border=0 rules="none" frame="void"
24        cols="2" cellspacing="0" cellpadding="0">
25 <tr valign="top" align="left">
26 <td width="10%"></td><td width="90%">
27 new_mutex, mutex_enter, mutex_leave, mutex_try_enter - mutual exclusion (mutex) locks</td></table>
28 <a name="SYNOPSIS"></a>
29 <h2>SYNOPSIS</h2>
30
31 <table width="100%" border=0 rules="none" frame="void"
32        cols="2" cellspacing="0" cellpadding="0">
33 <tr valign="top" align="left">
34 <td width="10%"></td><td width="90%">
35 <pre><b>#include &lt;pthr_mutex.h&gt;
36
37 mutex new_mutex (pool);
38 void mutex_enter (mutex, pseudothread);
39 void mutex_leave (mutex, pseudothread);
40 int mutex_try_enter (mutex, pseudothread);
41 </b></pre></td></table>
42 <a name="DESCRIPTION"></a>
43 <h2>DESCRIPTION</h2>
44
45 <table width="100%" border=0 rules="none" frame="void"
46        cols="2" cellspacing="0" cellpadding="0">
47 <tr valign="top" align="left">
48 <td width="10%"></td><td width="90%">
49 Mutex locks are simple: at most one pseudothread may enter
50 the critical area protected by the lock at once. If instead
51 you wish multiple reader / single writer semantics, then
52 please see <b>new_rwlock(3)</b>.</td></table>
53
54 <table width="100%" border=0 rules="none" frame="void"
55        cols="2" cellspacing="0" cellpadding="0">
56 <tr valign="top" align="left">
57 <td width="10%"></td><td width="90%">
58 Mutex locks are automatically released if they are being
59 held when the thread exits.</td></table>
60
61 <table width="100%" border=0 rules="none" frame="void"
62        cols="2" cellspacing="0" cellpadding="0">
63 <tr valign="top" align="left">
64 <td width="10%"></td><td width="90%">
65 Note that there are possible deadlocks when using locks. To
66 avoid deadlocks, always ensure every thread acquires locks
67 in the same order.</td></table>
68
69 <table width="100%" border=0 rules="none" frame="void"
70        cols="2" cellspacing="0" cellpadding="0">
71 <tr valign="top" align="left">
72 <td width="10%"></td><td width="90%">
73 <b>new_mutex</b> creates a new mutex object.</td></table>
74
75 <table width="100%" border=0 rules="none" frame="void"
76        cols="2" cellspacing="0" cellpadding="0">
77 <tr valign="top" align="left">
78 <td width="10%"></td><td width="90%">
79 <b>mutex_enter</b> and <b>mutex_leave</b> enter and leave
80 the critical section. Only one thread can run at a time
81 inside the critical section.</td></table>
82
83 <table width="100%" border=0 rules="none" frame="void"
84        cols="2" cellspacing="0" cellpadding="0">
85 <tr valign="top" align="left">
86 <td width="10%"></td><td width="90%">
87 <b>mutex_try_enter</b> is identical to <b>mutex_enter</b>
88 except that it does not block if the lock is held by another
89 thread. The function returns true if the lock was
90 successfully acquired, or false if another thread is
91 currently holding it.</td></table>
92 <a name="BUGS"></a>
93 <h2>BUGS</h2>
94
95 <table width="100%" border=0 rules="none" frame="void"
96        cols="2" cellspacing="0" cellpadding="0">
97 <tr valign="top" align="left">
98 <td width="10%"></td><td width="90%">
99 A common mistake is to accidentally call <b>mutex_leave</b>
100 when you are not holding the lock. This generally causes the
101 library to crash.</td></table>
102 <a name="AUTHOR"></a>
103 <h2>AUTHOR</h2>
104
105 <table width="100%" border=0 rules="none" frame="void"
106        cols="2" cellspacing="0" cellpadding="0">
107 <tr valign="top" align="left">
108 <td width="10%"></td><td width="90%">
109 Richard Jones &lt;rich@annexia.org&gt;</td></table>
110 <a name="LICENSE"></a>
111 <h2>LICENSE</h2>
112
113 <table width="100%" border=0 rules="none" frame="void"
114        cols="2" cellspacing="0" cellpadding="0">
115 <tr valign="top" align="left">
116 <td width="10%"></td><td width="90%">
117 GNU LGPL (see http://www.gnu.org/)</td></table>
118 <a name="VERSION"></a>
119 <h2>VERSION</h2>
120
121 <table width="100%" border=0 rules="none" frame="void"
122        cols="2" cellspacing="0" cellpadding="0">
123 <tr valign="top" align="left">
124 <td width="10%"></td><td width="90%">
125 pthrlib-3.0.3</td></table>
126 <hr>
127 </body>
128 </html>