Bebaviour of mail


The following is the trace of sending/receiving messages between two processes: s, r.

notation

sM send mbox
sA send await
rM receive mbox
rA receive await
sB sender block
rB receiver block
p producer
c consumer

The trace is:
p: sM sB *
c: rM rA rB *
p: sA sM sB *
c: rM rA rB * ...

With the benchmark, sending and receiving 1000 messages in total 171037 instructions, with nut25 all optimisations turned on (macro, prim, lxvd, sxvd). As NOS itself, not counting the send/receive, consumes around 5% of instructions, therefore the number of instruction for passing (send and receive) one message is 171037/1000 = 170 inst./mess.

The benchmark program

(let p1 p2)

;; send 2..n to p2 ended with -1
(def produce (n) (i)
  (do
  (set i 2)
  (while (< i n)
    (do
    (send p2 i)
    (set i (+ i 1))))
  (send p2 -1)))

;; receive 2..n from p1 ended with -1
(def consume () (m flag)
  (do
  (set flag 1)
  (while flag
    (do
    (set m (receive p1))
    (if (< m 0)
      (set flag 0))))
  (nl)))

(def main () (p)
  (do
  (di)
  (set activep 0)
  (set sseg 1000)
  (set pid 1)
  (set p1 (run (produce 1000)))
  (set p2 (run (consume)))
  (bootnos)))

20 Feb 2005