From e0bf118825765fc2a81e7a5c9b65304c3cc02b02 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 19 Nov 2014 00:19:57 -0800 Subject: 275 - pass args to fork Only literals for starters. --- mu.arc | 7 ++++--- mu.arc.t | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mu.arc b/mu.arc index 9bf1e703..522ddff4 100644 --- a/mu.arc +++ b/mu.arc @@ -131,9 +131,9 @@ ;; managing concurrent routines ; routine = runtime state for a serial thread of execution -(def make-routine (fn-name) +(def make-routine (fn-name . args) (annotate 'routine (obj call-stack (list - (obj fn-name fn-name pc 0 caller-arg-idx 0))))) + (obj fn-name fn-name pc 0 args args caller-arg-idx 0))))) (defextend empty (x) (isa x 'routine) (no rep.x!call-stack)) @@ -501,7 +501,8 @@ run (run (v arg.0)) fork - (enq (make-routine (v arg.0)) running-routines*) + (let v car ; same effect as 'v' macro + (enq (apply make-routine (v car.arg) (map v cdr.arg)) running-routines*)) ; todo: errors should stall a process and let its parent ; inspect it assert diff --git a/mu.arc.t b/mu.arc.t index 7a8665eb..7487f57b 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1801,6 +1801,17 @@ (if (~iso memory*.2 4) (prn "F - fork works")) +(reset) +(new-trace "fork-with-args") +(add-fns + '((f1 + (fork (f2 fn) (4 literal))) + (f2 + ((2 integer) <- arg)))) +(run 'f1) +(if (~iso memory*.2 4) + (prn "F - fork can pass args")) + ; 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. -- cgit 1.4.1-2-gfad0