-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathjob.m
79 lines (69 loc) · 1.48 KB
/
job.m
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# unix job, process
https://en.wikipedia.org/wiki/Process_(computing)
add x:N : N = x > 0ffff_ffff & x | add x+1
multi _ = Asm
mov a Data_vmend
add a 8 1
ret
per i:N =
| Posix.fork 0 & 0
|
i+1 . Core.set_affinity
!Core.affinity . N.log
add 0
!Core.affinity . N.log
Sys.exit 0
0
main2 _ =
x = Posix.fork 0
| x & Fail 'a'
| Fail 'b'
out f:Z?0 : S =
r, w = Pair.map File.of !Sys.pipe
| Posix.fork 0 &
Posix.wait 0
File.in_size r 2048
|
File.dup2 w 1.File.of
f 0
Sys.exit 0
err f:Z?0 : S =
r, w = Pair.map File.of !Sys.pipe
| Posix.fork 0 &
Posix.wait 0
File.in_size r 2048
|
File.dup2 w 2.File.of
f 0
Sys.exit 1
do f:Z?Z : S, S =
r1, w1 = Pair.map File.of !Sys.pipe
r2, w2 = Pair.map File.of !Sys.pipe
| Posix.fork 0 &
Posix.wait 0
x = File.in_size r1 2048
y = File.in_size r2 2048
x, y # fixme - wait for child to exit
|
File.dup2 w1 1.File.of
File.dup2 w2 2.File.of
# must write some to w1/w2, or r1/r2 above block
Out ' '
Err ' '
f 0
Sys.exit 1
test _ : S, S =
r1, w1 = Pair.map File.of !Sys.pipe
r2, w2 = Pair.map File.of !Sys.pipe
| Posix.fork 0 &
x = File.in_size r1 2048
y = File.in_size r2 2048
Put x
Put y
x, y
|
File.dup2 w1 1.File.of
File.dup2 w2 2.File.of
Out 'ok'
Sys.exit 0
all = %0 : %*(Z?_)