Subversion Repositories HelenOS-doc

Rev

Rev 62 | Rev 75 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 64
Line 58... Line 58...
58
    architectures can be compiled with this optimization.</para>
58
    architectures can be compiled with this optimization.</para>
59
 
59
 
60
    <para>Although the kernel does not do any floating point
60
    <para>Although the kernel does not do any floating point
61
    arithmetics<footnote>
61
    arithmetics<footnote>
62
        <para>Some architectures (e.g. ia64) inevitably use a fixed set of
62
        <para>Some architectures (e.g. ia64) inevitably use a fixed set of
63
        floating point registers to carry out its normal operations.</para>
63
        floating point registers to carry out their normal operations.</para>
64
      </footnote>, it must protect FPU context of userspace threads against
64
      </footnote>, it must protect FPU context of userspace threads against
65
    destruction by other threads. Moreover, only a fraction of userspace
65
    destruction by other threads. Moreover, only a fraction of userspace
66
    programs use the floating point unit. HelenOS contains a generic framework
66
    programs use the floating point unit. HelenOS contains a generic framework
67
    for switching FPU context only when the switch is forced.</para>
67
    for switching FPU context only when the switch is forced (i.e. a thread
-
 
68
    uses a floating point instruction and its FPU context is not loaded in the
-
 
69
    processor).</para>
68
 
70
 
69
    <para>The last member of the context family is the memory management
71
    <para>The last member of the context family is the memory management
70
    context. It includes memory management registers that identify address
72
    context. It includes memory management registers that identify address
71
    spaces on hardware level (i.e. ASIDs and page tables pointers).</para>
73
    spaces on hardware level (i.e. ASIDs and page tables pointers).</para>
72
 
74
 
Line 117... Line 119...
117
    and to the latter group as to userspace threads. Both kernel and userspace
119
    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
120
    threads are visible to the scheduler and can become a subject of kernel
119
    preemption and thread migration during times when preemption is
121
    preemption and thread migration during times when preemption is
120
    possible.</para>
122
    possible.</para>
121
 
123
 
122
    <figure>
124
    <formalpara>
123
      <title>Transitions among thread states.</title>
125
      <title>Thread states</title>
124
 
126
 
-
 
127
      <para>In each moment, a thread exists in one of five possible thread
-
 
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,
-
 
130
      it is put into the <code>Entering</code> state. After some time, the
-
 
131
      scheduler picks up the thread and starts executing it. A thread being
-
 
132
      currently executed on a processor is in the <code>Running</code> state.
-
 
133
      From there, the thread has three possibilities. It either runs until it
-
 
134
      is preemtped, in which case the state changes to <code>Ready</code>,
-
 
135
      goes to the <code>Sleeping</code> state by going to sleep or enters the
-
 
136
      <code>Exiting</code> state when it reaches termination.<figure>
-
 
137
          <title>Transitions among thread states.</title>
-
 
138
 
125
      <mediaobject id="thread_states" xreflabel="">
139
          <mediaobject id="thread_states" xreflabel="">
126
        <imageobject role="html">
140
            <imageobject role="html">
127
          <imagedata fileref="images/thread_states.png" format="PNG" />
141
              <imagedata fileref="images/thread_states.png" format="PNG" />
128
        </imageobject>
142
            </imageobject>
129
 
143
 
130
        <imageobject role="fop">
144
            <imageobject role="fop">
131
          <imagedata fileref="images.vector/thread_states.svg" format="SVG" />
145
              <imagedata fileref="images.vector/thread_states.svg"
-
 
146
                         format="SVG" />
132
        </imageobject>
147
            </imageobject>
133
      </mediaobject>
148
          </mediaobject>
-
 
149
        </figure></para>
134
    </figure>
150
    </formalpara>
-
 
151
 
-
 
152
    <formalpara>
-
 
153
      <title>Pseudo threads</title>
135
 
154
 
136
    <para>HelenOS userspace layer knows even smaller units of execution. Each
155
      <para>HelenOS userspace layer knows even smaller units of execution.
137
    userspace thread can make use of an arbitrary number of pseudo threads.
156
      Each userspace thread can make use of an arbitrary number of pseudo
138
    These pseudo threads have their own synchronous register context,
157
      threads. These pseudo threads have their own synchronous register
139
    userspace code and stack. They live their own life within the userspace
158
      context, userspace code and stack. They live their own life within the
140
    thread and the scheduler does not have any idea about them because they
159
      userspace thread and the scheduler does not have any idea about them
141
    are completely implemented by the userspace library. This implies several
160
      because they are completely implemented by the userspace library. This
142
    things:</para>
-
 
143
 
-
 
144
    <itemizedlist>
161
      implies several things:<itemizedlist>
145
      <listitem>
162
          <listitem>
146
        <para>pseudothreads schedule themselves cooperatively within the time
163
            <para>pseudothreads schedule themselves cooperatively within the
147
        slice given to their userspace thread,</para>
164
            time slice given to their userspace thread,</para>
148
      </listitem>
165
          </listitem>
149
 
166
 
150
      <listitem>
167
          <listitem>
151
        <para>pseudothreads share FPU context of their containing thread
168
            <para>pseudothreads share FPU context of their containing thread
152
        and</para>
169
            and</para>
153
      </listitem>
170
          </listitem>
154
 
171
 
155
      <listitem>
172
          <listitem>
156
        <para>all pseudothreads of one userspace thread block when one of them
173
            <para>all pseudothreads of one userspace thread block when one of
157
        goes to sleep.</para>
174
            them goes to sleep.</para>
158
      </listitem>
175
          </listitem>
159
    </itemizedlist>
176
        </itemizedlist></para>
-
 
177
    </formalpara>
160
  </section>
178
  </section>
161
 
179
 
162
  <section>
180
  <section>
163
    <title>Scheduler</title>
181
    <title>Scheduler</title>
164
 
182