diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-08-27 18:23:53 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-08-27 18:23:53 -0700 |
commit | e947da75bd926da6d533fd73b352c16c8417b3f6 (patch) | |
tree | f31b798b4849da26bf6c5eec921d5e8a7178f17f | |
parent | 50bff0c5fb8dc13987fcb4e9bf16432da1544740 (diff) | |
download | mu-e947da75bd926da6d533fd73b352c16c8417b3f6.tar.gz |
3265
Ah, the reason commit 3258 broke chessboard.mu was that I forgot to migrate the implementation of 'switch' to 'wait-for-routine-to-block'. That caused these cascading effects when running chessboard.mu: a) 'read-event' from real keyboard calls 'switch' b) 'switch' waits for some other currently running routine to *complete* rather than just block c) deadlock unsurprisingly ensues This was hard to debug because I kept searching for occurrences of 'wait-for-routine' that I'd missed, and didn't realize that 'switch' too was a form of 'wait-for-routine'. No more; now it's a form of 'wait-for-routine-to-block', possibly the *only* reason to ever call that instruction outside of tests.
-rw-r--r-- | 073wait.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/073wait.cc b/073wait.cc index e42df163..46086589 100644 --- a/073wait.cc +++ b/073wait.cc @@ -399,6 +399,8 @@ for (int i = 0; i < SIZE(Routines); ++i) { } } +//: yield voluntarily to let some other routine run + :(before "End Primitive Recipe Declarations") SWITCH, :(before "End Primitive Recipe Numbers") @@ -407,17 +409,18 @@ put(Recipe_ordinal, "switch", SWITCH); case SWITCH: { break; } +//: pick another RUNNING routine at random and wait for it to get a chance +//: there might be a better implementation than this :(before "End Primitive Recipe Implementations") case SWITCH: { int id = some_other_running_routine(); if (id) { assert(id != Current_routine->id); Current_routine->state = WAITING; - Current_routine->waiting_on_routine = id; + Current_routine->waiting_on_routine_to_block = id; } break; } - :(code) int some_other_running_routine() { for (int i = 0; i < SIZE(Routines); ++i) { |