about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-04 20:19:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-04 20:55:03 -0700
commit133401ecbc34b0b06a72717c5dd2875293171985 (patch)
tree27e65e8f03205190326d59d2dfb7622349192c92
parent6e56bf32cca9f2b6b67de3c6c640d4dfa33b5197 (diff)
downloadmu-133401ecbc34b0b06a72717c5dd2875293171985.tar.gz
94 - old multiprocessing experiment
-rw-r--r--fork.mu12
-rw-r--r--mu.arc9
2 files changed, 20 insertions, 1 deletions
diff --git a/fork.mu b/fork.mu
new file mode 100644
index 00000000..42f1956b
--- /dev/null
+++ b/fork.mu
@@ -0,0 +1,12 @@
+(main
+  (fork (thread2 fn))
+  ((1 integer) <- literal 34)
+  (print (1 integer))
+  (jmp (-2 offset))
+)
+
+(thread2
+  ((2 integer) <- literal 35)
+  (print (2 integer))
+  (jmp (-2 offset))
+)
diff --git a/mu.arc b/mu.arc
index 1fc2c39b..ceca177e 100644
--- a/mu.arc
+++ b/mu.arc
@@ -164,7 +164,7 @@
 (mac caller-arg-idx (context (o idx 0))  ; assignable
   `((((rep ,context) 'call-stack) ,idx) 'caller-arg-idx))
 
-(= scheduling-interval* 500)
+(= scheduling-interval* 5)
 
 (def parse-instr (instr)
   (iflet delim (pos '<- instr)
@@ -295,6 +295,13 @@
                 print
                   (do1 nil
                     (apply prn (map m arg)))
+
+                ; multiprocessing
+                run
+                  (run (v arg.0))
+                fork
+                  (enq (make-context (v arg.0)) contexts*)
+
                 reply
                   (do (pop-stack context)
                       (if empty.context (return ninstrs))