Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/node/probe/check.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / node / probe / check.om` 174 lines ยท 2830 bytes Raw Blame History 1 note Native independent wire client. Argument is the disposable server PID. 2 text label "omega-node-n0." 3 text ok "PASS N0 control; maximum snapshot latency in nanoseconds follows\n" 4 text nl "\n" 5 global serverid ulong 1 6 global addr uchar 110 7 global wire uchar 4 8 global reply uchar 12 9 global peer uchar 12 10 global held int 6 11 12 fn write_number v ulong to void 13 d = new uchar 20 0 14 x = v 15 k = ulong 20 16 for i ulong 20 17 k = sub k 1 18 put d k uchar add rem x 10 48 19 x = div x 10 20 if eq x 0 21 break 22 end 23 end 24 r = write 1 d k sub 20 k 25 end 26 27 note Write "/proc//stat" into p; returns its length. 28 fn ck test bool code int to void 29 if not test 30 exit code 31 end 32 end 33 34 fn init_addr to void 35 a = new uchar 12 0 36 n = argread 1 a 0 len a 37 ck and gt n 0 le n 8 2 38 v = ulong 0 39 for i ulong ulong n bound 8 40 b = get a i 41 ck and ge b 48 le b 57 2 42 v = add mul v 10 ulong sub b 48 43 end 44 ck gt v 0 2 45 put serverid 0 v 46 put addr 0 1 47 for i ulong len label 48 put addr add i 3 get label i 49 end 50 for i ulong 4 51 b = uchar and shr v mul i 8 255 52 put addr add add len label 3 i b 53 end 54 end 55 56 fn dial to int 57 for i ulong 40 58 s = socknew 1 524289 0 59 ck ge s 0 3 60 r = connect int s addr 0 add len label 7 61 if eq r 0 62 ck eq peercred int s peer 0 12 0 4 63 id = ulong 0 64 for j ulong 4 65 id = or id shl ulong get peer j mul j 8 66 end 67 ck eq id get serverid 0 4 68 ret int s 69 end 70 r = fclose int s 71 r = sleepns `5000000` 72 end 73 exit 5 74 end 75 76 fn exchange op uchar ver uchar count ulong size uchar to void 77 s = dial 78 put wire 0 size 79 put wire 1 ver 80 put wire 2 op 81 put wire 3 123 82 for i ulong count bound 4 83 ck eq sendmsg s wire i 1 16384 1 6 84 end 85 ck eq shutdown s 1 0 6 86 off = ulong 0 87 for k ulong 12 88 ck gt waitio s 1 `1000000000` 0 7 89 r = recv s reply off sub 12 off 0 90 ck gt r 0 7 91 off = add off ulong r 92 if eq off 12 93 break 94 end 95 end 96 ck eq off 12 7 97 ck eq get reply 0 11 8 98 ck eq get reply 1 1 8 99 if ge count 3 100 ck eq get reply 2 op 8 101 end 102 id = ulong 0 103 for j ulong 4 104 id = or id shl ulong get reply add j 8 mul j 8 105 end 106 ck eq id get serverid 0 8 107 r = fclose s 108 end 109 110 fn cmd op uchar to void 111 exchange op 1 3 2 112 ck eq get reply 3 0 9 113 end 114 115 fn bad op uchar ver uchar count ulong size uchar to void 116 exchange op ver count size 117 ck eq get reply 3 1 10 118 end 119 120 fn latency to long 121 for k ulong 6 122 s = dial 123 put held k s 124 ck eq sendmsg s wire 0 1 16384 1 11 125 end 126 mx = long 0 127 for j ulong 32 128 t = monons 129 cmd 2 130 dt = sub monons t 131 ck lt dt `200000000` 12 132 if gt dt mx 133 mx = dt 134 end 135 ck eq get reply 6 0 12 136 end 137 for k ulong 6 138 r = fclose get held k 139 end 140 ret mx 141 end 142 143 fn main to int 144 init_addr 145 cmd 1 146 bad 5 2 3 2 147 bad 3 1 2 2 148 bad 3 1 4 2 149 bad 3 1 3 255 150 bad 77 1 3 2 151 cmd 2 152 ck eq get reply 4 0 13 153 mx = latency 154 ck eq get reply 7 1 14 155 cmd 3 156 ck eq get reply 4 1 15 157 cmd 4 158 ck eq get reply 4 0 16 159 cmd 6 160 ck eq get reply 6 1 17 161 for i ulong 100 162 cmd 2 163 if eq get reply 6 2 164 break 165 end 166 r = sleepns `2000000` 167 end 168 ck eq get reply 6 2 18 169 cmd 5 170 r = write 1 ok 0 len ok 171 write_number ulong mx 172 r = write 1 nl 0 len nl 173 ret 0 174 end