about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-19 00:19:57 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-19 00:23:48 -0800
commite0bf118825765fc2a81e7a5c9b65304c3cc02b02 (patch)
tree5a73c09ed4b2f38b5f8e283faa07257a4518a820
parent38e51bc6175397d134b10b0ba87e4bd77067d32d (diff)
downloadmu-e0bf118825765fc2a81e7a5c9b65304c3cc02b02.tar.gz
275 - pass args to fork
Only literals for starters.
-rw-r--r--mu.arc7
-rw-r--r--mu.arc.t11
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.