Symbian3/PDK/Source/GUID-242D9F27-401B-4230-B3A6-11E2D9D3DE17.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-242D9F27-401B-4230-B3A6-11E2D9D3DE17" xml:lang="en"><title>Threading
       
    13 Model</title><shortdesc>Describes the impacts of thread execution in SMP environment.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>In single core system, the active threads are executed in a time-sliced
       
    15 fashion and appear to run in parallel. In a multi-core environment, multiple
       
    16 threads can be executed in parallel and can also use time-sliced thread execution. </p>
       
    17 <section id="GUID-54670F76-522D-48FC-8D71-397E0E14D9DE"><title>Single-threaded
       
    18 code</title>The applications designed with single threads will not have any
       
    19 performance benefit by using multiple cores. The contention for CPU usage
       
    20 may be reduced on multi-core hardware. The single threaded code should run
       
    21 normally on multi-core hardware. Some code is more efficient
       
    22 having single threads and some code performs better with multiple threads.<note> It
       
    23 is not recommended to modify a single-threaded application into multi-threaded
       
    24 code until the existing code runs safely on multiple-core hardware. But new
       
    25 applications can be designed to be multi-threaded to take advantage of the
       
    26 SMP hardware.</note></section>
       
    27 <section id="GUID-80EF734A-69F4-4B21-B031-F22D23721629"><title>Servers</title><p>Most
       
    28 servers on Symbian platform are single threaded and are unlikely to need any
       
    29 modification to migrate to a multi-core hardware. Some servers may need to
       
    30 service multiple clients concurrently. One of the solutions to take advantage
       
    31 of SMP hardware is to modify the servers to have multiple threads to service
       
    32 the clients concurrently. The performance can also be improved by implementing
       
    33 caching in the server. </p></section>
       
    34 <section id="GUID-DA500B10-CE4F-4640-A203-A06E0DD63C10"><title>Active scheduler</title><p>Active
       
    35 schedulers are designed to be single threaded and the active objects never
       
    36 run concurrently because there is no need for a lock in the data shared between
       
    37 active objects. The active scheduler will only execute one active object at
       
    38 a time. The existing code should run safely on multi-core hardware. If the
       
    39 active objects need to use multiple cores then the code should be modified
       
    40 to be multi-threaded and use locks when there is shared data between the threads. </p></section>
       
    41 <section id="GUID-31F8B40D-507B-458A-847F-2982FA06989D"><title>User-side code</title><p>The
       
    42 user-side applications that use Symbian platform Inter Process Communication
       
    43 (IPC) functions like <xref href="GUID-B0E661BC-4058-3256-B9C3-5A4FD52F6DE5.dita#GUID-B0E661BC-4058-3256-B9C3-5A4FD52F6DE5/GUID-83AADCC6-1AD8-32D8-A6E6-B86B47C97DC2"><apiname>RThread::Rendezvous()</apiname></xref>, <xref href="GUID-C197C9A7-EA05-3F24-9854-542E984C612D.dita#GUID-C197C9A7-EA05-3F24-9854-542E984C612D/GUID-2F263A1B-BB71-396C-8C45-B0D062327FFA"><apiname>User::RequestComplete()</apiname></xref>, <xref href="GUID-9741288A-B0EE-3098-B891-43124FF056BB.dita#GUID-9741288A-B0EE-3098-B891-43124FF056BB/GUID-5ACB4970-55CA-3ECD-8388-C9CE9CFF103E"><apiname>RSession::SendReceive()</apiname></xref> or Publish-Subscribe should run safely on multi-core hardware. If the user-side
       
    44 code uses some proprietary IPC mechanism to communicate with other process,
       
    45 that code may need to be modified to use Symbian IPC functions. </p><table id="GUID-114D4D3D-C28E-43BE-85CA-01DCAD2B944B">
       
    46 <desc>The following table compares the advantages of single-threaded and multi-threaded
       
    47 applications on an SMP hardware:</desc>
       
    48 <tgroup cols="2"><colspec colname="col1"/><colspec colname="col2"/>
       
    49 <thead>
       
    50 <row>
       
    51 <entry valign="top">Single-threaded applications</entry>
       
    52 <entry valign="top">Multi-threaded applications</entry>
       
    53 </row>
       
    54 </thead>
       
    55 <tbody>
       
    56 <row>
       
    57 
       
    58 <entry>Low CPU usage for schedulers</entry>
       
    59 <entry>Parallel execution provides faster execution</entry>
       
    60 </row>
       
    61 <row>
       
    62 <entry>Low memory overhead</entry>
       
    63 <entry>Added control on power consumption</entry>
       
    64 </row>
       
    65 <row>
       
    66 <entry>Low cache overhead</entry>
       
    67 <entry>Servers that have to service multiple clients can run on different
       
    68 CPUs</entry>
       
    69 </row>
       
    70 </tbody>
       
    71 </tgroup>
       
    72 </table></section>
       
    73 </conbody><related-links>
       
    74 <link href="GUID-387E98B0-568D-4DBB-9A9E-616E41E96B58.dita"><linktext>SMP Overview</linktext>
       
    75 </link>
       
    76 </related-links></concept>