From 0e4a335edc7d4e584924fd6b298156e45d2626c8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 6 Sep 2015 16:35:46 -0700 Subject: 2175 --- html/038scheduler.cc.html | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'html/038scheduler.cc.html') diff --git a/html/038scheduler.cc.html b/html/038scheduler.cc.html index 02c08935..3a258741 100644 --- a/html/038scheduler.cc.html +++ b/html/038scheduler.cc.html @@ -15,7 +15,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } .SalientComment { color: #00ffff; } .traceAbsent { color: #c00000; } -.CommentedCode { color: #6c6c6c; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } @@ -83,7 +82,12 @@ Scheduling_interval = 500; Routines.clear(); :(replace{} "void run(recipe_ordinal r)") void run(recipe_ordinal r) { - Routines.push_back(new routine(r)); + run(new routine(r)); +} + +:(code) +void run(routine* rr) { + Routines.push_back(rr); Current_routine_index = 0, Current_routine = Routines.at(0); while (!all_routines_done()) { skip_to_next_routine(); @@ -101,7 +105,6 @@ void run(recipe_ordinal r } } -:(code) bool all_routines_done() { for (long long int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == RUNNING) { @@ -139,6 +142,24 @@ for (long long int i = 0.at(i); Routines.clear(); +//: special case for the very first routine +:(replace{} "void run_main(int argc, char* argv[])") +void run_main(int argc, char* argv[]) { + recipe_ordinal r = Recipe_ordinal[string("main")]; + if (r) { + // pass in commandline args as ingredients to main + // todo: test this + routine* rr = new routine(r); + Current_routine = rr; + for (long long int i = 1; i < argc; ++i) { + vector<double> arg; + arg.push_back(new_mu_string(argv[i])); + Current_routine->calls.front().ingredient_atoms.push_back(arg); + } + run(rr); + } +} + //:: To schedule new routines to run, call 'start-running'. //: 'start-running' will return a unique id for the routine that was created. @@ -253,7 +274,6 @@ recipe f2 [ % Routines.push_back(new routine(f1)); // f1 meant to run % Routines.push_back(new routine(f2)); % Routines.back()->state = COMPLETED; // f2 not meant to run -#? % Trace_stream->dump_layer = "all"; # must have at least one routine without escaping recipe f3 [ 3:number <- copy 0 @@ -418,12 +438,15 @@ case _DUMP_ROUTINES: { % Scheduling_interval = 2; recipe f1 [ 1:number/child-id <- start-running f2:recipe - limit-time 1:number/child-id, 1 + limit-time 1:number/child-id, 10 + # padding loop just to make sure f2 has time to completed + 2:number <- copy 20 + 2:number <- subtract 2:number, 1 + jump-if 2:number, -2:offset ] recipe f2 [ -{ - loop # run forever -} + jump -1:offset # run forever + $print [should never get here], 10/newline ] # f2 terminates +schedule: discontinuing routine 2 -- cgit 1.4.1-2-gfad0