about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-21 20:37:24 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-21 20:37:32 -0800
commit672cda7e1ce754dda4801a7411221f5ed80517fb (patch)
treed0e8cccd6366c86ff928345f0beae301003ab0e7 /mu.arc.t
parent3a65d3be749ccd35a38674df49e7e9e59be88903 (diff)
downloadmu-672cda7e1ce754dda4801a7411221f5ed80517fb.tar.gz
288 - support sleeping while watching a memory location
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t52
1 files changed, 50 insertions, 2 deletions
diff --git a/mu.arc.t b/mu.arc.t
index f2fea892..da0ffa0f 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -1764,6 +1764,54 @@
   (prn "F - scheduler wakes up sleeping routines at the right time"))
 
 (reset)
+(new-trace "scheduler-sleep-location")
+(add-fns
+  '((f1
+      ((1 integer) <- copy (3 literal)))
+    (f2
+      ((2 integer) <- copy (4 literal)))))
+; add one baseline routine to run (empty running-routines* handled below)
+(enq make-routine!f1 running-routines*)
+(assert (is 1 len.running-routines*))
+; sleeping routine
+(let routine make-routine!f2
+  (= rep.routine!sleep '(23 integer))
+  (set sleeping-routines*.routine))
+; 'empty' memory location
+(= memory*.23 0)
+;? (prn memory*)
+;? (prn running-routines*)
+;? (prn sleeping-routines*)
+;? (set dump-trace*)
+;? (= dump-trace* (obj whitelist '("run" "schedule")))
+(update-scheduler-state)
+;? (prn running-routines*)
+;? (prn sleeping-routines*)
+(if (~is 1 len.running-routines*)
+  (prn "F - scheduler lets routines block on locations"))
+;? (quit)
+
+(reset)
+(new-trace "scheduler-wakeup-location")
+(add-fns
+  '((f1
+      ((1 integer) <- copy (3 literal)))
+    (f2
+      ((2 integer) <- copy (4 literal)))))
+; add one baseline routine to run (empty running-routines* handled below)
+(enq make-routine!f1 running-routines*)
+(assert (is 1 len.running-routines*))
+; sleeping routine
+(let routine make-routine!f2
+  (= rep.routine!sleep '(23 integer))
+  (set sleeping-routines*.routine))
+; set memory location
+(= memory*.23 1)
+(update-scheduler-state)
+(if (~is 2 len.running-routines*)
+  (prn "F - scheduler unblocks routines blocked on locations"))
+
+(reset)
 (new-trace "scheduler-skip")
 (add-fns
   '((f1
@@ -1845,7 +1893,7 @@
 (each routine completed-routines*
   (aif rep.routine!error (prn "error - " it)))
 (if (~is memory*.2 4)  ; successor of value
-  (prn "F - scheduler handles routines blocking on a memory location"))
+  (prn "F - sleep can block on a memory location"))
 ;? (quit)
 
 (reset)
@@ -1864,7 +1912,7 @@
 ;? (= dump-trace* (obj whitelist '("run" "schedule")))
 (run 'f1 'f2)
 (if (~is memory*.12 4)  ; successor of value
-  (prn "F - scheduler handles routines blocking on a scoped memory location"))
+  (prn "F - sleep can block on a scoped memory location"))
 ;? (quit)
 
 (reset)