From 51370addc91cae57e32de58ae71b63ef0bfd33d2 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 21 Nov 2014 23:43:27 -0800 Subject: 291 - figured out the channel-handoff problem 'read' and 'write' pass in the channel by value, so they block on different *local* variables. Does this kill my plan to pervasively use call-by-value everywhere? No, we might be able to salvage it if channels are the only shared pointers. --- mu.arc | 11 ++++++++--- mu.arc.t | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mu.arc b/mu.arc index 754171b5..79ee4210 100644 --- a/mu.arc +++ b/mu.arc @@ -184,8 +184,9 @@ (> curr-cycle* rep.routine!sleep.0) (ret result nil (= routine* routine) -;? (tr "checking location " rep.routine*!sleep) +;? (tr "checking location " rep.routine*!sleep " -> " (addr rep.routine*!sleep)) (= result (~in (m rep.routine!sleep) 0 nil)) +;? (tr (if result "yep" "nope")) (= routine* nil)))) (on-init @@ -229,6 +230,7 @@ ; wake up any necessary sleeping routines (either by time or on a location) ; detect deadlock: kill all sleeping routines when none can be woken (def update-scheduler-state () +;? (trace "schedule" curr-cycle*) (when routine* (if rep.routine*!sleep @@ -257,7 +259,8 @@ (detect-deadlock)) (def detect-deadlock () - (when (and empty.running-routines* + (when (and (empty running-routines*) + (~empty sleeping-routines*) (~some 'literal (map (fn(_) rep._!sleep.1) keys.sleeping-routines*))) (each (routine _) sleeping-routines* @@ -555,7 +558,9 @@ (let delay v.operand (trace "run" "sleeping until " (+ curr-cycle* delay)) (= rep.routine*!sleep `(,(+ curr-cycle* delay) literal))) - (= rep.routine*!sleep operand)) + (do +;? (tr "blocking on " operand " -> " (addr operand)) + (= rep.routine*!sleep operand))) ((abort-routine*))) ; text interaction diff --git a/mu.arc.t b/mu.arc.t index 29bfee42..3740a1b7 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -2316,7 +2316,9 @@ ((ochan channel-address) <- arg) ((x tagged-value-address) <- new-tagged-value (integer-address literal) (n integer-address)) ((ochan channel-address deref) <- write (ochan channel-address deref) (x tagged-value-address deref))))) -;? (= dump-trace* (obj whitelist '("run"))) +(set dump-trace*) +;? (= dump-trace* (obj whitelist '("schedule" "run" "addr"))) +;? (= dump-trace* (obj whitelist '("-"))) (run 'f1) ;? (prn memory*) (each routine completed-routines* -- cgit 1.4.1-2-gfad0