interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / arboris / compute-lock.om

47 lines · 905 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Child opens an independent description of the same supervisor inode.
3fn al_contender kind ulong to int
4 inherited = fclose int get ar_compute_fd 0
5 put ar_compute_kind 0 0
6 if ar_claim_compute kind
7 ret 1
8 end
9 ret 0
10end
11fn al_contention first ulong second ulong to bool
12 if not ar_claim_compute first
13 ret false
14 end
15 if ar_claim_compute first
16 ret false
17 end
18 pid = fork
19 if eq pid 0
20 exit al_contender second
21 end
22 status = new uchar 4 0
23 ok = false
24 if gt pid 0
25 if eq waitpid int pid status 0 4 0 pid
26 ok = and eq get status 0 0 eq get status 1 0
27 end
28 end
29 ar_drop_compute
30 if not ar_claim_compute second
31 ret false
32 end
33 ar_drop_compute
34 ret ok
35end
36fn main to int
37 if ar_claim_compute 0
38 ret 3
39 end
40 if not al_contention 1 2
41 ret 1
42 end
43 if not al_contention 2 1
44 ret 2
45 end
46 ret 0
47end