159 lines
5.6 KiB
HTML
159 lines
5.6 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>pthread_rwlock_unlock()--Unlock Exclusive Write or Shared Read Lock</title>
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- NETMG2 SCRIPT A converted by B2H R4.1 (346) (CMS) by HOLTJM at -->
|
||
|
<!-- RCHVMW2 on 29 Jan 1999 at 10:01:37 -->
|
||
|
<!--File Edited November 2001 -->
|
||
|
<!--End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<!-- Java sync-link -->
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>pthread_rwlock_unlock()--Unlock Exclusive Write or Shared Read Lock</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax:
|
||
|
<pre> #include <pthread.h>
|
||
|
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); </pre>
|
||
|
Service Program Name: QP0WPTHR<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE <br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Signal Safe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>pthread_rwlock_unlock</strong>() function unlocks a shared read or exclusive write lock held by the calling thread.</p>
|
||
|
|
||
|
<p>A thread should call <strong>pthread_rwlock_unlock</strong>() once for each time that the thread successfully called
|
||
|
<strong>pthread_rwlock_rdlock</strong>(), <strong>pthread_rwlock_tryrdlock</strong>(), <strong>pthread_rwlock_trywrlock</strong>(),
|
||
|
<strong>pthread_rwlock_timedrdlock_np</strong>(), or <strong>pthread_rwlock_timedwrlock_np</strong>() to acquire a shared read or
|
||
|
exclusive write lock. For example, if a thread holds 4 shared read locks on a read/write lock object, the thread must call
|
||
|
<strong>pthread_rwlock_unlock</strong>() 4 times before the read/write lock becomes completely unlocked.</p>
|
||
|
|
||
|
<p>If a thread holds <strong>both</strong> shared read <strong>and</strong> exclusive write locks for the specified read/write
|
||
|
lock object, the exclusive write locks are unlocked first. If more than one outstanding exclusive write lock was held by the
|
||
|
thread, a matching number of successful calls to <strong>pthread_rwlock_unlock</strong>() must be done before all write locks are
|
||
|
unlocked. When all write locks are unlocked, subsequent calls to <strong>pthread_rwlock_unlock</strong>() unlock the shared read
|
||
|
locks.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Authorities and Locks</h3>
|
||
|
|
||
|
<p>For successful completion, either a shared read or exclusive write lock must be held on the read/write lock before you call
|
||
|
<strong>pthread_rwlock_unlock</strong>().</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>rwlock</strong></dt>
|
||
|
|
||
|
<dd>(Input) The address of the read/write lock</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>0</strong></dt>
|
||
|
|
||
|
<dd><strong>pthread_rwlock_unlock</strong>() was successful.</dd>
|
||
|
|
||
|
<dt><strong>value</strong></dt>
|
||
|
|
||
|
<dd><strong>pthread_rwlock_unlock</strong>() was not successful. <em>value</em> is set to indicate the error condition.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>pthread_rwlock_unlock</strong>() was not successful, the error condition returned usually indicates one of the
|
||
|
following errors. Under some conditions, the value returned could indicate an error other than those listed here.</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><em>[EINVAL]</em></dt>
|
||
|
|
||
|
<dd><p>The value specified for the argument is not correct.</p></dd>
|
||
|
|
||
|
<dt><em>[EPERM]</em></dt>
|
||
|
|
||
|
<dd><p>A shared read or exclusive write lock was not held by the calling thread and could not be unlocked.</p></dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>pthread.h</strong>> header file. See <a href="rzah4hed.htm">Header files for Pthread functions</a>.<br><br></li>
|
||
|
|
||
|
<li><a href="users_86.htm">pthread_rwlock_init()</a>--Initialize Read/Write Lock<br><br></li>
|
||
|
|
||
|
<li><a href="users_87.htm">pthread_rwlock_rdlock()</a>--Get Shared Read Lock<br><br></li>
|
||
|
|
||
|
<li><a href="users_88.htm">pthread_rwlock_timedrdlock_np()</a>--Get Shared Read Lock with Time-Out<br><br></li>
|
||
|
|
||
|
<li><a href="users_89.htm">pthread_rwlock_timedwrlock_np()</a>--Get Exclusive Write Lock with Time-Out<br><br></li>
|
||
|
|
||
|
<li><a href="users_90.htm">pthread_rwlock_tryrdlock()</a>--Get Shared Read Lock with No Wait<br><br></li>
|
||
|
|
||
|
<li><a href="users_91.htm">pthread_rwlock_trywrlock()</a>--Get Exclusive Write Lock with No Wait<br><br></li>
|
||
|
|
||
|
<li><a href="users_93.htm">pthread_rwlock_wrlock()</a>--Get Exclusive Write Lock</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<h3>Example</h3>
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<p>See any of the following examples:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="users_90.htm#373231">pthread_rwlock_tryrdlock()</a><br><br></li>
|
||
|
|
||
|
<li><a href="users_91.htm#373418">pthread_rwlock_trywrlock()</a><br><br></li>
|
||
|
|
||
|
<li><a href="users_88.htm#372828">pthread_rwlock_timedrdlock_np()</a><br><br></li>
|
||
|
|
||
|
<li><a href="users_89.htm#373025">pthread_rwlock_timedwrlock_np()</a></li>
|
||
|
</ul>
|
||
|
|
||
|
<hr>
|
||
|
API introduced: V4R3
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> |
|
||
|
<a href="rzah4mst.htm">Pthread APIs</a> |
|
||
|
<a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|