Rev 64 | Rev 76 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 64 | Rev 75 | ||
|---|---|---|---|
| Line 122... | Line 122... | ||
| 122 | possible.</para> |
122 | possible.</para> |
| 123 | 123 | ||
| 124 | <formalpara> |
124 | <formalpara> |
| 125 | <title>Thread states</title> |
125 | <title>Thread states</title> |
| 126 | 126 | ||
| 127 | <para>In each moment, a thread exists in one of five possible thread |
127 | <para>In each moment, a thread exists in one of six possible thread |
| 128 | states. When the thread is created and first readied into the |
128 | states. When the thread is created and first readied into the |
| 129 | scheduler's run queues or when a thread is migrated to a new processor, |
129 | scheduler's run queues or when a thread is migrated to a new processor, |
| 130 | it is put into the <code>Entering</code> state. After some time, the |
130 | it is put into the <constant>Entering</constant> state. After some time, |
| 131 | scheduler picks up the thread and starts executing it. A thread being |
131 | the scheduler picks up the thread and starts executing it. A thread |
| 132 | currently executed on a processor is in the <code>Running</code> state. |
132 | being currently executed on a processor is in the |
| 133 | From there, the thread has three possibilities. It either runs until it |
133 | <constant>Running</constant> state. From there, the thread has three |
| 134 | is preemtped, in which case the state changes to <code>Ready</code>, |
134 | possibilities. It either runs until it is preemtped, in which case the |
| - | 135 | state changes to <constant>Ready</constant>, goes to the |
|
| 135 | goes to the <code>Sleeping</code> state by going to sleep or enters the |
136 | <constant>Sleeping</constant> state by going to sleep or enters the |
| 136 | <code>Exiting</code> state when it reaches termination.<figure> |
137 | <constant>Exiting</constant> state when it reaches termination. When the |
| - | 138 | thread exits, its kernel structure usually stays in memory, until the |
|
| - | 139 | thread is detached by another thread using <code>thread_detach</code> |
|
| - | 140 | function. Terminated but undetached threads are in the |
|
| - | 141 | <constant>Undead</constant> state. When the thread is detached or |
|
| - | 142 | detaches itself during its life, it is destroyed in the |
|
| - | 143 | <constant>Exiting</constant> state and the <constant>Undead</constant> |
|
| - | 144 | state is not reached.<figure> |
|
| 137 | <title>Transitions among thread states.</title> |
145 | <title>Transitions among thread states.</title> |
| 138 | 146 | ||
| 139 | <mediaobject id="thread_states" xreflabel=""> |
147 | <mediaobject id="thread_states" xreflabel=""> |
| 140 | <imageobject role="html"> |
148 | <imageobject role="html"> |
| 141 | <imagedata fileref="images/thread_states.png" format="PNG" /> |
149 | <imagedata fileref="images/thread_states.png" format="PNG" /> |