Showing posts with label Symbian FAQ. Show all posts
Showing posts with label Symbian FAQ. Show all posts

Thursday, January 22, 2015

WHAT IS THE PURPOSE OF THE UID USED BY DLL & EXE IN SYMBIAN?

A Symbian OS UID is a 32-bit, globally unique identifier value used to identify a file type, both for running executable code and for associating data files with the appropriate application. Symbian OS uses a combination of up to three UIDs to uniquely identify a binary executable.

UID1: UID1 is a system-level identifier which distinguishes between EXEs and DLLs. This value is never stated explicitly but is determined by the Symbian build tools from the targettype specified in the MMP file.

UID2: distinguishes between shared library DLLs (KSharedLibrary-and polymorphic interface DLLs (in case of UID1 is DLL).

UID3: identifies a component uniquely. In order to ensure that each binary that needs a distinguishing UID is assigned a genuinely unique value, Symbian manages UID allocation through a central database and developers must be registered with Symbian Signed to request
UIDs
Note:
UID2 is not relevant for an EXE and can be left unspecified or set explicitly to KNullUid (= 0). UID3 can be left unspecified too but, on Symbian OS v9 and beyond, it should usually be set to a unique value to act as the secure identifier for the binary.

WHAT IS MEAN BY WRITABLE STATIC DATA IN SYMBIAN?

Writable Staitic Data:
Symbian OS Supports global writable staitic data in EXEs on all versions and handsets.
However writable static data can not be used in DLL on Symbian OS version 8.1a, 8.0a or earlier (KKA1 Architecure was used).
Symbian OS versions 8.0b, 8.1b, 9.0 and beyond do now support the use of writable static data in DLLs, but it is still not recommended, because it is expensive in terms of memory usage.
Note: In order to enable global writable static data on EKA2, the EPOCALLOWDLLDATAkeyword must be added to the MMP file of a DLL
Workaround to avoid writable static data:
1. Thread – local storage:
Thread-local storage is simply a 32-bit pointer, specific to each thread, that can be used to refer to an object which simulates global writable static data. All the global data must be grouped within this single object, which is allocated on the heap on creation of the thread. The
pointer to the object is saved to the thread-local storage pointer, using Dll::SetTls. To access the global data, the code calls Dll::Tls().
2. Client–server framework:
Symbian OS supports writable global static data in EXEs. A common porting strategy is to wrap the code in a Symbian server (which is an EXE), and expose its API as a client interface.

WHAT IS CRITICAL SECTION?

A critical section is a region of code that should not be entered simultaneously by multiple threads. An example is code that manipulates global static data, since it could cause problems if multiple threads change the data simultaneously. Symbian OS provides the RCriticalSection class that allows only one thread within the process into the controlled section, forcing other threads attempting to gain access to that critical section to wait until the first thread has exited from the critical section.
While in critical section the thread cannot be suspended or killed. Any suspension or kill will be deferred until the thread leaves the critical section.

WHAT IS CONTEXT SWITCH?

A context switch is the action of switching a CPU execution between executing one thread and another (or transferring control between them). This may involve crossing one or more protection boundary.