Symbian3/PDK/Source/GUID-C7B748CF-D080-5448-98AF-1634D821E713.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-C7B748CF-D080-5448-98AF-1634D821E713" xml:lang="en"><title> SMP
       
    13 Example</title><shortdesc>This example demonstrates symmetric multiprocessing using multiple
       
    14 threads. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>This example shows the differences between code running in a unicore environment
       
    16 and in a multiprocessor environment.</p>
       
    17 <section id="GUID-7AC2BE12-4F01-4140-8379-672475DE7681"><title>Download</title> <p>Click on the following link to download
       
    18 the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-577596d8-76a2-4a41-aa0f-deefe5638e23.zip" scope="external">SmpExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-577596d8-76a2-4a41-aa0f-deefe5638e23.html" scope="peer">browse</xref> to view the example code. </p> </section>
       
    19 <section id="GUID-7A70847E-40A2-4267-9BD4-36F88F48C84A"><title>Class summary</title><ul>
       
    20 <li><p><xref href="GUID-B0E661BC-4058-3256-B9C3-5A4FD52F6DE5.dita"><apiname>RThread</apiname></xref> - A handle to a thread.</p></li>
       
    21 <li><p><xref href="GUID-F4A68645-2265-307F-B951-8295827E000B.dita"><apiname>RDbStoreDatabase</apiname></xref> - DBMS Store database implementation</p></li>
       
    22 </ul></section>
       
    23 <section id="GUID-BE13F08D-09FD-41DF-9210-D46EBECADA69"><title>Design and implementation</title> <p>The example creates two
       
    24 databases named DBforSMP1.db and DBforSMP2.db and three threads: </p> <ul>
       
    25 <li id="GUID-F4EE1C84-FE30-5C99-872B-1881D852CAEA"><p> <codeph>WriterThread1</codeph>:
       
    26 It creates the DBforSMP1.db database and writes integers to it. The thread
       
    27 has the lowest priority amongst all the threads. </p> </li>
       
    28 <li id="GUID-7B2D0419-E069-59FA-A6CE-70EBC203F656"><p> <codeph>WriterThread2</codeph>:
       
    29 It creates the DBforSMP2.db database and writes some integers to it. The thread
       
    30 has highest priority amongst all the threads. </p> </li>
       
    31 <li id="GUID-7C9584F2-E6C8-5A02-B4C2-4845CF4BAA36"><p> <codeph>ReaderThread</codeph>:
       
    32 It reads the two databases and prints the output to the console. It has normal
       
    33 priority. </p> </li>
       
    34 </ul> <p>In a unicore enviroment, the threads are executed according to their
       
    35 priorities. This means first <codeph> WriterThread2</codeph>, then <codeph>ReaderThread</codeph> and
       
    36 finally <codeph>WriterThread1</codeph> is executed. Hence <codeph>ReaderThead</codeph> can
       
    37 only print the contents of the DBforSMP2.db in the console because DBforSMP1
       
    38 is empty. in an SMP environment, threads run simultaneously and <codeph>ReaderThread</codeph> can
       
    39 print the contents of both the databases. </p> </section>
       
    40 <section id="GUID-3686F166-C4DD-4269-9B9C-F0027F53547E"><title>Building and configuring</title> <p>To build the example: </p> <ul>
       
    41 <li id="GUID-037442C7-2436-5152-9A3E-9DC0B4283A9C-GENID-1-7-1-14-1-1-8-1-4-1-25-1-30-1-3-5-3-1"><p>The example builds an
       
    42 executable called <filepath>smpexample.exe</filepath> in the standard location. </p> </li>
       
    43 <li id="GUID-B7C849B9-0885-5253-A78B-71854F86D772-GENID-1-7-1-14-1-1-8-1-4-1-25-1-30-1-3-5-3-2"><p>You can build the example
       
    44 from your IDE or the command line. </p> <p>If you use an IDE, import the <filepath>bld.inf</filepath> file
       
    45 of the example into your IDE, and use the build command of the IDE. </p> <p>If
       
    46 you use the command line, open a command prompt, and set the current directory
       
    47 to the source code directory of the example. You can then build the example
       
    48 with the SBSv1 build tools with the following commands: </p> <p><userinput>bldmake
       
    49 bldfiles</userinput> </p> <p><userinput>abld build</userinput> </p> <p><xref href="GUID-793A5EF9-CC16-5EEB-9011-6431EA76EB15.dita">How to use bldmake</xref> and <xref href="GUID-B6B54E07-3B34-5D5C-8815-93383FA8FB4B.dita">How to use abld</xref> describe
       
    50 how to use the SBSv1 build tools. </p> </li>
       
    51 </ul> </section>
       
    52 <section id="GUID-F773B722-7612-4BAF-99CB-84E39CE10C40"><title>Running the example</title> <p>To test the example in an SMP
       
    53 environment, add <codeph>crazyscheduling on</codeph>in the <filepath>epoc32\data\epoc.ini</filepath> file.
       
    54 This emulates SMP behaviour in the techview emulator. Execute the example
       
    55 in both unicore and multiprocessor environment and see the difference. Run
       
    56 the example following the instructions provided in the console. </p> </section>
       
    57 </conbody></concept>