From fac6a170edcf1ae79ade2d9d8bdcabacacf6b24f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 6 Nov 2014 11:36:16 -0800 Subject: 233 - start tracking global cycle count We're gonna need this to implement 'sleep'. --- mu.arc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'mu.arc') diff --git a/mu.arc b/mu.arc index 06fd2f0b..207349ad 100644 --- a/mu.arc +++ b/mu.arc @@ -135,7 +135,8 @@ (= running-routines* (queue)) (= completed-routines* (queue)) (= routine* nil) - (= abort-routine* (parameter nil))) + (= abort-routine* (parameter nil)) + (= curr-cycle* 0)) ; like arc's 'point' but you can also call ((abort-routine*)) in nested calls (mac routine-mark body @@ -145,18 +146,16 @@ ,@body))))) (def run fn-names - (ret result 0 - (each it fn-names - (enq make-routine.it running-routines*)) - ; simple round-robin scheduler - (while (~empty running-routines*) - (= routine* deq.running-routines*) - (trace "schedule" top.routine*!fn-name) - (whenlet insts-run (routine-mark:run-for-time-slice scheduling-interval*) - (= result (+ result insts-run))) - (if (~empty routine*) - (enq routine* running-routines*) - (enq-limit routine* completed-routines*))))) + (each it fn-names + (enq make-routine.it running-routines*)) + ; simple round-robin scheduler + (while (~empty running-routines*) + (= routine* deq.running-routines*) + (trace "schedule" top.routine*!fn-name) + (routine-mark:run-for-time-slice scheduling-interval*) + (if (~empty routine*) + (enq routine* running-routines*) + (enq-limit routine* completed-routines*)))) (def die (msg) (= rep.routine*!error msg) @@ -358,8 +357,9 @@ (pop-stack routine*) (if empty.routine* (return ninstrs)) (++ pc.routine*)) + (++ curr-cycle*) (trace "run" "-- " int-canon.memory*) - (trace "run" top.routine*!fn-name " " pc.routine* ": " (body.routine* pc.routine*)) + (trace "run" curr-cycle* " " top.routine*!fn-name " " pc.routine* ": " (body.routine* pc.routine*)) ;? (trace "run" routine*) (let (oarg op arg) (parse-instr (body.routine* pc.routine*)) (let tmp -- cgit 1.4.1-2-gfad0 class='path'>path: root/src/history.c
blob: d7e360c112296bcc49fef30524ab53d017122a32 (plain) (tree)
1
2
3
4
5