Subversion Repositories HelenOS-doc

Rev

Rev 57 | Rev 59 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57 Rev 58
Line 101... Line 101...
101
      returned.</para>
101
      returned.</para>
102
    </section>
102
    </section>
103
  </section>
103
  </section>
104
 
104
 
105
  <section>
105
  <section>
106
    <title>Scheduler</title>
106
    <title>Threads</title>
107
 
107
 
-
 
108
    <para>A thread is the basic executable entity with some code and stack.
-
 
109
    While the code, implemented by a C language function, can be shared by
-
 
110
    several threads, the stack is always private to each instance of the
-
 
111
    thread. Each thread belongs to exactly one task through which it shares
-
 
112
    address space with its sibling threads. Threads that execute purely in the
-
 
113
    kernel don't have any userspace memory allocated. However, when a thread
-
 
114
    has ambitions to run in userspace, it must be allocated a userspace stack.
-
 
115
    The distinction between the purely kernel threads and threads running also
-
 
116
    in userspace is made by refering to the former group as to kernel threads
-
 
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
-
 
119
    preemption and thread migration during times when preemption is
-
 
120
    possible.</para>
-
 
121
 
-
 
122
    <para>HelenOS userspace layer knows even smaller units of execution. Each
-
 
123
    userspace thread can make use of an arbitrary number of pseudo threads.
-
 
124
    These pseudo threads have their own synchronous register context,
-
 
125
    userspace code and stack. They live their own life within the userspace
108
    <para>How scheduler designed and how it works.</para>
126
    thread and the scheduler does not have any idea about them because they
-
 
127
    are completely implemented by the userspace library. This implies several
-
 
128
    things:</para>
-
 
129
 
-
 
130
    <itemizedlist>
-
 
131
      <listitem>
-
 
132
        <para>pseudothreads schedule themselves cooperatively within the time
-
 
133
        slice given to their userspace thread,</para>
-
 
134
      </listitem>
-
 
135
 
-
 
136
      <listitem>
-
 
137
        <para>pseudothreads share FPU context of their containing thread
-
 
138
        and</para>
-
 
139
      </listitem>
-
 
140
 
-
 
141
      <listitem>
-
 
142
        <para>all pseudothreads of one userspace thread block when one of them
-
 
143
        goes to sleep.</para>
-
 
144
      </listitem>
-
 
145
    </itemizedlist>
-
 
146
 
-
 
147
    <para></para>
109
  </section>
148
  </section>
110
</chapter>
149
</chapter>
111
150