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</title> 9<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 10</head> 11 12<body> 13 14<h1 align="left">OS_UnlockMutex <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 <nitro/os.h></CODE><BR> <BR> <CODE>void OS_UnlockMutex( 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%"><EM><STRONG>mutex</STRONG></EM></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 releases <CODE>mutex</CODE>.<BR>The thread that calls this function must be the owner of <CODE>mutex</CODE>.</P> 37<P>However, when the calling thread has locked <CODE>mutex</CODE> <I>n</I> times, the mutex will only be released by the <I>n</I>th call to the <CODE><A href="OS_LockMutex.html">OS_LockMutex</A></CODE> function.</P> 38<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <BR> <CODE>OSMutex mutex;<BR> <BR> OS_LockMutex( &mutex );<BR> : <BR>OS_LockMutex( &mutex );<BR> :<BR>:<BR> :<BR> OS_UnlockMutex( &mutex ); <FONT color="#ff0000">// mutex not released yet</FONT><BR> :<BR>OS_UnlockMutex( &mutex ); <FONT color="#ff0000">// mutex is released</FONT></CODE> </BLOCKQUOTE> 39<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> 40<h2>See Also</h2> 41<p><a href="OS_InitMutex.html"><code>OS_InitMutex</code></a><BR> <a href="OS_LockMutex.html"><CODE>OS_LockMutex</CODE></a><BR> <a href="OS_TryLockMutex.html"><CODE>OS_TryLockMutex</CODE></a><BR> <a href="../thread/OS_ExitThread.html"><CODE>OS_ExitThread</CODE></a></p> 42 43<H2>Revision History</H2> 44<P>2008/12/17 Added example.<BR>2004/04/05 Added mention that mutex is unlocked by the <CODE><A href="../thread/OS_ExitThread.html">OS_ExitThread</A></CODE> function.<BR>2003/12/01 Initial version.</P> 45<hr><p>CONFIDENTIAL</p></body> 46</html> 47