Skip to content

Commit bcda866

Browse files
committed
experiment
1 parent c6a1f12 commit bcda866

File tree

2 files changed

+93
-8
lines changed

2 files changed

+93
-8
lines changed

corout.fdoc

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,66 @@ with these properties:
99
In our system, there are four principle operations:
1010
<ol>
1111
<li><em>spawn</em> a new fibre</li>
12-
<li><em>read/em> from a channel</li>
13-
<li><em>write/em> to a channel</li>
12+
<li><em>read</em> from a channel</li>
13+
<li><em>write</em> to a channel</li>
1414
<li>Commit <em>suicide</em>
1515
</ol>
16-
A fibre of control can be in one of four states:
16+
A fibre of control can be in one of five states:
1717
<ol>
1818
<li>Running</em>
1919
<li>Active (but not running)</li>
20-
<li>Waiting on I/O</li>
20+
<li>Waiting on read</li>
21+
<li>Waiting on write</ii>
2122
<li>Dead</li>
2223
</ol>
24+
In our system, all the resources associated by an <em>unreachable</em> dead
25+
fibre are automatically reaped by the garbage collector so that in fact
26+
the fibre is not technically dead because it no longer exists.
27+
28+
A <em>channel</em> is an object associated with which
29+
set of fibres all waiting to read or all waiting to write.
30+
31+
When a write operation is performed on a channel by the running fibre,
32+
if there are fibres on the channel which are waiting to read
33+
then one is selected, the data to be written is tranfered from the writer to the reader,
34+
the fibre is removed from association with the channel,
35+
and both the running and reader fibre are made active.
36+
37+
When a read operation is performed on a channel by the running fibre,
38+
if there are fibres on the channel which are waiting to write
39+
then one is selected, the data to be written is transfered from the writer to the reader,
40+
fibre, the fibre is removed from association with the channel,
41+
and both the running and reader fibre are made active.
42+
43+
When a fibre commits suicide, it is removed as the running fibre.
44+
45+
When a new fibre is spawned, both the spawner and spawnee are made active.
46+
47+
When there is no running fibre, then if an active fibre exists,
48+
an active fibre is selected and promoted to running state
49+
and the thread of control begins executing it.
50+
51+
When there is no running fibre, and no active fibres,
52+
the whole system terminates. Any fibres waiting on I/O become dead
53+
54+
The description above is a complete account of the abstract semantics
55+
known as <em>Communicating Sequential Coroutines</em> or CSC, it is a
56+
sub system obtain from Tony Hoare's <em>Communicating Sequenmtial Processes</em>
57+
or CSP, in which concurrency is replaced by an indeterminate total ordering.
58+
59+
To be precise in CSC all events are totally ordered, however the exact ordering
60+
is not determinate. This is because a scheduler running the system is free
61+
to pick any active fibre to run when one is needed.
62+
63+
In the Felix implementation, a spawned fibre runs immediately
64+
if the @{spawn_fthread} procedure is used to launch it, or the
65+
running fibre continues instead, of @{schedule_fthread} is used instead.
66+
67+
In addition, I/O transfers always result in the reader proceeding,
68+
to give it a chance to actually fetch the data before the write
69+
might modify it.
70+
71+
2372
@h2 next
2473
stuff
2574
@felix

tmp.html

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,53 @@ <h1 id='The_concept_of_fibration_h'><img src='/share/src/web/images/minus.gif' i
400400
In our system, there are four principle operations:
401401
<ol>
402402
<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>
405405
<li>Commit <em>suicide</em>
406406
</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:
408408
<ol>
409409
<li>Running</em>
410410
<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>
412413
<li>Dead</li>
413414
</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.
414450
</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'>
415451
<p>stuff
416452
</p><p><pre class='flxbg'><span class="lineno" id=line1></span> blah

0 commit comments

Comments
 (0)