-
Notifications
You must be signed in to change notification settings - Fork 1
/
selecttime.occ
56 lines (50 loc) · 1.08 KB
/
selecttime.occ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#INCLUDE "course.module"
#INCLUDE "maths.module"
DATA TYPE PACKET
RECORD
INT writer:
INT n:
:
PROC writer(CHAN PACKET out!, VAL INT writer, VAL INT writes)
PACKET p:
SEQ i = 0 FOR writes
SEQ
p[writer] := writer
p[n] := i
out ! p
:
PROC reader(CHAN BYTE out!, [8]CHAN PACKET in?, VAL INT total)
TIMER tim:
INT t0, t1, millisecs:
PACKET p:
SEQ
tim ? t0
SEQ count = 0 FOR total
SEQ
IF
(count \ 65536) = 0
SEQ
tim ? t1
millisecs := t1 - t0
out.int(millisecs, 0, out)
out.string("*n", 0, out)
tim ? t0
TRUE
SKIP
ALT k = 0 FOR 8
in[k] ? p
SKIP
:
PROC experiment(VAL INT iterations, procs, CHAN BYTE out!)
[8]CHAN PACKET chans:
PAR
PAR i = 0 FOR 8
writer(chans[i], i, iterations / procs)
reader(out, chans, iterations)
:
PROC select.time(CHAN BYTE kyb?, screen!, err!)
INT iterations:
SEQ
iterations := INT TRUNC POWER(2.0, 24.0)
experiment(iterations, 8, screen)
: