From f3b0f4dc0513388135a57961b5a7a00fd2b9e4e6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 28 Aug 2014 20:44:16 -0700 Subject: 89 - a simple round-robin scheduler --- mu.arc.t | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mu.arc.t') diff --git a/mu.arc.t b/mu.arc.t index f02f9610..2ab4d9c8 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -662,3 +662,27 @@ (prn "F - 'new' returns current high-water mark")) (if (~iso Memory-in-use-until (+ before 5)) (prn "F - 'new' on primitive arrays increments high-water mark by their size"))) + +(reset) +(add-fns + '((f1 + ((1 integer) <- literal 3)) + (f2 + ((2 integer) <- literal 4)))) +(enq make-context!f1 contexts*) +(enq make-context!f2 contexts*) +(let ninsts (run) + (when (~iso 2 ninsts) + (prn "F - scheduler didn't run the right number of instructions: " ninsts))) +(if (~iso memory* (obj 1 3 2 4)) + (prn "F - scheduler runs multiple functions: " memory*)) +(check-trace-contents "scheduler orders functions correctly" + '(("schedule" "f1") + ("schedule" "f2") + )) +(check-trace-contents "scheduler orders schedule and run events correctly" + '(("schedule" "f1") + ("run" "f1 0") + ("schedule" "f2") + ("run" "f2 0") + )) -- cgit 1.4.1-2-gfad0