3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>new_mutex</title>
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>
19 <!-- Creator : groff version 1.17.2 -->
20 <!-- CreationDate: Fri Aug 30 16:16:29 2002 -->
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>
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 <pthr_mutex.h>
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>
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>
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>
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>
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>
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>
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>
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>
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 <rich@annexia.org></td></table>
110 <a name="LICENSE"></a>
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>
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>