Symbian
Symbian OS Library

FAQ-0938 Can I use writeable static data in a multi-threaded context in Symbian OS

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Base
Created: 10/15/2003 Modified: 11/12/2003
Number: FAQ-0938
Platform: Not Applicable

Question:
I understand Symbian OS does not support writeable static data but that it provides thread local storage (TLS) which enables a work around for data written to and read by a single thread. But is there a work around for static data written to and read by multiple threads?

Answer:
The preferred mechanism Symbian OS provides for sharing data between threads is through the Symbian OS client-server mechanism (subclassing RSessionBase and CServer in the client and server code respectively). By storing your static data in a local server, typically running in the background as a .exe, it can potentially be made accessible through a client session to any thread or process running on the phone. An implementation of this approach has been provided by Peroon and is available for download with full source code from their Web site at http://www.peroon.co.il/epocstat.html.

    It should be borne in mind that, because of the context-switching required to access the server, there is a performance penalty to be borne in using the above approach so it whould only be used where truly needed. The reasons why Symbian OS does not support writeable static data are explained in FAQ-0907.