1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.1.0 for Windows">
7<META http-equiv="Content-Style-Type" content="text/css">
8<title>OS_UnlockMutex[R|W|RW]</title>
9<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
10</head>
11
12<body>
13
14<h1 align="left">OS_UnlockMutex[R|W|RW] <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></h1>
15<h2>Syntax</h2>
16
17<dl>
18  <dd>
19<CODE>#include &lt;nitro/os.h&gt;</CODE><BR> <BR> <CODE>void OS_UnlockMutexR( OSMutex* mutex );</CODE><BR> <BR> <CODE>void OS_UnlockMutexW( OSMutex* mutex );</CODE><BR> <BR> <CODE>void OS_UnlockMutexRW( OSMutex* mutex );</CODE></dd>
20</dl>
21
22<h2>Arguments</h2>
23<TABLE border="1" width="100%">
24  <TBODY>
25    <TR>
26      <TD width="13%"><CODE>mutex</CODE></TD>
27      <TD width="87%">Pointer to the <CODE>OSMutex</CODE> structure</TD>
28    </TR>
29  </TBODY>
30</TABLE>
31
32<h2>Return Values</h2>
33<p>None.</p>
34
35<H2>Description</H2>
36<P>The thread calling this function unlocks the <CODE>mutex</CODE>.<BR></P>
37<P>The <CODE>OS_UnlockMutexR</CODE> function unlocks a <CODE>read lock</CODE>. When unlocking a <CODE>read lock</CODE>, it does not matter if the calling thread is not the owner of <CODE>mutex</CODE>. Note that if <CODE>mutex</CODE> has been locked <I>n</I> times, only the <I>nth</I> <CODE>OS_UnlockMutexR</CODE> function call actually releases the lock.</P>
38<P>The <CODE>OS_UnlockMutexW</CODE> function unlocks a <CODE>write lock</CODE>. To unlock a <CODE>write lock</CODE>, the calling thread must be the owner of <CODE>mutex</CODE>. Note that if <CODE>mutex</CODE> has been locked <I>n</I> times by the calling thread, it is only released by the <I>nth</I> call to the <CODE>OS_UnlockMutexW</CODE> function.</P>
39<P>The <CODE>OS_UnlockMutexRW</CODE> function can unlock both a <CODE>read lock</CODE> and a <CODE>write lock</CODE>. It has the characteristics of both the <CODE>OS_UnlockMutexR</CODE> and <CODE>OS_UnlockMutexW</CODE> functions noted above. It can also unlock a mutex locked with the <CODE><A href="OS_LockMutex.html">OS_LockMutex</A></CODE> function.</P>
40<H3><BR>Lock and Unlock Correlation</H3>
41<P>If <CODE><A href="OS_LockMutexRW.html">mutex</A></CODE> has been locked by the <CODE><A href="OS_LockMutexRW.html">OS_LockMutexR</A></CODE> function, unlock it using the <CODE><A href="OS_LockMutexRW.html">OS_UnlockMutexR</A></CODE> or <CODE><A href="OS_LockMutexRW.html">OS_UnlockMutexRW</A></CODE> function. If you try to unlock using the <CODE>OS_UnlockMutexW</CODE> function the process will stop with the <CODE><A href="../debug/OS_Panic.html">OS_Panic</A></CODE> function.</P>
42<P>If <CODE><A href="OS_LockMutexRW.html">mutex</A></CODE> has been locked by the <CODE><A href="OS_LockMutexRW.html">OS_LockMutexW</A></CODE> function, unlock it using the <CODE><A href="OS_LockMutexRW.html">OS_UnlockMutexW</A></CODE> or <CODE><A href="OS_LockMutexRW.html">OS_UnlockMutexRW</A></CODE> function. If you try to unlock using the <CODE>OS_UnlockMutexR</CODE> function, the process will stop with the <CODE><A href="../debug/OS_Panic.html">OS_Panic</A></CODE> function.</P>
43<P>The process will also stop with the <CODE><A href="../debug/OS_Panic.html">OS_Panic</A></CODE> function if you try using the <CODE>OS_UnlockMutexR</CODE>, <CODE>OS_UnlockMutexW</CODE> or <CODE>OS_UnlockMutexRW</CODE> function to unlock a <CODE>mutex</CODE> that is not locked.</P>
44<P>If the process stops with the <CODE><A href="../debug/OS_Panic.html">OS_Panic</A></CODE> function, check the correlation of lock and unlock functions in the application.</P>
45<H3><BR>Exiting the Thread</H3>
46<P>When the thread that is locking <CODE>mutex</CODE> is terminated with the <A href="../thread/OS_ExitThread.html"><CODE>OS_ExitThread</CODE></A> function, <CODE>mutex</CODE> is automatically unlocked.</P>
47<h2>See Also</h2>
48<p><CODE><A href="OS_InitMutex.html">OS_InitMutex</A><BR> <A href="OS_LockMutex.html">OS_LockMutex</A><BR> <A href="OS_TryLockMutex.html">OS_TryLockMutex</A><BR> <A href="../thread/OS_ExitThread.html">OS_ExitThread</A><br> <A href="OS_LockMutexRW.html">OS_LockMutexR</A><BR> <A href="OS_LockMutexRW.html">OS_LockMutexW</A><BR> <A href="OS_TryLockMutexRW.html">OS_TryLockMutexR</A><BR> <A href="OS_TryLockMutexRW.html">OS_TryLockMutexW</A><BR> <A href="OS_LockMutexFromToRW.html">OS_LockMutexFromRToW</A><BR> <A href="OS_LockMutexFromToRW.html">OS_LockMutexFromWToR</A><BR> <A href="OS_TryLockMutexFromToRW.html">OS_TryLockMutexFromRToW</A><BR> <A href="OS_TryLockMutexFromToRW.html">OS_TryLockMutexFromWToR</A></CODE></p>
49<H2>Revision History</H2>
50<P>2008/12/16 Initial version.</P>
51<hr><p>CONFIDENTIAL</p></body>
52</html>
53