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-06 16:08:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-06 16:08:16 -0800
commit40544ff87cf82d84c051659c971093ffb534b0d6 (patch)
treed4497a34975a3277295aae7800b7abfe5019e140 /mu.arc.t
parent64579cf7c812e4ffe659fc6f1b1614bfc5848f22 (diff)
downloadmu-40544ff87cf82d84c051659c971093ffb534b0d6.tar.gz
238 - avoid deadlock if all jobs are sleeping
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/mu.arc.t b/mu.arc.t
index 41561520..4050a6aa 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -1698,6 +1698,30 @@
     ("run" "f1 2")
   ))
 
+(reset)
+(new-trace "sleep-long")
+(add-fns
+  '((f1
+      (sleep (20 literal))
+      ((1 integer) <- copy (3 literal))
+      ((1 integer) <- copy (3 literal)))
+    (f2
+      ((2 integer) <- copy (4 literal))
+      ((2 integer) <- copy (4 literal)))))
+;? (= dump-trace* (obj whitelist '("run" "schedule")))
+(= scheduling-interval* 1)
+(run 'f1 'f2)
+(check-trace-contents "scheduler progresses sleeping routines when there are no routines left to run"
+  '(("run" "f1 0")
+    ("run" "sleeping until 21")
+    ("schedule" "pushing f1 to sleep queue")
+    ("run" "f2 0")
+    ("run" "f2 1")
+    ("schedule" "waking up f1")
+    ("run" "f1 1")
+    ("run" "f1 2")
+  ))
+
 ; 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.