Symbian3/SDK/Source/GUID-092C18D4-A525-5562-9BF6-41435E400290.dita
changeset 13 48780e181b38
parent 8 ae94777fff8f
equal deleted inserted replaced
12:80ef3a206772 13:48780e181b38
    14 on the Symbian platform) program, the use of the LibpThread library
    14 on the Symbian platform) program, the use of the LibpThread library
    15 to demonstrate simple multi-threading and synchronisation. </p>
    15 to demonstrate simple multi-threading and synchronisation. </p>
    16 <p>The purpose is to create a basic multithreading example showing
    16 <p>The purpose is to create a basic multithreading example showing
    17 the usage of the LibpThread APIs. This example also shows how multi-threading
    17 the usage of the LibpThread APIs. This example also shows how multi-threading
    18 is used to achieve concurrency in tasks and sharing of resources. </p>
    18 is used to achieve concurrency in tasks and sharing of resources. </p>
    19 <section id="GUID-026FD8D6-6C4A-5958-B289-775D4AE1E756-GENID-1-10-1-11-1-1-5-1-3-1-11-1-7-1-2-3"><title>Download</title> <p>Click on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-84e8baf2-57f1-4255-aeb8-a6ed0ed2145e.zip" scope="external"> LibpThreadExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-84e8baf2-57f1-4255-aeb8-a6ed0ed2145e.html" scope="peer">browse</xref> to view the example code. </p> </section>
    19 <section id="GUID-026FD8D6-6C4A-5958-B289-775D4AE1E756-GENID-1-10-1-13-1-1-5-1-3-1-11-1-7-1-2-3"><title>Download</title> <p>Click on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-84e8baf2-57f1-4255-aeb8-a6ed0ed2145e.zip" scope="external"> LibpThreadExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-84e8baf2-57f1-4255-aeb8-a6ed0ed2145e.html" scope="peer">browse</xref> to view the example code. </p> </section>
    20 <section id="GUID-7E7C4564-B10E-41F9-8A9D-D8A6C5E9C51C-GENID-1-10-1-11-1-1-5-1-3-1-11-1-7-1-2-4"><title>Description</title> <p>The following sections provide more information about the steps
    20 <section id="GUID-7E7C4564-B10E-41F9-8A9D-D8A6C5E9C51C-GENID-1-10-1-13-1-1-5-1-3-1-11-1-7-1-2-4"><title>Description</title> <p>The following sections provide more information about the steps
    21 that the example performs. </p> <p><b> Thread Synchronisation</b> </p> <p>The example creates three threads named ThreadOne,
    21 that the example performs. </p> <p><b> Thread Synchronisation</b> </p> <p>The example creates three threads named ThreadOne, ThreadTwo
    22 ThreadTwo and ThreadThree. The threads write "One", "Two" and "Three"
    22 and ThreadThree. The threads write "One", "Two" and "Three" five times
    23 five times in a text file. The text file, located in <filepath>epoc32\winscw\c\newfile.txt</filepath>, is used as a shared resource for all three threads. A mutex is
    23 in a text file. The text file, located in <filepath>epoc32\winscw\c\newfile.txt</filepath>, is used as a shared resource for all three threads. A mutex is
    24 used to ensure that first ThreadOne writes in the file, then ThreadTwo
    24 used to ensure that first ThreadOne writes in the file, then ThreadTwo
    25 and then ThreadThree. If the mutex is not used all the threads can
    25 and then ThreadThree. If the mutex is not used all the threads can
    26 simultaneously write in the file. This can be seen by commenting out <codeph>pthread_mutex_lock</codeph> and <codeph>pthread_mutex_unlock</codeph> in the code. </p> </section>
    26 simultaneously write in the file. This can be seen by commenting out <codeph>pthread_mutex_lock</codeph> and <codeph>pthread_mutex_unlock</codeph> in the code. </p> </section>
    27 <section id="GUID-236CB272-E196-4A61-B627-ACFFC4B37AA1"><title>Related
    27 <section id="GUID-236CB272-E196-4A61-B627-ACFFC4B37AA1"><title>Related
    28 APIs</title><p><xref href="GUID-94FEEC14-384E-364F-929F-0339FE559FB0.dita"><apiname>pthread_mutex_lock(pthread_mutex_t *)</apiname></xref> </p><p><xref href="GUID-E0AABD52-5A8F-3F49-A46D-5CE5BE975765.dita"><apiname>pthread_mutex_unlock(pthread_mutex_t *)</apiname></xref> </p><p><xref href="GUID-23868643-4C61-3661-843B-2D67C54CF163.dita"><apiname>pthread_join(pthread_t,void **)</apiname></xref></p><p><xref href="GUID-889CB456-6980-3B92-9350-0C6C8C9AC435.dita"><apiname>pthread_mutex_t</apiname></xref></p></section>
    28 APIs</title><p><xref href="GUID-94FEEC14-384E-364F-929F-0339FE559FB0.dita"><apiname>pthread_mutex_lock(pthread_mutex_t *)</apiname></xref> </p><p><xref href="GUID-E0AABD52-5A8F-3F49-A46D-5CE5BE975765.dita"><apiname>pthread_mutex_unlock(pthread_mutex_t *)</apiname></xref> </p><p><xref href="GUID-23868643-4C61-3661-843B-2D67C54CF163.dita"><apiname>pthread_join(pthread_t,void **)</apiname></xref></p><p><xref href="GUID-889CB456-6980-3B92-9350-0C6C8C9AC435.dita"><apiname>pthread_mutex_t</apiname></xref></p></section>
    29 <section id="GUID-67A72761-1D92-46D1-B1C9-7455978BDE4E-GENID-1-10-1-11-1-1-5-1-3-1-11-1-7-1-2-6"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian
    29 <section id="GUID-67A72761-1D92-46D1-B1C9-7455978BDE4E-GENID-1-10-1-13-1-1-5-1-3-1-11-1-7-1-2-6"><title>Build</title> <p>The Symbian build process describes how to build this example
    30 build process</xref> describes how to build this example application. </p> <p>The example builds an executable called <filepath>LibpThreadExample.exe</filepath> in the standard locations. </p> <p>To run the example, start <filepath>LibpThreadExample.exe</filepath> from the file system or from your
    30 application. </p> <p>The example builds an executable
    31 IDE. After launching the executable, depending on the emulator you
    31 called <filepath>LibpThreadExample.exe</filepath> in the standard
    32 are using, you may need to navigate away from the application launcher
    32 locations. </p> <p>To run the example, start <filepath>LibpThreadExample.exe</filepath> from the file system or from your IDE. After launching the executable,
    33 or shell screen to view the console. </p> </section>
    33 depending on the emulator you are using, you may need to navigate
       
    34 away from the application launcher or shell screen to view the console. </p> </section>
    34 </conbody></concept>
    35 </conbody></concept>