From 5cd7cebefa743cc7a71e6069b34f302ac3130a61 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 22 Nov 2014 00:31:31 -0800 Subject: 294 - read/write now pass channel by reference But handoff test still failing. --- mu.arc | 30 +++++++++++++++--------------- mu.arc.t | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/mu.arc b/mu.arc index 79ee4210..2b5117e5 100644 --- a/mu.arc +++ b/mu.arc @@ -85,7 +85,7 @@ (= traces* (queue))) (def new-trace (filename) -;? (prn "new-trace " filename) + (prn "new-trace " filename) (= curr-trace-file* filename)) (= dump-trace* nil) @@ -933,20 +933,20 @@ (init-fn write ((default-scope scope-address) <- new (scope literal) (30 literal)) - ((chan channel) <- arg) + ((chan channel-address) <- arg) ((val tagged-value) <- arg) { begin ; block if chan is full - ((full boolean) <- full? (chan channel)) + ((full boolean) <- full? (chan channel-address deref)) ; race condition: might unnecessarily sleep if consumer routine reads from ; channel between previous check and the set to watch below (break-unless (full boolean)) - ((watch boolean-address) <- get-address (chan channel) (read-watch offset)) + ((watch boolean-address) <- get-address (chan channel-address deref) (read-watch offset)) ((watch boolean-address deref) <- copy (nil literal)) (sleep (watch boolean-address deref)) } - ((q tagged-value-array-address) <- get (chan channel) (circular-buffer offset)) - ((free integer-address) <- get-address (chan channel) (first-free offset)) + ((q tagged-value-array-address) <- get (chan channel-address deref) (circular-buffer offset)) + ((free integer-address) <- get-address (chan channel-address deref) (first-free offset)) ((dest tagged-value-address) <- index-address (q tagged-value-array-address deref) (free integer-address deref)) ((dest tagged-value-address deref) <- copy (val tagged-value)) ((free integer-address deref) <- add (free integer-address deref) (1 literal)) @@ -956,25 +956,25 @@ (break-if (remaining? boolean)) ((free integer-address deref) <- copy (0 literal)) } - ((watch boolean-address) <- get-address (chan channel) (write-watch offset)) + ((watch boolean-address) <- get-address (chan channel-address deref) (write-watch offset)) ((watch boolean-address deref) <- copy (t literal)) - (reply (chan channel))) + (reply (chan channel-address deref))) (init-fn read ((default-scope scope-address) <- new (scope literal) (30 literal)) - ((chan channel) <- arg) + ((chan channel-address) <- arg) { begin ; block if chan is empty - ((empty boolean) <- empty? (chan channel)) + ((empty boolean) <- empty? (chan channel-address deref)) ; race condition: might unnecessarily sleep if consumer routine writes to ; channel between previous check and the set to watch below (break-unless (empty boolean)) - ((watch boolean-address) <- get-address (chan channel) (write-watch offset)) + ((watch boolean-address) <- get-address (chan channel-address deref) (write-watch offset)) ((watch boolean-address deref) <- copy (nil literal)) (sleep (watch boolean-address deref)) } - ((full integer-address) <- get-address (chan channel) (first-full offset)) - ((q tagged-value-array-address) <- get (chan channel) (circular-buffer offset)) + ((full integer-address) <- get-address (chan channel-address deref) (first-full offset)) + ((q tagged-value-array-address) <- get (chan channel-address deref) (circular-buffer offset)) ((result tagged-value) <- index (q tagged-value-array-address deref) (full integer-address deref)) ((full integer-address deref) <- add (full integer-address deref) (1 literal)) { begin @@ -983,9 +983,9 @@ (break-if (remaining? boolean)) ((full integer-address deref) <- copy (0 literal)) } - ((watch boolean-address) <- get-address (chan channel) (read-watch offset)) + ((watch boolean-address) <- get-address (chan channel-address deref) (read-watch offset)) ((watch boolean-address deref) <- copy (t literal)) - (reply (result tagged-value) (chan channel))) + (reply (result tagged-value) (chan channel-address deref))) ; An empty channel has first-empty and first-full both at the same value. (init-fn empty? diff --git a/mu.arc.t b/mu.arc.t index d88cb8b0..50ec12ff 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -2049,7 +2049,7 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((4 integer) <- get (1 channel-address deref) (first-full offset)) ((5 integer) <- get (1 channel-address deref) (first-free offset))))) ;? (set dump-trace*) @@ -2070,8 +2070,8 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) - ((4 tagged-value) (1 channel-address deref) <- read (1 channel-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) + ((4 tagged-value) (1 channel-address deref) <- read (1 channel-address)) ((6 integer-address) <- maybe-coerce (4 tagged-value) (integer-address literal)) ((7 integer) <- get (1 channel-address deref) (first-full offset)) ((8 integer) <- get (1 channel-address deref) (first-free offset))))) @@ -2095,13 +2095,13 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ; first-free will now be 1 ((4 integer) <- get (1 channel-address deref) (first-free offset)) ; read one value - (_ (1 channel-address deref) <- read (1 channel-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ; write a second value; verify that first-free wraps around to 0. - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((5 integer) <- get (1 channel-address deref) (first-free offset))))) ;? (set dump-trace*) ;? (= dump-trace* (obj blacklist '("sz" "m" "setm" "addr" "array-len" "cvt0" "cvt1"))) @@ -2121,15 +2121,15 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ; read one value - (_ (1 channel-address deref) <- read (1 channel-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ; first-full will now be 1 ((4 integer) <- get (1 channel-address deref) (first-full offset)) ; write a second value - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ; read second value; verify that first-full wraps around to 0. - (_ (1 channel-address deref) <- read (1 channel-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ((5 integer) <- get (1 channel-address deref) (first-full offset))))) ;? (set dump-trace*) ;? (= dump-trace* (obj blacklist '("sz" "m" "setm" "addr" "array-len" "cvt0" "cvt1"))) @@ -2161,7 +2161,7 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((4 boolean) <- empty? (1 channel-address deref)) ((5 boolean) <- full? (1 channel-address deref))))) ;? (set dump-trace*) @@ -2179,7 +2179,7 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((4 boolean) <- empty? (1 channel-address deref)) ((5 boolean) <- full? (1 channel-address deref))))) ;? (set dump-trace*) @@ -2197,9 +2197,9 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) - (_ (1 channel-address deref) <- read (1 channel-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ((4 boolean) <- empty? (1 channel-address deref)) ((5 boolean) <- full? (1 channel-address deref))))) ;? (set dump-trace*) @@ -2217,8 +2217,8 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) - (_ (1 channel-address deref) <- read (1 channel-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ((4 boolean) <- empty? (1 channel-address deref)) ((5 boolean) <- full? (1 channel-address deref))))) ;? (set dump-trace*) @@ -2237,7 +2237,7 @@ '((main ((1 channel-address) <- new-channel (3 literal)) ; channel is empty, but receives a read - ((2 tagged-value) (1 channel-address deref) <- read (1 channel-address deref))))) + ((2 tagged-value) (1 channel-address deref) <- read (1 channel-address))))) ;? (set dump-trace*) ;? (= dump-trace* (obj whitelist '("run"))) (run 'main) @@ -2261,9 +2261,9 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ; channel has capacity 1, but receives a second write - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref))))) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref))))) ;? (set dump-trace*) ;? (= dump-trace* (obj whitelist '("run" "schedule" "addr"))) (run 'main) @@ -2294,7 +2294,7 @@ ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) ((4 boolean) <- get (1 channel-address deref) (read-watch offset)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((5 boolean) <- get (1 channel-address deref) (write-watch offset))))) (run 'main) (if (or (~is nil memory*.4) @@ -2309,9 +2309,9 @@ ((2 integer-address) <- new (integer literal)) ((2 integer-address deref) <- copy (34 literal)) ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address)) - ((1 channel-address deref) <- write (1 channel-address deref) (3 tagged-value-address deref)) + ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)) ((4 boolean) <- get (1 channel-address deref) (read-watch offset)) - (_ (1 channel-address deref) <- read (1 channel-address deref)) + (_ (1 channel-address deref) <- read (1 channel-address)) ((5 integer) <- get (1 channel-address deref) (read-watch offset))))) (run 'main) (if (or (~is nil memory*.4) @@ -2325,14 +2325,14 @@ ((default-scope scope-address) <- new (scope literal) (30 literal)) ((chan channel-address) <- new-channel (3 literal)) (fork (f2 fn) (chan channel-address)) - ((1 integer global) <- read (chan channel-address deref))) + ((1 integer global) <- read (chan channel-address))) (f2 ((default-scope scope-address) <- new (scope literal) (30 literal)) ((n integer-address) <- new (integer literal)) ((n integer-address deref) <- copy (24 literal)) ((ochan channel-address) <- arg) ((x tagged-value-address) <- new-tagged-value (integer-address literal) (n integer-address)) - ((ochan channel-address deref) <- write (ochan channel-address deref) (x tagged-value-address deref))))) + ((ochan channel-address deref) <- write (ochan channel-address) (x tagged-value-address deref))))) ;? (set dump-trace*) ;? (= dump-trace* (obj whitelist '("schedule" "run" "addr"))) ;? (= dump-trace* (obj whitelist '("-"))) -- cgit 1.4.1-2-gfad0