diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/072scheduler.cc.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/072scheduler.cc.html')
-rw-r--r-- | html/072scheduler.cc.html | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 4af95f06..1d2681fa 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -43,11 +43,11 @@ def f1 [ start-running f2 <span class="Comment"># wait for f2 to run</span> <span class="Delimiter">{</span> - jump-unless <span class="Constant">1</span>:number<span class="Delimiter">,</span> -<span class="Constant">1</span> + jump-unless <span class="Constant">1</span>:num<span class="Delimiter">,</span> -<span class="Constant">1</span> <span class="Delimiter">}</span> ] def f2 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span> ] <span class="traceContains">+schedule: f1</span> <span class="traceContains">+schedule: f2</span> @@ -169,7 +169,7 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s Current_routine = main_routine<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<<span class="Normal">double</span>> arg<span class="Delimiter">;</span> - arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> + arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_text<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>arg<span class="Delimiter">);</span> <span class="Delimiter">}</span> run<span class="Delimiter">(</span>main_routine<span class="Delimiter">);</span> @@ -233,8 +233,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(scenario scheduler_runs_single_routine)</span> <span class="Special">% Scheduling_interval = 1;</span> def f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> <span class="traceContains">+run: {1: "number"} <- copy {0: "literal"}</span> @@ -245,12 +245,12 @@ def f1 [ <span class="Special">% Scheduling_interval = 1;</span> def f1 [ start-running f2 - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] def f2 [ - <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> <span class="traceContains">+run: start-running {f2: "recipe-literal"}</span> @@ -268,12 +268,12 @@ def f1 [ start-running f2<span class="Delimiter">,</span> <span class="Constant">3</span> <span class="Comment"># wait for f2 to run</span> <span class="Delimiter">{</span> - jump-unless <span class="Constant">1</span>:number<span class="Delimiter">,</span> -<span class="Constant">1</span> + jump-unless <span class="Constant">1</span>:num<span class="Delimiter">,</span> -<span class="Constant">1</span> <span class="Delimiter">}</span> ] def f2 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>next-ingredient - <span class="Constant">2</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>next-ingredient + <span class="Constant">2</span>:num<span class="Special"> <- </span>add <span class="Constant">1</span>:num<span class="Delimiter">,</span> <span class="Constant">1</span> ] <span class="traceContains">+mem: storing 4 in location 2</span> @@ -285,20 +285,20 @@ def main [ local-scope create-<span class="Normal">new</span>-routine <span class="Comment"># padding to make sure we run new-routine before returning</span> - <span class="Normal">dummy</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Normal">dummy</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">dummy</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">dummy</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] def create-<span class="Normal">new</span>-routine [ local-scope - <span class="Normal">n</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Normal">n</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> number:type *n<span class="Special"> <- </span>copy <span class="Constant">34</span> start-running <span class="Normal">new</span>-routine<span class="Delimiter">,</span> n <span class="Comment"># refcount of n decremented</span> ] -def <span class="Normal">new</span>-routine n:address:number [ +def <span class="Normal">new</span>-routine n:&:num [ local-scope load-ingredients - <span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy *n + <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy *n ] <span class="Comment"># check that n wasn't reclaimed when create-new-routine returned</span> <span class="traceContains">+mem: storing 34 in location 1</span> @@ -318,25 +318,25 @@ increment_any_refcounts<span class="Delimiter">(</span>ingredient<span class="De <span class="Delimiter">}</span> <span class="Delimiter">:(scenario next_ingredient_never_leaks_refcounts)</span> -def create-scope n:address:number <span class="Delimiter">-></span> <span class="Normal">default</span>-space:address:array:location [ +def create-space n:&:num <span class="Delimiter">-></span> <span class="Normal">default</span>-space:space [ <span class="Normal">default</span>-space<span class="Special"> <- </span><span class="Normal">new</span> location:type<span class="Delimiter">,</span> <span class="Constant">2</span> load-ingredients ] -def use-scope [ +def use-space [ local-scope - <span class="Constant">0</span>:address:array:location/names:create-scope<span class="Special"> <- </span>next-ingredient - <span class="Normal">n</span>:address:number/space:<span class="Constant">1</span><span class="Special"> <- </span>next-ingredient <span class="Comment"># should decrement refcount</span> + <span class="Constant">0</span>:space/names:create-space<span class="Special"> <- </span>next-ingredient + <span class="Normal">n</span>:&:num/space:<span class="Constant">1</span><span class="Special"> <- </span>next-ingredient <span class="Comment"># should decrement refcount</span> *n/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Normal">n2</span>:number<span class="Special"> <- </span>add *n/space:<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Normal">n2</span>:num<span class="Special"> <- </span>add *n/space:<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span> reply n2 ] def main [ local-scope - <span class="Normal">n</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">12000</span>/unsafe <span class="Comment"># pretend allocation with a known address</span> + <span class="Normal">n</span>:&:num<span class="Special"> <- </span>copy <span class="Constant">12000</span>/unsafe <span class="Comment"># pretend allocation with a known address</span> *n<span class="Special"> <- </span>copy <span class="Constant">23</span> - <span class="Normal">scope</span>:address:array:location<span class="Special"> <- </span>create-scope n - <span class="Normal">n2</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">13000</span>/unsafe - <span class="Normal">n3</span>:number<span class="Special"> <- </span>use-scope scope<span class="Delimiter">,</span> n2 + <span class="Normal">space</span>:space<span class="Special"> <- </span>create-space n + <span class="Normal">n2</span>:&:num<span class="Special"> <- </span>copy <span class="Constant">13000</span>/unsafe + <span class="Normal">n3</span>:num<span class="Special"> <- </span>use-space space<span class="Delimiter">,</span> n2 ] <span class="traceContains">+run: {n: ("address" "number"), "space": "1"} <- next-ingredient</span> <span class="traceContains">+mem: decrementing refcount of 12000: 2 -> 1</span> @@ -346,24 +346,24 @@ def main [ <span class="Delimiter">:(scenario start_running_returns_routine_id)</span> def f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>start-running f2 + <span class="Constant">1</span>:num<span class="Special"> <- </span>start-running f2 ] def f2 [ - <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">44</span> + <span class="Constant">12</span>:num<span class="Special"> <- </span>copy <span class="Constant">44</span> ] <span class="traceContains">+mem: storing 2 in location 1</span> <span class="Comment">//: this scenario will require some careful setup in escaped C++</span> <span class="Comment">//: (straining our tangle capabilities to near-breaking point)</span> <span class="Delimiter">:(scenario scheduler_skips_completed_routines)</span> -<span class="Special">% recipe_ordinal f1 = load("recipe f1 [\n1:number <- copy 0\n]\n").front();</span> -<span class="Special">% recipe_ordinal f2 = load("recipe f2 [\n2:number <- copy 0\n]\n").front();</span> +<span class="Special">% recipe_ordinal f1 = load("recipe f1 [\n1:num <- copy 0\n]\n").front();</span> +<span class="Special">% recipe_ordinal f2 = load("recipe f2 [\n2:num <- copy 0\n]\n").front();</span> <span class="Special">% Routines.push_back(new routine(f1)); // f1 meant to run</span> <span class="Special">% Routines.push_back(new routine(f2));</span> <span class="Special">% Routines.back()->state = COMPLETED; // f2 not meant to run</span> <span class="Comment"># must have at least one routine without escaping</span> def f3 [ - <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="Comment"># by interleaving '+' lines with '-' lines, we allow f1 and f3 to run in any order</span> <span class="traceContains">+schedule: f1</span> @@ -377,8 +377,8 @@ def f3 [ <span class="Special">% Routines.push_back(new routine(COPY));</span> <span class="Special">% Routines.back()->state = COMPLETED;</span> def f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> <span class="traceAbsent">-run: idle</span> @@ -390,17 +390,17 @@ def f1 [ <span class="Special">% Scheduling_interval = 2;</span> def f1 [ start-running f2 - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] def f2 [ <span class="Comment"># divide by 0 twice</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>divide-with-remainder <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">0</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>divide-with-remainder <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">0</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>divide-with-remainder <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">0</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>divide-with-remainder <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">0</span> ] <span class="Comment"># f2 should stop after first divide by 0</span> -<span class="traceContains">+error: f2: divide by zero in '3:number <- divide-with-remainder 4, 0'</span> -<span class="traceAbsent">-error: f2: divide by zero in '4:number <- divide-with-remainder 4, 0'</span> +<span class="traceContains">+error: f2: divide by zero in '3:num <- divide-with-remainder 4, 0'</span> +<span class="traceAbsent">-error: f2: divide by zero in '4:num <- divide-with-remainder 4, 0'</span> <span class="Delimiter">:(after "operator<<(ostream& os, unused end)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream && Trace_stream<span class="Delimiter">-></span>curr_label == <span class="Constant">"error"</span> && Current_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -415,7 +415,7 @@ def main [ <span class="Comment"># f1 never actually runs because its parent completes without waiting for it</span> ] def f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceAbsent">-schedule: f1</span> @@ -443,13 +443,13 @@ def f1 [ <span class="Delimiter">:(scenario routine_state_test)</span> <span class="Special">% Scheduling_interval = 2;</span> def f1 [ - <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2 - <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># race condition since we don't care about location 12</span> + <span class="Constant">1</span>:num/child-id<span class="Special"> <- </span>start-running f2 + <span class="Constant">12</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># race condition since we don't care about location 12</span> <span class="Comment"># thanks to Scheduling_interval, f2's one instruction runs in between here and completes</span> - <span class="Constant">2</span>:number/state<span class="Special"> <- </span>routine-state <span class="Constant">1</span>:number/child-id + <span class="Constant">2</span>:num/state<span class="Special"> <- </span>routine-state <span class="Constant">1</span>:num/child-id ] def f2 [ - <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">12</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># trying to run a second instruction marks routine as completed</span> ] <span class="Comment"># recipe f2 should be in state COMPLETED</span> @@ -537,12 +537,12 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(scenario routine_discontinues_past_limit)</span> <span class="Special">% Scheduling_interval = 2;</span> def f1 [ - <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2 - limit-time <span class="Constant">1</span>:number/child-id<span class="Delimiter">,</span> <span class="Constant">10</span> + <span class="Constant">1</span>:num/child-id<span class="Special"> <- </span>start-running f2 + limit-time <span class="Constant">1</span>:num/child-id<span class="Delimiter">,</span> <span class="Constant">10</span> <span class="Comment"># padding loop just to make sure f2 has time to completed</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">20</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>subtract <span class="Constant">2</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> - jump-<span class="Normal">if</span> <span class="Constant">2</span>:number<span class="Delimiter">,</span> -<span class="Constant">2</span>:offset + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">20</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>subtract <span class="Constant">2</span>:num<span class="Delimiter">,</span> <span class="Constant">1</span> + jump-<span class="Normal">if</span> <span class="Constant">2</span>:num<span class="Delimiter">,</span> -<span class="Constant">2</span>:offset ] def f2 [ jump -<span class="Constant">1</span>:offset <span class="Comment"># run forever</span> @@ -661,16 +661,16 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(scenario number_of_instructions)</span> def f1 [ - <span class="Constant">10</span>:number/child-id<span class="Special"> <- </span>start-running f2 + <span class="Constant">10</span>:num/child-id<span class="Special"> <- </span>start-running f2 <span class="Delimiter">{</span> - loop-unless <span class="Constant">20</span>:number + loop-unless <span class="Constant">20</span>:num <span class="Delimiter">}</span> - <span class="Constant">11</span>:number<span class="Special"> <- </span>number-of-instructions <span class="Constant">10</span>:number + <span class="Constant">11</span>:num<span class="Special"> <- </span>number-of-instructions <span class="Constant">10</span>:num ] def f2 [ <span class="Comment"># 2 instructions worth of work</span> - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">20</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span> ] <span class="Comment"># f2 runs an extra instruction for the implicit return added by the</span> <span class="Comment"># fill_in_reply_ingredients transform</span> @@ -679,18 +679,18 @@ def f2 [ <span class="Delimiter">:(scenario number_of_instructions_across_multiple_scheduling_intervals)</span> <span class="Special">% Scheduling_interval = 1;</span> def f1 [ - <span class="Constant">10</span>:number/child-id<span class="Special"> <- </span>start-running f2 + <span class="Constant">10</span>:num/child-id<span class="Special"> <- </span>start-running f2 <span class="Delimiter">{</span> - loop-unless <span class="Constant">20</span>:number + loop-unless <span class="Constant">20</span>:num <span class="Delimiter">}</span> - <span class="Constant">11</span>:number<span class="Special"> <- </span>number-of-instructions <span class="Constant">10</span>:number + <span class="Constant">11</span>:num<span class="Special"> <- </span>number-of-instructions <span class="Constant">10</span>:num ] def f2 [ <span class="Comment"># 4 instructions worth of work</span> - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span> - <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">3</span> + <span class="Constant">20</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span> ] <span class="Comment"># f2 runs an extra instruction for the implicit return added by the</span> <span class="Comment"># fill_in_reply_ingredients transform</span> @@ -701,18 +701,18 @@ def f2 [ <span class="Delimiter">:(scenario new_concurrent)</span> def f1 [ start-running f2 - <span class="Constant">1</span>:address:number/<span class="Special">raw <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:&:num/<span class="Special">raw <- </span><span class="Normal">new</span> number:type <span class="Comment"># wait for f2 to complete</span> <span class="Delimiter">{</span> - loop-unless <span class="Constant">4</span>:number/<span class="Special">raw</span> + loop-unless <span class="Constant">4</span>:num/<span class="Special">raw</span> <span class="Delimiter">}</span> ] def f2 [ - <span class="Constant">2</span>:address:number/<span class="Special">raw <- </span><span class="Normal">new</span> number:type + <span class="Constant">2</span>:&:num/<span class="Special">raw <- </span><span class="Normal">new</span> number:type <span class="Comment"># hack: assumes scheduler implementation</span> - <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:address:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:address:number/<span class="Special">raw</span> + <span class="Constant">3</span>:<span class="Normal">bool</span>/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:&:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:&:num/<span class="Special">raw</span> <span class="Comment"># signal f2 complete</span> - <span class="Constant">4</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">1</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>copy <span class="Constant">1</span> ] <span class="traceContains">+mem: storing 0 in location 3</span> </pre> |