Symbian3/PDK/Source/GUID-547CF71C-6A62-57C0-A9BE-E76B4286C6D6.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-547CF71C-6A62-57C0-A9BE-E76B4286C6D6" xml:lang="en"><title>Threads
And Processes Overview</title><shortdesc>This document provides an overview of threads and processes.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-D894C473-2BCF-4988-BF07-435C7A779BAF"><title>Purpose</title> <p>Provides
access to processes, threads, and thread-local storage.</p> <p>Processes are
usually only manipulated directly by system programs. Threads can be directly
manipulated by multi-threaded programs. Note however that the active objects
framework provided by the Asynchronous Services API is usually preferred to
multi-threading in Symbian platform programming.</p> </section>
<section id="GUID-90EBDA3E-A7E1-4460-9A63-CDEC922AC58A"><title>Description</title> <p>The
API has three key concepts: process, thread, and thread-local storage. </p> <p><b>Process</b> </p> <p>A program running in Symbian platform is a process,
which can contains one or more conceptually concurrent threads of execution.
Each user process has its own private address space. A process can create
another process. </p> <p>Processes are Kernel objects and so are accessed
by user programs through handles. </p> <p>The process handle interface is
provided by <xref href="GUID-9DD1EA2B-DC59-315C-8E9C-CE6D9461B695.dita"><apiname>RProcess</apiname></xref>.</p> <p><xref href="GUID-71AF2BC3-5CCD-3561-8807-7B8CDC1A64E9.dita"><apiname>TFindProcess</apiname></xref> is
used for finding another process.</p> <p><b>Thread</b> </p> <p>A thread is the unit of execution within a process. The scheduling
of threads is pre-emptive, i.e. a currently executing thread may be suspended
at any time to allow another thread to run.</p> <p>Note the following properties
of threads:</p> <ul>
<li id="GUID-7FA506FD-3F36-51AB-87C6-0A4415ED4257"><p>every process has a
primary thread that is created when the process is initialised </p> </li>
<li id="GUID-3C2107B8-2979-5835-8985-AC289C75AAA6"><p>a thread can create,
suspend, resume, panic and kill other threads, subject to protection</p> </li>
<li id="GUID-D4298E05-F3C7-59E9-9E05-EA43BAE51D93"><p>data can be passed between
threads whether those threads are in different processes or the same process</p> </li>
<li id="GUID-8EF7BA10-3BBA-568B-A0BE-00A6F4B58D6C"><p>each thread has a priority:
the scheduler runs the highest-priority thread that is ready to run </p> </li>
</ul> <p>Threads are Kernel objects and so are accessed by user programs through
handles. </p> <p>The thread handle interface is provided by <xref href="GUID-B0E661BC-4058-3256-B9C3-5A4FD52F6DE5.dita"><apiname>RThread</apiname></xref>. </p> <p><xref href="GUID-29F27759-CC53-36DF-AE92-623F061D6C96.dita"><apiname>TFindThread</apiname></xref> is
used for finding another thread.</p> <p>The System Static Functions API <xref href="GUID-C197C9A7-EA05-3F24-9854-542E984C612D.dita"><apiname>User</apiname></xref> class
provides a number of functions that operate on the current thread.</p> <p><b>Thread-local storage</b> </p> <p>Thread-local storage in Symbian platform
supports one machine word of static data per DLL per thread. The scope of
the word is the thread and is only accessible to DLL code. DLL code running
on behalf of one thread does not see the same word when running on behalf
of another thread.</p> <p>The thread-local storage interface is provided by <xref href="GUID-6085A635-1664-323E-997A-EA11F75FBAC3.dita"><apiname>Dll</apiname></xref>.</p> </section>
<section id="GUID-33582F5A-3ADA-434C-BDD2-503AA667BAE0"><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>