<?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-E865E677-1219-500C-89CF-0A2835B91834" xml:lang="en"><title>Semaphores
Overview</title><shortdesc>This document provides an overview of semaphores.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-AFC30B0D-2A45-44D9-90BB-0D8D33455873"><title>Purpose</title> <p>Synchronises co-operation between threads. </p> </section>
<section id="GUID-10F7B1B1-86CC-4877-AE42-E7D219D24183"><title>Architectural relationships</title> <p>Every thread in Symbian
platform automatically has a semaphore called a <i>thread request semaphore</i>.
It is the underlying mechanism by which a thread is put in a waiting state
until an asynchronous request completes.</p> <p>The thread request semaphore
is accessed through the System Static Functions API.</p> </section>
<section id="GUID-EE14DA53-A4E9-40EE-9384-9A626F7C7C57"><title>Description</title> <p>A semaphore restricts the number of
simultaneous users of a shared resource up to a maximum number. Threads can
request access to the resource (decrementing the semaphore), and can signal
that they have finished using the resource (incrementing the semaphore).</p> <p>A
thread that requests access to a busy resource is put in a waiting state.
The semaphore maintains a FIFO queue of such waiting threads. When another
thread increments the semaphore, the first thread in this queue is resumed.</p> <p>Semaphores
are Kernel objects and, as such, are managed by the Kernel, and accessed by
user programs through handles. </p> <p>The semaphore handle is provided by <xref href="GUID-AED27A76-3645-3A04-B80D-10473D9C5A27.dita"><apiname>RSemaphore</apiname></xref>.</p> <p><xref href="GUID-F3ACDC41-31EE-3C32-BE2C-D696B84931CD.dita"><apiname>TFindSemaphore</apiname></xref> is used for finding a semaphore created by another process.</p> </section>
<section id="GUID-774B1B01-7034-4462-B1C2-86BC22A62557"><title>See also</title> <p><xref href="GUID-1294F540-FDA7-5050-BAFB-3C9888491B98.dita">Asynchronous
Services Overview</xref> </p> <p><xref href="GUID-FF8F5D97-7D37-5F6B-84A3-C064E2FD53E0.dita">System
Static Functions Overview</xref> </p> </section>
</conbody></concept>