Rev 61 | Rev 64 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 61 | Rev 62 | ||
---|---|---|---|
Line 117... | Line 117... | ||
117 | and to the latter group as to userspace threads. Both kernel and userspace |
117 | and to the latter group as to userspace threads. Both kernel and userspace |
118 | threads are visible to the scheduler and can become a subject of kernel |
118 | threads are visible to the scheduler and can become a subject of kernel |
119 | preemption and thread migration during times when preemption is |
119 | preemption and thread migration during times when preemption is |
120 | possible.</para> |
120 | possible.</para> |
121 | 121 | ||
122 | <para> |
122 | <figure> |
- | 123 | <title>Transitions among thread states.</title> |
|
- | 124 | ||
123 | <mediaobject id="thread_states" xreflabel=""> |
125 | <mediaobject id="thread_states" xreflabel=""> |
124 | <imageobject role="html"> |
126 | <imageobject role="html"> |
125 | <imagedata fileref="images/thread_states.png" format="PNG" /> |
127 | <imagedata fileref="images/thread_states.png" format="PNG" /> |
126 | </imageobject> |
128 | </imageobject> |
127 | 129 | ||
128 | <imageobject role="fop"> |
130 | <imageobject role="fop"> |
129 | <imagedata fileref="images.vector/thread_states.svg" format="SVG" /> |
131 | <imagedata fileref="images.vector/thread_states.svg" format="SVG" /> |
130 | </imageobject> |
132 | </imageobject> |
131 | - | ||
132 | <caption>Transitions among thread states.</caption> |
- | |
133 | </mediaobject> |
133 | </mediaobject> |
134 | </para> |
134 | </figure> |
135 | - | ||
136 | 135 | ||
137 | <para>HelenOS userspace layer knows even smaller units of execution. Each |
136 | <para>HelenOS userspace layer knows even smaller units of execution. Each |
138 | userspace thread can make use of an arbitrary number of pseudo threads. |
137 | userspace thread can make use of an arbitrary number of pseudo threads. |
139 | These pseudo threads have their own synchronous register context, |
138 | These pseudo threads have their own synchronous register context, |
140 | userspace code and stack. They live their own life within the userspace |
139 | userspace code and stack. They live their own life within the userspace |
Line 188... | Line 187... | ||
188 | suitable thread, the processor is idle and no thread executes on it. |
187 | suitable thread, the processor is idle and no thread executes on it. |
189 | Note that the act of switching to the private scheduler stack is |
188 | Note that the act of switching to the private scheduler stack is |
190 | essential. If the processor kept running using the stack of the |
189 | essential. If the processor kept running using the stack of the |
191 | preempted thread it could damage it because the old thread can be |
190 | preempted thread it could damage it because the old thread can be |
192 | migrated to another processor and scheduled there. In the worst case |
191 | migrated to another processor and scheduled there. In the worst case |
193 | scenario, two execution flows would be using the same stack. </para> |
192 | scenario, two execution flows would be using the same stack.</para> |
194 | 193 | ||
195 | <para>The scheduling policy is implemented in function |
194 | <para>The scheduling policy is implemented in function |
196 | <code>find_best_thread</code>. This function walks the processor run |
195 | <code>find_best_thread</code>. This function walks the processor run |
197 | queues from lower towards higher indices and looks for a thread. If the |
196 | queues from lower towards higher indices and looks for a thread. If the |
198 | visited run queue is empty, it simply searches the next run queue. If it |
197 | visited run queue is empty, it simply searches the next run queue. If it |