User guide

10 CHAPTER 1. THE SYSTEM OVERVIEW
}
task, count := 7, 1_000_000
IF argv!0 DO task := !argv!0
IF argv!1 DO count := !argv!1
pkt!0, pkt!1, pkt!2 := notinuse, task, count
writef("*nSending a packet to task %n, %n times*n", task, count)
{ LET k = pkt!2
UNLESS k BREAK
pkt!2 := k-1
qpkt(pkt)
pkt := taskwait()
} REPEAT
writes("Done*n")
}
0.010 1>
This program creates a packet consistin g of a vector (one dimensional array) of
three elements. The first is used by the system for chaining packets together
and must be initialised the the special value notinuse. The ne xt element of the
packet (pkt!1) holds the destination task number and the final element (pkt!2)
holds a value (initially 1000000) which is going t o be used as a counter. The
REPEAT loop decr em ents this counter field and sends the packet using qpkt to
the bounce task suspending itself in taskwait until the packet returns. Control
leaves the REPEAT loop when t h e counter rea ches zero, causing send to output
the message Done. We can compile and run send as follows.
0.010 1> c bc send
bcpl com/send.b to cin/send hdrs POSHDRS
BCPL (20 Oct 2009)
Code size = 252 bytes
0.020 1> send
Sending a packet to task 7, 1000000 times
Done
3.940 1>
This demonstration shows that a packet may be sent from one task to another
2 mill i on times in 3.94 seconds. This corresponds to a rate of just over half a
million ti m es per second.