Subversion Repositories HelenOS-doc

Rev

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

Rev 121 Rev 128
Line 13... Line 13...
13
  special layer providing a user application developer a reasonably
13
  special layer providing a user application developer a reasonably
14
  synchronous multithreaded environment sufficient to develop complex
14
  synchronous multithreaded environment sufficient to develop complex
15
  protocols.</para>
15
  protocols.</para>
16
 
16
 
17
  <section>
17
  <section>
18
    <title>Services provided by kernel</title>
18
    <title>Kernel Services</title>
19
 
19
 
20
    <para>Every message consists of 4 numeric arguments (32-bit and 64-bit on
20
    <para>Every message consists of 4 numeric arguments (32-bit and 64-bit on
21
    the corresponding platforms), from which the first one is considered a
21
    the corresponding platforms), from which the first one is considered a
22
    method number on message receipt and a return value on answer receipt. The
22
    method number on message receipt and a return value on answer receipt. The
23
    received message contains identification of the incoming connection, so
23
    received message contains identification of the incoming connection, so
Line 43... Line 43...
43
    primarily destined to deliver IRQ events to userspace device drivers.
43
    primarily destined to deliver IRQ events to userspace device drivers.
44
    These messages need not be answered, there is no party that could receive
44
    These messages need not be answered, there is no party that could receive
45
    such response.</para>
45
    such response.</para>
46
 
46
 
47
    <section>
47
    <section>
48
      <title>Low level IPC</title>
48
      <title>Low Level IPC</title>
49
 
49
 
50
      <para>The whole IPC subsystem consists of one-way communication
50
      <para>The whole IPC subsystem consists of one-way communication
51
      channels. Each task has one associated message queue (answerbox). The
51
      channels. Each task has one associated message queue (answerbox). The
52
      task can call other tasks and connect it's phones to their answerboxes.,
52
      task can call other tasks and connect it's phones to their answerboxes.,
53
      send and forward messages through these connections and answer received
53
      send and forward messages through these connections and answer received
Line 150... Line 150...
150
        </listitem>
150
        </listitem>
151
      </orderedlist>
151
      </orderedlist>
152
    </section>
152
    </section>
153
 
153
 
154
    <section>
154
    <section>
155
      <title>System call IPC layer</title>
155
      <title>System Call IPC Layer</title>
156
 
156
 
157
      <para>On top of this simple protocol the kernel provides special
157
      <para>On top of this simple protocol the kernel provides special
158
      services closely related to the inter-process communication. A range of
158
      services closely related to the inter-process communication. A range of
159
      method numbers is allocated and protocol is defined for these functions.
159
      method numbers is allocated and protocol is defined for these functions.
160
      The messages are interpreted by the kernel layer and appropriate actions
160
      The messages are interpreted by the kernel layer and appropriate actions
Line 203... Line 203...
203
      as soon as the message is acknowledged.</para>
203
      as soon as the message is acknowledged.</para>
204
    </section>
204
    </section>
205
  </section>
205
  </section>
206
 
206
 
207
  <section>
207
  <section>
208
    <title>Userspace view</title>
208
    <title>Userspace View</title>
209
 
209
 
210
    <para>The conventional design of the asynchronous api seems to produce
210
    <para>The conventional design of the asynchronous api seems to produce
211
    applications with one event loop and several big switch statements.
211
    applications with one event loop and several big switch statements.
212
    However, by intensive utilization of user-space threads, it was possible
212
    However, by intensive utilization of user-space threads, it was possible
213
    to create an environment that is not necesarilly restricted to this type
213
    to create an environment that is not necesarilly restricted to this type
214
    of event-driven programming and allows for more fluent expression of
214
    of event-driven programming and allows for more fluent expression of
215
    application programs.</para>
215
    application programs.</para>
216
 
216
 
217
    <section>
217
    <section>
218
      <title>Single point of entry</title>
218
      <title>Single Point of Entry</title>
219
 
219
 
220
      <para>Each tasks is associated with only one answerbox. If a
220
      <para>Each tasks is associated with only one answerbox. If a
221
      multi-threaded application needs to communicate, it must be not only
221
      multi-threaded application needs to communicate, it must be not only
222
      able to send a message, but it should be able to retrieve the answer as
222
      able to send a message, but it should be able to retrieve the answer as
223
      well. If several threads pull messages from task answerbox, it is a
223
      well. If several threads pull messages from task answerbox, it is a
Line 284... Line 284...
284
          </imageobject>
284
          </imageobject>
285
        </mediaobject>
285
        </mediaobject>
286
 
286
 
287
        <title>Single point of entry solution</title>
287
        <title>Single point of entry solution</title>
288
      </figure>
288
      </figure>
289
 
-
 
290
    </section>
289
    </section>
291
 
290
 
292
    <section>
291
    <section>
293
      <title>Ordering problem</title>
292
      <title>Ordering Problem</title>
294
 
293
 
295
      <para>Unfortunately, the real world is is never so simple. E.g. if a
294
      <para>Unfortunately, the real world is is never so simple. E.g. if a
296
      server handles incoming requests and as a part of its response sends
295
      server handles incoming requests and as a part of its response sends
297
      asynchronous messages, it can be easily prempted and other thread may
296
      asynchronous messages, it can be easily prempted and other thread may
298
      start intervening. This can happen even if the application utilizes only
297
      start intervening. This can happen even if the application utilizes only
Line 308... Line 307...
308
      where additional locking mechanism (futexes) should be used. The IPC
307
      where additional locking mechanism (futexes) should be used. The IPC
309
      framework ensures that there will always be enough free kernel threads
308
      framework ensures that there will always be enough free kernel threads
310
      to handle incoming answers and allow the application to run more
309
      to handle incoming answers and allow the application to run more
311
      user-space threads inside the kernel threads without the danger of
310
      user-space threads inside the kernel threads without the danger of
312
      locking all kernel threads in futexes.</para>
311
      locking all kernel threads in futexes.</para>
313
 
-
 
314
 
-
 
315
    </section>
312
    </section>
316
 
313
 
317
    <section>
314
    <section>
318
      <title>The interface</title>
315
      <title>The Interface</title>
319
 
316
 
320
      <para>The interface was developed to be as simple to use as possible.
317
      <para>The interface was developed to be as simple to use as possible.
321
      Classical applications simply send messages and occasionally wait for an
318
      Classical applications simply send messages and occasionally wait for an
322
      answer and check results. If the number of sent messages is higher than
319
      answer and check results. If the number of sent messages is higher than
323
      kernel limit, the flow of application is stopped until some answers
320
      kernel limit, the flow of application is stopped until some answers