@@ -400,17 +400,53 @@ <h1 id='The_concept_of_fibration_h'><img src='/share/src/web/images/minus.gif' i
400
400
In our system, there are four principle operations:
401
401
< ol >
402
402
< li > < em > spawn</ em > a new fibre</ li >
403
- < li > < em > read/em> from a channel</ li >
404
- < li > < em > write/em> to a channel</ li >
403
+ < li > < em > read< /em > from a channel</ li >
404
+ < li > < em > write< /em > to a channel</ li >
405
405
< li > Commit < em > suicide</ em >
406
406
</ ol >
407
- A fibre of control can be in one of four states:
407
+ A fibre of control can be in one of five states:
408
408
< ol >
409
409
< li > Running</ em >
410
410
< li > Active (but not running)</ li >
411
- < li > Waiting on I/O</ li >
411
+ < li > Waiting on read</ li >
412
+ < li > Waiting on write</ ii >
412
413
< li > Dead</ li >
413
414
</ ol >
415
+ In our system, all the resources associated by an < em > unreachable</ em > dead
416
+ fibre are automatically reaped by the garbage collector so that in fact
417
+ the fibre is not technically dead because it no longer exists.
418
+ </ p > < p > A < em > channel</ em > is an object associated with which
419
+ set of fibres all waiting to read or all waiting to write.
420
+ </ p > < p > When a write operation is performed on a channel by the running fibre,
421
+ if there are fibres on the channel which are waiting to read
422
+ then one is selected, the data to be written is tranfered from the writer to the reader,
423
+ the fibre is removed from association with the channel,
424
+ and both the running and reader fibre are made active.
425
+ </ p > < p > When a read operation is performed on a channel by the running fibre,
426
+ if there are fibres on the channel which are waiting to write
427
+ then one is selected, the data to be written is transfered from the writer to the reader,
428
+ fibre, the fibre is removed from association with the channel,
429
+ and both the running and reader fibre are made active.
430
+ </ p > < p > When a fibre commits suicide, it is removed as the running fibre.
431
+ </ p > < p > When a new fibre is spawned, both the spawner and spawnee are made active.
432
+ </ p > < p > When there is no running fibre, then if an active fibre exists,
433
+ an active fibre is selected and promoted to running state
434
+ and the thread of control begins executing it.
435
+ </ p > < p > When there is no running fibre, and no active fibres,
436
+ the whole system terminates. Any fibres waiting on I/O become dead
437
+ </ p > < p > The description above is a complete account of the abstract semantics
438
+ known as < em > Communicating Sequential Coroutines</ em > or CSC, it is a
439
+ sub system obtain from Tony Hoare's < em > Communicating Sequenmtial Processes</ em >
440
+ or CSP, in which concurrency is replaced by an indeterminate total ordering.
441
+ </ p > < p > To be precise in CSC all events are totally ordered, however the exact ordering
442
+ is not determinate. This is because a scheduler running the system is free
443
+ to pick any active fibre to run when one is needed.
444
+ </ p > < p > In the Felix implementation, a spawned fibre runs immediately
445
+ if the < code > spawn_fthread</ code > procedure is used to launch it, or the
446
+ running fibre continues instead, of < code > schedule_fthread</ code > is used instead.
447
+ </ p > < p > In addition, I/O transfers always result in the reader proceeding,
448
+ to give it a chance to actually fetch the data before the write
449
+ might modify it.
414
450
</ p > < h2 id ='next_h '> < img src ='/share/src/web/images/minus.gif ' id ='next ' onclick ='toggle(this,"next_d") ' alt ='+ '/> 1.1 next</ h2 > < div id ='next_d ' style ='display:block '>
415
451
< p > stuff
416
452
</ p > < p > < pre class ='flxbg '> < span class ="lineno " id =line1 > </ span > blah
0 commit comments