Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-getpass.html" /> | |
13 | <link rel="prev" href="module-sched.html" /> | |
14 | <link rel="parent" href="allos.html" /> | |
15 | <link rel="next" href="mutex-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>6.13 mutex -- Mutual exclusion support</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="6.12.1 Scheduler Objects" | |
25 | href="scheduler-objects.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="6. Generic Operating System" | |
28 | href="allos.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="6.13.1 Mutex Objects" | |
31 | href="mutex-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="scheduler-objects.html">6.12.1 Scheduler Objects</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="mutex-objects.html">6.13.1 Mutex Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION0081300000000000000000"> | |
56 | 6.13 <tt class="module">mutex</tt> -- | |
57 | Mutual exclusion support</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-mutex"></A> | |
62 | ||
63 | <P> | |
64 | The <tt class="module">mutex</tt> module defines a class that allows mutual-exclusion | |
65 | via acquiring and releasing locks. It does not require (or imply) | |
66 | threading or multi-tasking, though it could be useful for | |
67 | those purposes. | |
68 | ||
69 | <P> | |
70 | The <tt class="module">mutex</tt> module defines the following class: | |
71 | ||
72 | <P> | |
73 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
74 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-1988' xml:id='l2h-1988' class="class">mutex</tt></b>(</nobr></td> | |
75 | <td><var></var>)</td></tr></table></dt> | |
76 | <dd> | |
77 | Create a new (unlocked) mutex. | |
78 | ||
79 | <P> | |
80 | A mutex has two pieces of state -- a ``locked'' bit and a queue. | |
81 | When the mutex is not locked, the queue is empty. | |
82 | Otherwise, the queue contains zero or more | |
83 | <code>(<var>function</var>, <var>argument</var>)</code> pairs | |
84 | representing functions (or methods) waiting to acquire the lock. | |
85 | When the mutex is unlocked while the queue is not empty, | |
86 | the first queue entry is removed and its | |
87 | <code><var>function</var>(<var>argument</var>)</code> pair called, | |
88 | implying it now has the lock. | |
89 | ||
90 | <P> | |
91 | Of course, no multi-threading is implied - hence the funny interface | |
92 | for <tt class="method">lock()</tt>, where a function is called once the lock is | |
93 | acquired. | |
94 | </dl> | |
95 | ||
96 | <P> | |
97 | ||
98 | <p><br /></p><hr class='online-navigation' /> | |
99 | <div class='online-navigation'> | |
100 | <!--Table of Child-Links--> | |
101 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
102 | ||
103 | <UL CLASS="ChildLinks"> | |
104 | <LI><A href="mutex-objects.html">6.13.1 Mutex Objects</a> | |
105 | </ul> | |
106 | <!--End of Table of Child-Links--> | |
107 | </div> | |
108 | ||
109 | <DIV CLASS="navigation"> | |
110 | <div class='online-navigation'> | |
111 | <p></p><hr /> | |
112 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
113 | <tr> | |
114 | <td class='online-navigation'><a rel="prev" title="6.12.1 Scheduler Objects" | |
115 | href="scheduler-objects.html"><img src='../icons/previous.png' | |
116 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
117 | <td class='online-navigation'><a rel="parent" title="6. Generic Operating System" | |
118 | href="allos.html"><img src='../icons/up.png' | |
119 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
120 | <td class='online-navigation'><a rel="next" title="6.13.1 Mutex Objects" | |
121 | href="mutex-objects.html"><img src='../icons/next.png' | |
122 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
123 | <td align="center" width="100%">Python Library Reference</td> | |
124 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
125 | href="contents.html"><img src='../icons/contents.png' | |
126 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
127 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
128 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
129 | <td class='online-navigation'><a rel="index" title="Index" | |
130 | href="genindex.html"><img src='../icons/index.png' | |
131 | border='0' height='32' alt='Index' width='32' /></A></td> | |
132 | </tr></table> | |
133 | <div class='online-navigation'> | |
134 | <b class="navlabel">Previous:</b> | |
135 | <a class="sectref" rel="prev" href="scheduler-objects.html">6.12.1 Scheduler Objects</A> | |
136 | <b class="navlabel">Up:</b> | |
137 | <a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A> | |
138 | <b class="navlabel">Next:</b> | |
139 | <a class="sectref" rel="next" href="mutex-objects.html">6.13.1 Mutex Objects</A> | |
140 | </div> | |
141 | </div> | |
142 | <hr /> | |
143 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
144 | </DIV> | |
145 | <!--End of Navigation Panel--> | |
146 | <ADDRESS> | |
147 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
148 | </ADDRESS> | |
149 | </BODY> | |
150 | </HTML> |