Process, thread, stack and memory useful information in Debugging information

## Process and Thread Priorities

Internally the scheduler always deals with nanokernel threads, NThread objects, and their associated priority between 0 (lowest) and 63 (highest). In general, a thread with a higher priority that is ready to run will always run in preference to threads with a lower priority. The only exception is where a higher priority thread waits on a nanokernel fast mutex held by a lower priority thread. In this case, the higher priority thread will yield to the lower priority thread holding the mutex.

A Symbian OS thread, a DThread object, has an embedded NThread, which enables it to be scheduled by the nanokernel.

There are two ways of setting a priority for Symbian OS thread:

- using the two-level priority scheme

- using an absolute priority.

### The two level priority scheme

In this scheme, a Symbian OS thread priority is relative to the priority of its owning process. By default, Symbian OS threads inherit the priority of their owning process when they are created. This priority can be raised or lowered relative to the process priority - this just sets the thread’s priority to the process priority plus or minus a specified priority weighting. If the priority of the process is changed, the priority of its threads will change relative to other threads in the system but will remain the same relative to each other.

The default priority of a process is EPriorityForgeround, which is an absolute priority of 350. Threads by default are created with relative priority EPriorityNormal which sets them to the same priority as the owning process. The window server lowers the priority of background UI processes to EPriorityBackground (250).

The NULL thread, also known as the idle thread, runs at priority 0, and means that it will only run when there are no other threads ready to run.

Symbian OS thread priorities map onto NThread priorities in the range 1 to 31 as shown in the table below.

Thread priority | Idle | Much Less | Less | Normal | More | Much More | Real Time
Process priority |  |  |  |  |  |  |
Low | 1 | 1 | 2 | 3 | 4 | 5 | 22
Background | 3 | 5 | 6 | 7 | 8 | 9 | 22
Foreground | 3 | 10 | 11 | 12 | 13 | 14 | 22
High | 3 | 17 | 18 | 19 | 20 | 22 | 23
SystemServer1 | 9 | 15 | 16 | 21 | 24 | 25 | 28
SystemServer2 | 9 | 15 | 16 | 21 | 24 | 25 | 28
SystemServer3 | 9 | 15 | 16 | 21 | 24 | 25 | 28
RealTimeServer | 18 | 26 | 27 | 28 | 29 | 30 | 31

where:

- the process priority values are defined by the internal Symbian OS enum TProcPriority, defined in ...\e32\include\kernel\kern_priv.h. The symbols in the table correspond to the symbols in the enum.

- the thread priority values are defined by the internal Symbian OS enum TThrdPriority, defined in ...\e32\include\kernel\kern_priv.h. The symbols in the table correspond to the symbols in the enum.

### Absolute priority scheme

It is possible to set an absolute priority that is not relative to the process priority; it is not affected by changes in the process priority.