42,7 → 42,7 |
architecture. To highlight some, the program counter and stack pointer |
take part in the synchronous register context. These are the registers |
that must be preserved across a procedure call and during synchronous |
context switches. </para> |
context switches.</para> |
|
<para>The next type of the context understood by the kernel is the |
asynchronous register context. On an interrupt, the interrupted execution |
103,8 → 103,47 |
</section> |
|
<section> |
<title>Scheduler</title> |
<title>Threads</title> |
|
<para>How scheduler designed and how it works.</para> |
<para>A thread is the basic executable entity with some code and stack. |
While the code, implemented by a C language function, can be shared by |
several threads, the stack is always private to each instance of the |
thread. Each thread belongs to exactly one task through which it shares |
address space with its sibling threads. Threads that execute purely in the |
kernel don't have any userspace memory allocated. However, when a thread |
has ambitions to run in userspace, it must be allocated a userspace stack. |
The distinction between the purely kernel threads and threads running also |
in userspace is made by refering to the former group as to kernel threads |
and to the latter group as to userspace threads. Both kernel and userspace |
threads are visible to the scheduler and can become a subject of kernel |
preemption and thread migration during times when preemption is |
possible.</para> |
|
<para>HelenOS userspace layer knows even smaller units of execution. Each |
userspace thread can make use of an arbitrary number of pseudo threads. |
These pseudo threads have their own synchronous register context, |
userspace code and stack. They live their own life within the userspace |
thread and the scheduler does not have any idea about them because they |
are completely implemented by the userspace library. This implies several |
things:</para> |
|
<itemizedlist> |
<listitem> |
<para>pseudothreads schedule themselves cooperatively within the time |
slice given to their userspace thread,</para> |
</listitem> |
|
<listitem> |
<para>pseudothreads share FPU context of their containing thread |
and</para> |
</listitem> |
|
<listitem> |
<para>all pseudothreads of one userspace thread block when one of them |
goes to sleep.</para> |
</listitem> |
</itemizedlist> |
|
<para></para> |
</section> |
</chapter> |