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
omega-mv / seed / node / replay-test.om
| 1 | note Omega Node durable scheduling-policy replay (DRA-398). Concatenate |
| 2 | note after transport.om, pool.om, super.om, sched.om, |
| 3 | note seed/authority/action.om, journal.om and auth.om. |
| 4 | note A reference creator R runs 10 dispatch events on journal a. A creator |
| 5 | note C runs the same first k events on journal b and dies (77); C2 |
| 6 | note recovers journal b and runs the remaining events. Each event resumes |
| 7 | note dispatch once (auth_pause false, then true), then lets every assigned |
| 8 | note job finish and releases them in slot order, so each event ends at a |
| 9 | note quiescent point. Trace record per event (10 words): 0, 1 the ids |
| 10 | note assigned, 2 cursor, 3 reserved job id, 4 fold of (slot, id, bypass |
| 11 | note count) over ready jobs, 5 policy words (with the ticket lifetime), 6 |
| 12 | note fold of (id, need, estimate, uncertainty, topics) over waiting and |
| 13 | note ready jobs, 7 capacities, 8 sum of the ready jobs' bypass counts, 9 |
| 14 | note state and bypass count of job 7001. C2's state right after recovery |
| 15 | note must equal R's after event k (words 2..9), and the C and C2 trace |
| 16 | note must equal R's. |
| 17 | note Jobs: 14 ready jobs needing 1..3 of 4 CPU, two workers, window 4, |
| 18 | note dispatch budget 2, bypass budget 2, ticket lifetime 777, and job 7001 |
| 19 | note (3 CPU) waiting on topic 8, which the creator publishes before event |
| 20 | note 1 (39 if refused), so it is ready, by publication, across the crash. |
| 21 | note Policy 2 adds three waiting jobs, declared topics, estimates and |
| 22 | note uncertainties (one on a waiting job). |
| 23 | note Exits: 10..22 creator checks; per case base b: b R failed, b+1 C did |
| 24 | note not stop at 77, b+2 C2 failed, b+3 recovered state differs, b+4 traces |
| 25 | note differ, b+5 the case would not test replay (no bypass count, a zero |
| 26 | note cursor or job 7001 not ready at the boundary, or no reservation in |
| 27 | note the run), b+6 C3, which |
| 28 | note recovers journal b again after C2, differs from R's final state (or R's |
| 29 | note final cursor equals its boundary cursor, so the check would not see |
| 30 | note C2's FAIR records missing). Mid-event crash |
| 31 | note (90): C' dies right after a dispatch and its PAUSE, before the creator |
| 32 | note collects or releases the jobs it assigned; C2' must see the cursor, reservation and bypass counts of the |
| 33 | note jobs that were not assigned (93; 95 nothing assigned or bypassed, or |
| 34 | note the event moved neither cursor nor reservation, so losing its FAIR |
| 35 | note would go unseen). Records refused (96 a FAIR that repeats the last |
| 36 | note event, 97 a FAIR naming a free slot, 98 an OPEN of another SPVER, 23 |
| 37 | note an ADMIT into a held slot, 24 a FAIR assigning and bypassing one slot, |
| 38 | note 26 a FAIR assigning a waiting job, 27 a readiness record for a ready |
| 39 | note job (and a valid one at the last event refused), 25 a FAIR reserving |
| 40 | note a cancelled job, 28 a first FAIR that both assigns and readies). |
| 41 | note Failed journal (40..43): revoke, pause, cancel, |
| 42 | note admission, policy and goal change nothing. 44: a full replay ring |
| 43 | note stops dispatch; 47: and refuses publication. 29: recovery refuses a |
| 44 | note fence past the incarnation range. |
| 45 | text rpja "build/node/rpa/journal" |
| 46 | text rpla "build/node/rpa/lock" |
| 47 | text rpjb "build/node/rpb/journal" |
| 48 | text rplb "build/node/rpb/lock" |
| 49 | text rpda "build/node/rpa" |
| 50 | text rpdb "build/node/rpb" |
| 51 | text rpok "PASS node replay\n" |
| 52 | global rpm long 1 |
| 53 | global rpp uchar 128 |
| 54 | |
| 55 | fn rp_ok ok bool code int to void |
| 56 | if not ok |
| 57 | exit code |
| 58 | end |
| 59 | end |
| 60 | |
| 61 | note Path k (0 journal a, 1 lock a, 2 journal b, 3 lock b, 4 dir a, 5 dir |
| 62 | note b) into rpp; its length. |
| 63 | fn rp_path k ulong to ulong |
| 64 | n = ulong 0 |
| 65 | if eq k 0 |
| 66 | n = len rpja |
| 67 | for i ulong n bound 64 |
| 68 | put rpp i get rpja i |
| 69 | end |
| 70 | end |
| 71 | if eq k 1 |
| 72 | n = len rpla |
| 73 | for i ulong n bound 64 |
| 74 | put rpp i get rpla i |
| 75 | end |
| 76 | end |
| 77 | if eq k 2 |
| 78 | n = len rpjb |
| 79 | for i ulong n bound 64 |
| 80 | put rpp i get rpjb i |
| 81 | end |
| 82 | end |
| 83 | if eq k 3 |
| 84 | n = len rplb |
| 85 | for i ulong n bound 64 |
| 86 | put rpp i get rplb i |
| 87 | end |
| 88 | end |
| 89 | if eq k 4 |
| 90 | n = len rpda |
| 91 | for i ulong n bound 64 |
| 92 | put rpp i get rpda i |
| 93 | end |
| 94 | end |
| 95 | if eq k 5 |
| 96 | n = len rpdb |
| 97 | for i ulong n bound 64 |
| 98 | put rpp i get rpdb i |
| 99 | end |
| 100 | end |
| 101 | ret n |
| 102 | end |
| 103 | |
| 104 | fn rp_clean to void |
| 105 | for k ulong 4 |
| 106 | n = rp_path k |
| 107 | r = unlink rpp 0 n |
| 108 | end |
| 109 | end |
| 110 | |
| 111 | fn rp_open d ulong ms ulong to ulong |
| 112 | o = new ulong 4 0 |
| 113 | put o 0 398 |
| 114 | put o 1 7 |
| 115 | put o 2 7 |
| 116 | put o 3 7 |
| 117 | n = rp_path add d 4 |
| 118 | p = new uchar 128 0 |
| 119 | for i ulong n bound 128 |
| 120 | put p i get rpp i |
| 121 | end |
| 122 | ret jn_open p n o ms |
| 123 | end |
| 124 | |
| 125 | note The CPU job i (0..13) needs. |
| 126 | fn rp_cpu i ulong to ulong |
| 127 | ret add 1 rem mul i 7 3 |
| 128 | end |
| 129 | |
| 130 | fn rp_worker c long w ulong to int |
| 131 | out = new uchar 4096 0 |
| 132 | for it ulong 1000000000 |
| 133 | q = sched_wjob w |
| 134 | if gt q 0 |
| 135 | d = sched_wdone w q 2 out 0 |
| 136 | end |
| 137 | r = auth_wwait c w neg int 1 1000000000 |
| 138 | if or eq r 2 eq r 3 |
| 139 | ret 0 |
| 140 | end |
| 141 | if eq r 4 |
| 142 | t = auth_wctl w |
| 143 | end |
| 144 | if lt r 0 |
| 145 | ret 45 |
| 146 | end |
| 147 | end |
| 148 | ret 46 |
| 149 | end |
| 150 | |
| 151 | note Creator on journal d (0 a, 1 b): open it, recover, spawn two workers. |
| 152 | fn rp_setup d ulong to long |
| 153 | c = pool_new 4 2 |
| 154 | rp_ok gt c 0 10 |
| 155 | rp_ok eq sup_init c 0 11 |
| 156 | rp_ok eq sched_new c 32 8 0 12 |
| 157 | rp_ok eq auth_new c 0 13 |
| 158 | rp_ok eq rp_open d 3000 0 14 |
| 159 | rp_ok eq auth_recover c 0 15 |
| 160 | for w ulong 2 |
| 161 | p = auth_spawn c w |
| 162 | if eq p 0 |
| 163 | exit rp_worker c w |
| 164 | end |
| 165 | rp_ok gt p 0 16 |
| 166 | end |
| 167 | ret c |
| 168 | end |
| 169 | |
| 170 | fn rp_slot id ulong to ulong |
| 171 | for j ulong 64 |
| 172 | s = get sjst j |
| 173 | if and eq get sjid j id and ge s 1 le s 2 |
| 174 | ret j |
| 175 | end |
| 176 | end |
| 177 | ret 64 |
| 178 | end |
| 179 | |
| 180 | note A fresh creator: paused, capacities, policy, the jobs and (policy 2) |
| 181 | note the waiting jobs and declarations, all journaled. |
| 182 | fn rp_load c long pol ulong to void |
| 183 | rp_ok ge auth_pause c true 0 17 |
| 184 | rp_ok eq jn_cap 4 0 17 |
| 185 | rp_ok eq jn_policy pol 4 2 2 777 0 17 |
| 186 | for i ulong 14 |
| 187 | rp_ok ge jn_admitr add 5000 i 0 0 rp_cpu i 0 18 |
| 188 | end |
| 189 | rp_ok ge jn_admitr 7001 8 0 3 0 18 |
| 190 | if eq pol 2 |
| 191 | for i ulong 3 |
| 192 | rp_ok ge jn_admitr add 6000 i shl 1 i 0 0 0 18 |
| 193 | end |
| 194 | rp_ok eq jn_goal rp_slot 5003 3 40 5 0 19 |
| 195 | rp_ok eq jn_goal rp_slot 5008 4 60 7 0 19 |
| 196 | rp_ok eq jn_goal rp_slot 5005 0 10 1 0 19 |
| 197 | rp_ok eq jn_goal rp_slot 5011 0 20 3 0 19 |
| 198 | rp_ok eq jn_goal rp_slot 6000 0 30 9 0 19 |
| 199 | end |
| 200 | end |
| 201 | |
| 202 | fn rp_put base ulong e ulong i ulong v ulong to void |
| 203 | r = mapset get rpm 0 mul add add base mul e 10 i 8 8 v |
| 204 | end |
| 205 | |
| 206 | fn rp_get base ulong e ulong i ulong to ulong |
| 207 | ret mapget get rpm 0 mul add add base mul e 10 i 8 8 |
| 208 | end |
| 209 | |
| 210 | note Step until no job runs, then release every finished one, slot order. |
| 211 | fn rp_drive c long to void |
| 212 | dl = add ulong monons 20000000000 |
| 213 | for t ulong 100000000 |
| 214 | r = sched_step c 5000000 |
| 215 | k = auth_step c |
| 216 | busy = false |
| 217 | for j ulong 64 |
| 218 | if eq get sjst j 3 |
| 219 | busy = true |
| 220 | end |
| 221 | end |
| 222 | if not busy |
| 223 | for j ulong 64 |
| 224 | if eq get sjst j 4 |
| 225 | rp_ok ge jn_release j 0 21 |
| 226 | end |
| 227 | end |
| 228 | ret |
| 229 | end |
| 230 | rp_ok lt ulong monons dl 22 |
| 231 | end |
| 232 | end |
| 233 | |
| 234 | note Fold of (slot, id, bypass count) over ready jobs other than ids x, y; |
| 235 | note with sum true the sum of those bypass counts instead. |
| 236 | fn rp_fbyp x ulong y ulong sum bool to ulong |
| 237 | h = ulong 1469598103934665603 |
| 238 | n = ulong 0 |
| 239 | for j ulong 64 |
| 240 | id = get sjid j |
| 241 | if and eq get sjst j 2 and ne id x ne id y |
| 242 | n = add n get sjbyp j |
| 243 | h = mul xor h j 1099511628211 |
| 244 | h = mul xor h id 1099511628211 |
| 245 | h = mul xor h get sjbyp j 1099511628211 |
| 246 | end |
| 247 | end |
| 248 | if sum |
| 249 | ret n |
| 250 | end |
| 251 | ret h |
| 252 | end |
| 253 | |
| 254 | note Fold of (id, need, estimate, uncertainty, topics) over waiting and |
| 255 | note ready jobs. |
| 256 | fn rp_fjob to ulong |
| 257 | h = ulong 1469598103934665603 |
| 258 | for j ulong 64 |
| 259 | s = get sjst j |
| 260 | if and ge s 1 le s 4 |
| 261 | h = mul xor h get sjid j 1099511628211 |
| 262 | h = mul xor h get sjneed j 1099511628211 |
| 263 | h = mul xor h get sjest j 1099511628211 |
| 264 | h = mul xor h get sjunc j 1099511628211 |
| 265 | h = mul xor h get sjpro j 1099511628211 |
| 266 | end |
| 267 | end |
| 268 | ret h |
| 269 | end |
| 270 | |
| 271 | note Job 7001's state and bypass count, 0 when x or y is 7001 or it is not |
| 272 | note in the table. |
| 273 | fn rp_dep x ulong y ulong to ulong |
| 274 | if or eq x 7001 eq y 7001 |
| 275 | ret 0 |
| 276 | end |
| 277 | for j ulong 64 |
| 278 | if and eq get sjid j 7001 ne get sjst j 0 |
| 279 | ret or get sjst j shl get sjbyp j 8 |
| 280 | end |
| 281 | end |
| 282 | ret 0 |
| 283 | end |
| 284 | |
| 285 | fn rp_rid to ulong |
| 286 | r = sched_stat 29 |
| 287 | if eq r 0 |
| 288 | ret 0 |
| 289 | end |
| 290 | ret get sjid sub r 1 |
| 291 | end |
| 292 | |
| 293 | note Words 2..9 of trace record e (base), x and y excluded from 4, 8, 9. |
| 294 | fn rp_state base ulong e ulong x ulong y ulong to void |
| 295 | rp_put base e 2 sched_stat 28 |
| 296 | rp_put base e 3 rp_rid |
| 297 | rp_put base e 4 rp_fbyp x y false |
| 298 | p = or or sched_stat 24 shl sched_stat 25 8 or shl sched_stat 26 16 shl sched_stat 27 24 |
| 299 | rp_put base e 5 or p shl sched_stat 31 32 |
| 300 | rp_put base e 6 rp_fjob |
| 301 | rp_put base e 7 sched_caps |
| 302 | rp_put base e 8 rp_fbyp x y true |
| 303 | rp_put base e 9 rp_dep x y |
| 304 | end |
| 305 | |
| 306 | note Resume dispatch once, pause; record the ids assigned (words 0, 1). |
| 307 | fn rp_dispatch c long e ulong base ulong to void |
| 308 | rp_ok ge auth_pause c false 0 20 |
| 309 | rp_ok ge auth_pause c true 0 20 |
| 310 | a0 = ulong 0 |
| 311 | a1 = ulong 0 |
| 312 | for j ulong 64 |
| 313 | s = get sjst j |
| 314 | if and ge s 3 le s 4 |
| 315 | if eq a0 0 |
| 316 | a0 = get sjid j |
| 317 | else |
| 318 | a1 = get sjid j |
| 319 | end |
| 320 | end |
| 321 | end |
| 322 | rp_put base e 0 a0 |
| 323 | rp_put base e 1 a1 |
| 324 | end |
| 325 | |
| 326 | note Event e; before event 1 the creator publishes topic 8 (job 7001). |
| 327 | fn rp_event c long e ulong base ulong to void |
| 328 | pb = new uchar 4096 0 |
| 329 | if eq e 1 |
| 330 | rp_ok gt sched_publish c 8 pb 16 0 39 |
| 331 | end |
| 332 | rp_dispatch c e base |
| 333 | rp_drive c |
| 334 | rp_state base e 0 0 |
| 335 | end |
| 336 | |
| 337 | fn rp_down c long to void |
| 338 | r = sched_stop c 2000000000 |
| 339 | sup_closeall |
| 340 | jn_close |
| 341 | end |
| 342 | |
| 343 | fn rp_ref pol ulong en ulong to int |
| 344 | c = rp_setup 0 |
| 345 | rp_load c pol |
| 346 | for e ulong en |
| 347 | rp_event c e 0 |
| 348 | end |
| 349 | rp_down c |
| 350 | ret 0 |
| 351 | end |
| 352 | |
| 353 | fn rp_crash pol ulong k ulong to int |
| 354 | c = rp_setup 1 |
| 355 | rp_load c pol |
| 356 | for e ulong k |
| 357 | rp_event c e 1024 |
| 358 | end |
| 359 | ret 77 |
| 360 | end |
| 361 | |
| 362 | fn rp_rec k ulong en ulong to int |
| 363 | c = rp_setup 1 |
| 364 | rp_state 2048 0 0 0 |
| 365 | for e ulong sub en k |
| 366 | rp_event c add k e 1024 |
| 367 | end |
| 368 | rp_down c |
| 369 | ret 0 |
| 370 | end |
| 371 | |
| 372 | note C3: recover journal b again, state at 2048 + 10. |
| 373 | fn rp_again to int |
| 374 | c = rp_setup 1 |
| 375 | rp_state 2048 1 0 0 |
| 376 | rp_down c |
| 377 | ret 0 |
| 378 | end |
| 379 | |
| 380 | note C': k events, then one dispatch and its PAUSE, state at 3072, die. |
| 381 | fn rp_mcrash pol ulong k ulong to int |
| 382 | c = rp_setup 1 |
| 383 | rp_load c pol |
| 384 | for e ulong k |
| 385 | rp_event c e 1024 |
| 386 | end |
| 387 | rp_dispatch c 0 3072 |
| 388 | rp_state 3072 0 rp_get 3072 0 0 rp_get 3072 0 1 |
| 389 | ret 77 |
| 390 | end |
| 391 | |
| 392 | note C2': recover, state at 3072 + 10 without the jobs C' assigned. |
| 393 | fn rp_mrec to int |
| 394 | c = rp_setup 1 |
| 395 | rp_state 3072 1 rp_get 3072 0 0 rp_get 3072 0 1 |
| 396 | rp_down c |
| 397 | ret 0 |
| 398 | end |
| 399 | |
| 400 | fn rp_reap p long to ulong |
| 401 | ws = new uchar 4 0 |
| 402 | g = waitpid int p ws 0 4 0 |
| 403 | if le g 0 |
| 404 | ret 999 |
| 405 | end |
| 406 | if ne and get ws 0 127 0 |
| 407 | ret add 128 ulong and get ws 0 127 |
| 408 | end |
| 409 | ret ulong get ws 1 |
| 410 | end |
| 411 | |
| 412 | note A child that should exit want: anything else ends the test with the |
| 413 | note child's own check code (10..48, 90..99), or code. |
| 414 | fn rp_child x ulong want ulong code int to void |
| 415 | if ne x want |
| 416 | if or and ge x 10 le x 48 and ge x 90 le x 99 |
| 417 | exit int x |
| 418 | end |
| 419 | exit code |
| 420 | end |
| 421 | end |
| 422 | |
| 423 | fn rp_zero to void |
| 424 | for i ulong 4096 |
| 425 | r = mapset get rpm 0 mul i 8 8 0 |
| 426 | end |
| 427 | end |
| 428 | |
| 429 | fn rp_case pol ulong k ulong b int to void |
| 430 | en = ulong 10 |
| 431 | rp_zero |
| 432 | rp_clean |
| 433 | p = fork |
| 434 | if eq p 0 |
| 435 | exit rp_ref pol en |
| 436 | end |
| 437 | rp_child rp_reap p 0 b |
| 438 | p = fork |
| 439 | if eq p 0 |
| 440 | exit rp_crash pol k |
| 441 | end |
| 442 | rp_child rp_reap p 77 add b 1 |
| 443 | p = fork |
| 444 | if eq p 0 |
| 445 | exit rp_rec k en |
| 446 | end |
| 447 | rp_child rp_reap p 0 add b 2 |
| 448 | p = fork |
| 449 | if eq p 0 |
| 450 | exit rp_again |
| 451 | end |
| 452 | rp_child rp_reap p 0 add b 6 |
| 453 | rp_cmp k en b |
| 454 | end |
| 455 | |
| 456 | fn rp_cmp k ulong en ulong b int to void |
| 457 | for i ulong 8 |
| 458 | rp_ok eq rp_get 2048 0 add i 2 rp_get 0 sub k 1 add i 2 add b 3 |
| 459 | end |
| 460 | seen = false |
| 461 | for e ulong en |
| 462 | for i ulong 10 |
| 463 | rp_ok eq rp_get 0 e i rp_get 1024 e i add b 4 |
| 464 | end |
| 465 | if gt rp_get 0 e 3 0 |
| 466 | seen = true |
| 467 | end |
| 468 | end |
| 469 | rp_ok seen add b 5 |
| 470 | rp_ok gt rp_get 0 sub k 1 8 0 add b 5 |
| 471 | rp_ok ne rp_get 0 sub k 1 2 0 add b 5 |
| 472 | rp_ok eq and rp_get 0 sub k 1 9 255 2 add b 5 |
| 473 | for i ulong 8 |
| 474 | rp_ok eq rp_get 2048 1 add i 2 rp_get 0 sub en 1 add i 2 add b 6 |
| 475 | end |
| 476 | rp_ok ne rp_get 0 sub en 1 2 rp_get 0 sub k 1 2 add b 6 |
| 477 | end |
| 478 | |
| 479 | fn rp_mid pol ulong k ulong to void |
| 480 | rp_zero |
| 481 | rp_clean |
| 482 | p = fork |
| 483 | if eq p 0 |
| 484 | exit rp_mcrash pol k |
| 485 | end |
| 486 | rp_child rp_reap p 77 91 |
| 487 | p = fork |
| 488 | if eq p 0 |
| 489 | exit rp_mrec |
| 490 | end |
| 491 | rp_child rp_reap p 0 92 |
| 492 | for i ulong 8 |
| 493 | rp_ok eq rp_get 3072 1 add i 2 rp_get 3072 0 add i 2 93 |
| 494 | end |
| 495 | rp_ok gt rp_get 3072 0 0 0 95 |
| 496 | rp_ok gt rp_get 3072 0 8 0 95 |
| 497 | w2 = rp_get 1024 sub k 1 2 |
| 498 | w3 = rp_get 1024 sub k 1 3 |
| 499 | rp_ok or ne rp_get 3072 0 2 w2 ne rp_get 3072 0 3 w3 95 |
| 500 | end |
| 501 | |
| 502 | note Journal b as left by the mid-event case: a FAIR repeating the last |
| 503 | note event is refused (96), and one assigning a free slot (97). |
| 504 | fn rp_dup to int |
| 505 | rp_ok eq rp_open 1 3000 0 96 |
| 506 | r = new ulong 16 0 |
| 507 | put r 0 13 |
| 508 | put r 3 get jfair 0 |
| 509 | put r 6 get jfair 1 |
| 510 | rp_ok eq jn_put r 25 96 |
| 511 | for i ulong 16 |
| 512 | put r i 0 |
| 513 | end |
| 514 | s = ulong 64 |
| 515 | for j ulong 64 |
| 516 | if eq get jsl j 0 |
| 517 | s = j |
| 518 | end |
| 519 | end |
| 520 | rp_ok lt s 64 97 |
| 521 | put r 0 13 |
| 522 | put r 3 add get jfair 0 1 |
| 523 | put r 4 shl 1 s |
| 524 | rp_ok eq jn_put r 25 97 |
| 525 | for i ulong 16 |
| 526 | put r i 0 |
| 527 | end |
| 528 | put r 0 1 |
| 529 | put r 3 1 |
| 530 | put r 5 add SPVER 1 |
| 531 | rp_ok eq jn_put r 33 98 |
| 532 | rp_dupv |
| 533 | jn_close |
| 534 | ret 0 |
| 535 | end |
| 536 | |
| 537 | note A live ready job's slot (no deps, not cancelled), or 64. |
| 538 | fn rp_rslot to ulong |
| 539 | for s ulong 64 |
| 540 | x = get jsl s |
| 541 | if ne x 0 |
| 542 | b = mul sub x 1 8 |
| 543 | if and eq get jjob add b 2 0 eq get jjob add b 6 0 |
| 544 | ret s |
| 545 | end |
| 546 | end |
| 547 | end |
| 548 | ret 64 |
| 549 | end |
| 550 | |
| 551 | fn rp_fair r edit ulong 16 ev ulong am ulong bm ulong rs ulong rd ulong to void |
| 552 | for i ulong 16 |
| 553 | put r i 0 |
| 554 | end |
| 555 | put r 0 13 |
| 556 | put r 3 ev |
| 557 | put r 4 am |
| 558 | put r 5 bm |
| 559 | put r 6 get jfair 1 |
| 560 | put r 7 rs |
| 561 | put r 8 rd |
| 562 | end |
| 563 | |
| 564 | note Contradictory records are refused (23..27); valid ones still pass. |
| 565 | fn rp_dupv to void |
| 566 | r = new ulong 16 0 |
| 567 | s = rp_rslot |
| 568 | rp_ok lt s 64 23 |
| 569 | f = ulong 64 |
| 570 | for j ulong 64 |
| 571 | if eq get jsl j 0 |
| 572 | f = j |
| 573 | end |
| 574 | end |
| 575 | rp_ok lt f 64 23 |
| 576 | put r 0 2 |
| 577 | put r 3 9100 |
| 578 | put r 7 s |
| 579 | rp_ok eq jn_put r 25 23 |
| 580 | e = add get jfair 0 1 |
| 581 | rp_fair r e shl 1 s shl 1 s 0 0 |
| 582 | rp_ok eq jn_put r 25 24 |
| 583 | for i ulong 16 |
| 584 | put r i 0 |
| 585 | end |
| 586 | put r 0 2 |
| 587 | put r 3 9101 |
| 588 | put r 4 16 |
| 589 | put r 7 f |
| 590 | rp_ok eq jn_put r 0 26 |
| 591 | rp_fair r e shl 1 f 0 0 0 |
| 592 | rp_ok eq jn_put r 25 26 |
| 593 | rp_fair r get jfair 0 0 0 0 shl 1 s |
| 594 | rp_ok eq jn_put r 25 27 |
| 595 | put jfair 3 0 |
| 596 | rp_fair r e shl 1 s 0 0 shl 1 f |
| 597 | rp_ok eq jn_put r 25 28 |
| 598 | rp_ok eq get jfair 3 0 28 |
| 599 | rp_ok eq get jrdy sub get jsl f 1 0 28 |
| 600 | put jfair 3 1 |
| 601 | rp_fair r get jfair 0 0 0 0 shl 1 f |
| 602 | rp_ok eq jn_put r 0 27 |
| 603 | for i ulong 16 |
| 604 | put r i 0 |
| 605 | end |
| 606 | put r 0 8 |
| 607 | put r 3 get jjob add mul sub get jsl s 1 8 1 |
| 608 | rp_ok eq jn_put r 0 25 |
| 609 | rp_fair r add get jfair 0 1 0 0 add s 1 0 |
| 610 | rp_ok eq jn_put r 25 25 |
| 611 | end |
| 612 | |
| 613 | note A full replay ring (64 records not yet durable) refuses dispatch (44) |
| 614 | note and publication (47: job 7001 stays waiting). |
| 615 | fn rp_ring to int |
| 616 | c = rp_setup 0 |
| 617 | rp_load c 1 |
| 618 | put sfj 1 64 |
| 619 | put scpause 0 0 |
| 620 | x = sched_dispatch c |
| 621 | rp_ok eq x 0 44 |
| 622 | rp_ok eq sched_stat 15 1 44 |
| 623 | rp_ok eq sched_stat 4 0 44 |
| 624 | pb = new uchar 4096 0 |
| 625 | rp_ok eq sched_publish c 8 pb 16 neg long 105 47 |
| 626 | rp_ok eq sched_stat 15 2 47 |
| 627 | rp_ok eq get sjst rp_slot 7001 1 47 |
| 628 | put sfj 1 0 |
| 629 | put scpause 0 1 |
| 630 | rp_down c |
| 631 | ret 0 |
| 632 | end |
| 633 | |
| 634 | note A failed journal: nothing it refuses changes the creator (40..43). |
| 635 | fn rp_fail to int |
| 636 | c = rp_setup 0 |
| 637 | rp_load c 2 |
| 638 | j = rp_slot 5000 |
| 639 | g = get augen 0 |
| 640 | put jbad 0 1 |
| 641 | rp_ok eq auth_revoke c 0 40 |
| 642 | rp_ok eq get augen 0 g 40 |
| 643 | rp_ok eq auth_pause c false neg long 5 41 |
| 644 | rp_ok eq get scpause 0 1 41 |
| 645 | rp_ok eq auth_cancel c j neg long 5 42 |
| 646 | rp_ok eq get sjst j 2 42 |
| 647 | rp_ok eq jn_admitr 7000 0 0 1 neg long 5 43 |
| 648 | rp_ok eq jn_policy 1 8 2 2 1000 neg long 5 43 |
| 649 | rp_ok eq sched_stat 25 4 43 |
| 650 | rp_ok eq jn_goal j 1 99 1 neg long 5 43 |
| 651 | rp_ok eq get sjest j 0 43 |
| 652 | rp_ok eq jn_cap 8 neg long 5 43 |
| 653 | rp_ok eq sched_caps 4 43 |
| 654 | rp_down c |
| 655 | ret 0 |
| 656 | end |
| 657 | |
| 658 | note Recovery fails closed past the incarnation range (29): fence 2^24 + 1, |
| 659 | note which a 24-bit mask would fold onto incarnation 1, is refused and |
| 660 | note leaves the scheduler unincarnated, so 2^24 - 1 is then accepted. |
| 661 | fn rp_fence to int |
| 662 | c = pool_new 4 2 |
| 663 | rp_ok gt c 0 29 |
| 664 | rp_ok eq sched_new c 32 8 0 29 |
| 665 | put jpol 0 0 |
| 666 | put jfence 0 16777217 |
| 667 | rp_ok not jn_rpol 29 |
| 668 | put jfence 0 16777215 |
| 669 | rp_ok jn_rpol 29 |
| 670 | ret 0 |
| 671 | end |
| 672 | |
| 673 | fn main to int |
| 674 | m = mapnew neg int 1 0 32768 3 33 |
| 675 | rp_ok gt m 0 9 |
| 676 | put rpm 0 m |
| 677 | rp_case 1 3 50 |
| 678 | rp_case 1 6 60 |
| 679 | rp_case 2 3 70 |
| 680 | rp_case 2 6 80 |
| 681 | rp_mid 1 3 |
| 682 | p = fork |
| 683 | if eq p 0 |
| 684 | exit rp_dup |
| 685 | end |
| 686 | rp_child rp_reap p 0 96 |
| 687 | rp_clean |
| 688 | p = fork |
| 689 | if eq p 0 |
| 690 | exit rp_fail |
| 691 | end |
| 692 | rp_child rp_reap p 0 40 |
| 693 | rp_clean |
| 694 | p = fork |
| 695 | if eq p 0 |
| 696 | exit rp_ring |
| 697 | end |
| 698 | rp_child rp_reap p 0 44 |
| 699 | rp_clean |
| 700 | p = fork |
| 701 | if eq p 0 |
| 702 | exit rp_fence |
| 703 | end |
| 704 | rp_child rp_reap p 0 29 |
| 705 | if ne write 1 rpok 0 len rpok long len rpok |
| 706 | ret 100 |
| 707 | end |
| 708 | ret 0 |
| 709 | end |