Symbian3/SDK/Source/GUID-FA120B3F-4EC4-5A0A-8A36-D5CD032CF1B0.dita
changeset 7 51a74ef9ed63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-FA120B3F-4EC4-5A0A-8A36-D5CD032CF1B0.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
+<!-- This component and the accompanying materials are made available under the terms of the License 
+"Eclipse Public License v1.0" which accompanies this distribution, 
+and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
+<!-- Initial Contributors:
+    Nokia Corporation - initial contribution.
+Contributors: 
+-->
+<!DOCTYPE concept
+  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
+<concept id="GUID-FA120B3F-4EC4-5A0A-8A36-D5CD032CF1B0" xml:lang="en"><title>Using
+Mutexes</title><shortdesc>This document describes how to use mutexes.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>Mutexes provide serialised access to shared resources. They are Kernel
+objects and, as such, are managed by the Kernel.</p>
+<p>A mutex can be used by threads across any number of processes. If a resource
+is only shared between the threads within the same process, it can be more
+efficient to use a critical section.</p>
+<p>Access to a mutex is through an RMutex handle.</p>
+<p>Mutexes are similar to semaphores in that they have a <codeph>TInt</codeph> count
+value that is incremented by calling the <codeph>Signal()</codeph> member
+function of the mutex handle and decremented by calling the <codeph>Wait()</codeph> member
+function of the mutex handle. A mutex with a negative value implies that a
+thread must wait for access to the shared resource.</p>
+<p>Unlike a semaphore, the count value of a mutex is always set to one when
+it is constructed.</p>
+<p>The creator of a shared resource uses the <codeph>CreateLocal()</codeph> or <codeph>CreateGlobal()</codeph> member
+functions of <codeph>RMutex</codeph> to create a mutex and to open the handle
+to it. Any thread wishing to access the resource first calls <codeph>Wait()</codeph>;
+that thread then calls <codeph>Signal()</codeph> after completing its access.</p>
+<p>The first thread to call <codeph>Wait()</codeph> returns immediately, and
+is free to continue execution, but any other threads that call <codeph>Wait()</codeph> will
+wait in a queue maintained by the mutex. Waiting threads are released on a
+first-in first-out basis when the thread currently accessing the resource
+calls <codeph>Signal()</codeph>.</p>
+<p>The nature of the shared resources should be such that any access completes
+in a relatively short time so that threads do not wait for extensive periods
+on the mutex.</p>
+<p>In many cases, it may be better to use servers to serialize access to a
+shared resource (for example, the window server) rather than use a mutex. </p>
+</conbody></concept>
\ No newline at end of file