Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / rlock-objects.html
CommitLineData
86530b38
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="condition-objects.html" />
13<link rel="prev" href="lock-objects.html" />
14<link rel="parent" href="module-threading.html" />
15<link rel="next" href="condition-objects.html" />
16<meta name='aesop' content='information' />
17<title>7.5.2 RLock Objects </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="7.5.1 Lock Objects"
25 href="lock-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="7.5 threading "
28 href="module-threading.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="7.5.3 Condition Objects"
31 href="condition-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="lock-objects.html">7.5.1 Lock Objects</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-threading.html">7.5 threading </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="condition-objects.html">7.5.3 Condition Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION009520000000000000000"></A><A NAME="rlock-objects"></A>
56<BR>
577.5.2 RLock Objects
58</H2>
59
60<P>
61A reentrant lock is a synchronization primitive that may be
62acquired multiple times by the same thread. Internally, it uses
63the concepts of ``owning thread'' and ``recursion level'' in
64addition to the locked/unlocked state used by primitive locks. In
65the locked state, some thread owns the lock; in the unlocked
66state, no thread owns it.
67
68<P>
69To lock the lock, a thread calls its <tt class="method">acquire()</tt> method; this
70returns once the thread owns the lock. To unlock the lock, a
71thread calls its <tt class="method">release()</tt> method.
72<tt class="method">acquire()</tt>/<tt class="method">release()</tt> call pairs may be nested; only
73the final <tt class="method">release()</tt> (the <tt class="method">release()</tt> of the outermost
74pair) resets the lock to unlocked and allows another thread blocked in
75<tt class="method">acquire()</tt> to proceed.
76
77<P>
78<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
79 <td><nobr><b><tt id='l2h-2722' xml:id='l2h-2722' class="method">acquire</tt></b>(</nobr></td>
80 <td><var></var><big>[</big><var>blocking<code> = 1</code></var><big>]</big><var></var>)</td></tr></table></dt>
81<dd>
82Acquire a lock, blocking or non-blocking.
83
84<P>
85When invoked without arguments: if this thread already owns
86the lock, increment the recursion level by one, and return
87immediately. Otherwise, if another thread owns the lock,
88block until the lock is unlocked. Once the lock is unlocked
89(not owned by any thread), then grab ownership, set the
90recursion level to one, and return. If more than one thread
91is blocked waiting until the lock is unlocked, only one at a
92time will be able to grab ownership of the lock. There is no
93return value in this case.
94
95<P>
96When invoked with the <var>blocking</var> argument set to true, do the
97same thing as when called without arguments, and return true.
98
99<P>
100When invoked with the <var>blocking</var> argument set to false, do not
101block. If a call without an argument would block, return false
102immediately; otherwise, do the same thing as when called
103without arguments, and return true.
104</dl>
105
106<P>
107<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
108 <td><nobr><b><tt id='l2h-2723' xml:id='l2h-2723' class="method">release</tt></b>(</nobr></td>
109 <td><var></var>)</td></tr></table></dt>
110<dd>
111Release a lock, decrementing the recursion level. If after the
112decrement it is zero, reset the lock to unlocked (not owned by any
113thread), and if any other threads are blocked waiting for the lock to
114become unlocked, allow exactly one of them to proceed. If after the
115decrement the recursion level is still nonzero, the lock remains
116locked and owned by the calling thread.
117
118<P>
119Only call this method when the calling thread owns the lock.
120Do not call this method when the lock is unlocked.
121
122<P>
123There is no return value.
124</dl>
125
126<P>
127
128<DIV CLASS="navigation">
129<div class='online-navigation'>
130<p></p><hr />
131<table align="center" width="100%" cellpadding="0" cellspacing="2">
132<tr>
133<td class='online-navigation'><a rel="prev" title="7.5.1 Lock Objects"
134 href="lock-objects.html"><img src='../icons/previous.png'
135 border='0' height='32' alt='Previous Page' width='32' /></A></td>
136<td class='online-navigation'><a rel="parent" title="7.5 threading "
137 href="module-threading.html"><img src='../icons/up.png'
138 border='0' height='32' alt='Up One Level' width='32' /></A></td>
139<td class='online-navigation'><a rel="next" title="7.5.3 Condition Objects"
140 href="condition-objects.html"><img src='../icons/next.png'
141 border='0' height='32' alt='Next Page' width='32' /></A></td>
142<td align="center" width="100%">Python Library Reference</td>
143<td class='online-navigation'><a rel="contents" title="Table of Contents"
144 href="contents.html"><img src='../icons/contents.png'
145 border='0' height='32' alt='Contents' width='32' /></A></td>
146<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
147 border='0' height='32' alt='Module Index' width='32' /></a></td>
148<td class='online-navigation'><a rel="index" title="Index"
149 href="genindex.html"><img src='../icons/index.png'
150 border='0' height='32' alt='Index' width='32' /></A></td>
151</tr></table>
152<div class='online-navigation'>
153<b class="navlabel">Previous:</b>
154<a class="sectref" rel="prev" href="lock-objects.html">7.5.1 Lock Objects</A>
155<b class="navlabel">Up:</b>
156<a class="sectref" rel="parent" href="module-threading.html">7.5 threading </A>
157<b class="navlabel">Next:</b>
158<a class="sectref" rel="next" href="condition-objects.html">7.5.3 Condition Objects</A>
159</div>
160</div>
161<hr />
162<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
163</DIV>
164<!--End of Navigation Panel-->
165<ADDRESS>
166See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
167</ADDRESS>
168</BODY>
169</HTML>