## Thread State Summary

This is a brief summary about nanokernel thread states and Symbian OS thread states.

### Nanokernel thread states

The state of a nanokernel thread is referred to as the NState (or N-state). This is to disambiguate it from any other state, such as the state of a Symbian OS thread (referred to as the MState or M-state).

The states of a nanokernel thread are defined by the values of the NThreadBase::NThreadState enumeration.

### Symbian OS thread states

The state of a Symbian OS thread is referred to as the MState (or M_state). This is in addition to the nanokernel N-state, and tracks threads waiting on Symbian OS synchronisation objects. The DThread class representing a Symbian OS thread is internal to Symbian, but the following table defines its possible states. The values in the left-hand column are the enumerators of the internal enumeration DThread::TThreadState.

ECreated | The initial state of all Symbian OS threads. It is a transient state; the thread starts in this state when the DThread object is created, and stays in that state until it is ready to be resumed, typically when DLL linkage and memory allocation is complete. At this point, the state will change to EReady.
EDead | This is the final state of a Symbian OS thread. A thread enters this state when it reaches the end of its exit handler, just before the nanokernel terminates it. In effect, the thread has exited but has not yet been deleted.
EReady | This indicates that the thread is not waiting on, or attached to any Symbian OS kernel wait object. It does not necessarily imply that the thread is actually ready to run - this is indicated by the N-state. For example, a thread that is explicitly suspended or waiting on a nanokernel wait object (generally a fast semaphore) still has a READY M-state provided that it is not attached to any Symbian OS wait object.
EWaitSemaphore | This indicates that the thread is currently blocked waiting for a Symbian OS semaphore, and is enqueued on the semaphore’s wait queue. The thread’s DThread::iWaitObj field points to the semaphore. For example, this is the case if the thread calls User::WaitForRequest() or RSemaphore::Wait()
EWaitSemaphoreSuspended | This indicates that the thread has been explicitly suspended after blocking on a Symbian OS semaphore, and is enqueued on the semaphore’s suspended queue. The thread’s DThread::iWaitObj field points to the semaphore.
EWaitMutex | This indicates that the thread is currently blocked waiting for a Symbian OS mutex, and is enqueued on the mutex wait queue. The thread’s DThread::iWaitObj field points to the mutex.
EWaitMutexSuspended | This indicates that the thread has been explicitly suspended after blocking on a Symbian OS mutex, and is enqueued on the mutex suspended queue. The thread’s DThread::iWaitObj field points to the mutex.
EHoldMutexPending | This indicates that the thread has been woken up from the EWaitMutex state but has not yet claimed the mutex. The thread is enqueued on the mutex pending queue and the thread’s DThread::iWaitObj field points to the mutex.
EWaitCondVar | This indicates that the thread is waiting on a condition variable.
EWaitCondVarSuspended | This indicates that the thread is suspended while waiting on a condition variable.