User guide

3.3. GLOBAL FUNCTIONS 77
res := sys(Sys
usleep, usecs) CIN:y, PO S: y, NAT:y
Under ci ntsys, thi s call causes the system to sleep for usecs micro-seconds. Under
cintpos, it causes the current task to sleep for usecs micro-seconds.
sys(Sys
waitirq, msecs) CIN:n, POS:y, NAT:n
This call is typically only made from the body of the Cintpos Idle task. It suspends
the interpreter until either some Cintpos device issues an interrupt request or the
specified timeou t occurs. It is typicall y implemented by waiting with a timeout on a
host operating system condition variable. When a device thread wishes to interrupt
the interpreter it se nd a signal via the appropriate condition variable. Unfortunatel y
some operating systems m ay take hundreds of milliseconds to reschedule the interpreter
thread. A possible but sel fish solution is for the Idle task to execute a busy loop instead
of calling waitirq.
sys(Sys
watch, addr) CIN:y, POS:y, NAT:n
This sets the address of a location of Cintcode memory to be inspected every time
the interpreter executes and instruction. When the watched value changes it returns
with result 12. The watch feature is disabled if addr is zero or if fasterp is being used.
n := sys(Sys
write, fp, buf, len) CIN:y, POS:y, NAT:y
This writ es len bytes to the file specifie d by the file pointer fp from the byte buffer
buf. The file pointer must have be en created by a call of sys(Sys
openwrite,...).
The result is the number of bytes transferred, or zero if the r e was an error.
pkt := taskwait() CIN:n, POS:y, NAT:n
If there is a packet in the task’s queue i t is dequeued and returned as the result.
If there was no packet on the work queue this task is suspended in WAIT state and
control given to a lower priority task.
res := testbit(bitno, bitvec) CIN:y, POS:y, NAT:y
This function returns a non zero value if and only if the specified bit in bi tv ec
is a one. The bits are numbered from ze r o starting at the least significant bit of
bitvec!0. bitvec!0 hol ds bits 0 to bitsperword-1, bitvec!1 holds bits bitsperword
to 2*bitsperword-1, et c .
res := testflags(flags) CIN:n, POS:y, NAT:n
This Cintpos func ti on tests and cle ar s s pecified flags in the task control block of the
current task. Flags ar e bits in the tcb
flags field of the task control blo ck, and they
are normally called A, B, etc corresponding to consecutive bits from the least significant
end of the field. A flag is set if the corresp ondi ng bit is a one. The argument flags is a
bit pattern i de ntifying which flags are being inspected. The result is FALSE if none of
the specified flags wer e set , and TRUE if at least one was, in which case result2 is set
to a bit pattern representing the flags that were set and have now been cleared.
unloadseg(segl) CIN:y, POS:y, NAT:y
This routine unloads the list of loaded program modules given by segl.
res := unrdch() CIN:y, POS:y, NAT:y
This attempts to step the current input st r e am back by one character position. It