about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-10 13:49:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-10 13:49:16 -0800
commitea0d661bb77ca3a844ff7c7268cd5a9b3266265c (patch)
treed68c3c67405e3125f5284cc5a4d958ced7a358bd /mu.arc.t
parent9c2ed239561c069beba0953616ddab15ac21265b (diff)
downloadmu-ea0d661bb77ca3a844ff7c7268cd5a9b3266265c.tar.gz
529 - 'sleep' can now wait for a routine to complete
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t26
1 files changed, 26 insertions, 0 deletions
diff --git a/mu.arc.t b/mu.arc.t
index d12b109b..f9c2ef83 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -2882,6 +2882,32 @@
 (when (ran-to-completion 'f1)
   (prn "F - fork can specify a maximum cycle limit"))
 
+(reset)
+(new-trace "fork-then-wait")
+(add-code
+  '((function f1 [
+      { begin
+        (loop)
+      }
+     ])
+    (function main [
+      (1:integer/routine-id <- fork f1:fn nil:literal/globals 30:literal/limit)
+      (sleep until-routine-done:literal 1:integer/routine-id)
+      (2:integer <- copy 34:literal)
+     ])))
+(= scheduling-interval* 5)
+;? (= dump-trace* (obj whitelist '("schedule")))
+(run 'main)
+(each routine completed-routines*
+  (awhen rep.routine!error (prn "error - " it)))
+(check-trace-contents "scheduler orders functions correctly"
+  '(("schedule" "pushing main to sleep queue")
+    ("schedule" "scheduling f1")
+    ("schedule" "ran out of time")
+    ("schedule" "waking up main")
+  ))
+;? (quit)
+
 ; The scheduler needs to keep track of the call stack for each routine.
 ; Eventually we'll want to save this information in mu's address space itself,
 ; along with the types array, the magic buffers for args and oargs, and so on.