This example application shows, using a P.I.P.S. (P.I.P.S. Is POSIX on the Symbian platform) program, the use of the LibpThread library to demonstrate simple multi-threading and synchronisation.
The purpose is to create a basic multithreading example showing the usage of the LibpThread APIs. This example also shows how multi-threading is used to achieve concurrency in tasks and sharing of resources.
Click on the following link to download the example: LibpThreadExample.zip
Click: browse to view the example code.
The following sections provide more information about the steps that the example performs.
The example creates three threads named ThreadOne, ThreadTwo and ThreadThree. The threads write "One", "Two" and "Three" five times in a text file. The text file, located in epoc32\winscw\c\newfile.txt , is used as a shared resource for all three threads. A mutex is used to ensure that first ThreadOne writes in the file, then ThreadTwo and then ThreadThree. If the mutex is not used all the threads can simultaneously write in the file. This can be seen by commenting out pthread_mutex_lock and pthread_mutex_unlock in the code.
The Symbian build process describes how to build this example application.
The example builds an executable called LibpThreadExample.exe in the standard locations.
To run the example, start LibpThreadExample.exe from the file system or from your IDE. After launching the executable, depending on the emulator you are using, you may need to navigate away from the application launcher or shell screen to view the console.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.