User guide

50 CHAPTER 3. THE LIBRARY
P2 L2 fn sz c P1 L1 0 c
K9G 24 cowait(c)
LP3
J -7 } REPEAT
K6 fn( ... )
LP5 {PC
P
The new coroutine
coroutine chain
fn sz c
stack frame
createco
stack frame
changeco
colist
currco
SP5 c := ...
Figure 3.3: The state just after changeco(0,c) in createco
devid := createdev(dcb) CIN:n, POS:y, NAT:n
This Cintpos fun ct i on creates a device using the first available slot in devtab. The
device control block dcb must have already been initialised and li nked to its devi c e
driver. If su cc e ssf ul it returns a negative value identifying the device. On fail ur e it
returns zero with result2 set to 104 if the devtab is full, or to 106 if devi ce initialisation
failed.
res := createtask(seglist, stsize, pri) CIN:n, POS:y, NAT:n
This Cintpos function creates a task using the first free slot in the task table. It
allocates space for the new task control block (TCB) and a copy of the specified segment
list, and initialises them both. It inserts the new TCB in priority chain of tasks and
returns the id of the newly created task if successful. It is left in DEAD state with no
stack or global vector and no packets on its work queue. If there is an error, it returns
zero with result2 set to 102 if there is already a task with priority pri, or to 103 if
there is insufficient memor y or to 105 if the task table is full. A segment list is a s mal l
vector whose zeroth element holds it upperbound and whose other element hole lists
of sections of code typically loaded by loadseg.
datstamp(datv) CIN:y, POS:y, NAT:y
This sets datv!0 to the number of days since 1 January 1970, and datv!1 to the
number of milli-seconds since midnight, and for compatability with the older version
of datstamp datv!2=-1 indicating the new date and time format is being used.
dat
to string(datv, v) CIN:y, POS:y, NAT:y