From 9e751bb8c0cdf771d34c839cb6591d892b8e62de Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Mar 2017 01:41:48 -0800 Subject: 3761 --- html/072scheduler.cc.html | 185 +++++++++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 92 deletions(-) (limited to 'html/072scheduler.cc.html') diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 37bc5fc4..378ed639 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -15,18 +15,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color a { text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.Constant { color: #00a0a0; } -.traceAbsent { color: #c00000; } -.Special { color: #c00000; } -.muRecipe { color: #ff8700; } .SalientComment { color: #00ffff; } -.Comment { color: #9090ff; } -.Delimiter { color: #800080; } +.muRecipe { color: #ff8700; } .LineNr { color: #444444; } .traceContains { color: #008000; } +.traceAbsent { color: #c00000; } +.Delimiter { color: #800080; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #c0a020; } .cSpecial { color: #008000; } +.Conceal { color: #4e4e4e; } +.Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.Identifier { color: #c0a020; } --> @@ -69,7 +70,7 @@ if ('onhashchange' in window) { 6 start-running f2 7 # wait for f2 to run 8 { - 9 jump-unless 1:num, -1 + 9 ¦ jump-unless 1:num, -1 10 } 11 ] 12 def f2 [ @@ -91,7 +92,7 @@ if ('onhashchange' in window) { 28 bool should_continue_running(const routine* current_routine) { 29 assert(current_routine == Current_routine); // argument passed in just to make caller readable above 30 return Current_routine->state == RUNNING - 31 && Current_routine->instructions_run_this_scheduling_slice < Scheduling_interval; + 31 ¦ ¦ && Current_routine->instructions_run_this_scheduling_slice < Scheduling_interval; 32 } 33 :(after "stop_running_current_routine:") 34 // Reset instructions_run_this_scheduling_slice @@ -126,26 +127,26 @@ if ('onhashchange' in window) { 63 Routines.push_back(rr); 64 Current_routine_index = 0, Current_routine = Routines.at(0); 65 while (!all_routines_done()) { - 66 skip_to_next_routine(); - 67 assert(Current_routine); - 68 assert(Current_routine->state == RUNNING); - 69 trace(9990, "schedule") << current_routine_label() << end(); - 70 run_current_routine(); - 71 // Scheduler State Transitions - 72 if (Current_routine->completed()) - 73 Current_routine->state = COMPLETED; - 74 // End Scheduler State Transitions + 66 ¦ skip_to_next_routine(); + 67 ¦ assert(Current_routine); + 68 ¦ assert(Current_routine->state == RUNNING); + 69 ¦ trace(9990, "schedule") << current_routine_label() << end(); + 70 ¦ run_current_routine(); + 71 ¦ // Scheduler State Transitions + 72 ¦ if (Current_routine->completed()) + 73 ¦ ¦ Current_routine->state = COMPLETED; + 74 ¦ // End Scheduler State Transitions 75 - 76 // Scheduler Cleanup - 77 // End Scheduler Cleanup + 76 ¦ // Scheduler Cleanup + 77 ¦ // End Scheduler Cleanup 78 } 79 // End Run Routine 80 } 81 82 bool all_routines_done() { 83 for (int i = 0; i < SIZE(Routines); ++i) { - 84 if (Routines.at(i)->state == RUNNING) - 85 return false; + 84 ¦ if (Routines.at(i)->state == RUNNING) + 85 ¦ ¦ return false; 86 } 87 return true; 88 } @@ -155,11 +156,11 @@ if ('onhashchange' in window) { 92 assert(!Routines.empty()); 93 assert(Current_routine_index < SIZE(Routines)); 94 for (int i = (Current_routine_index+1)%SIZE(Routines); i != Current_routine_index; i = (i+1)%SIZE(Routines)) { - 95 if (Routines.at(i)->state == RUNNING) { - 96 Current_routine_index = i; - 97 Current_routine = Routines.at(i); - 98 return; - 99 } + 95 ¦ if (Routines.at(i)->state == RUNNING) { + 96 ¦ ¦ Current_routine_index = i; + 97 ¦ ¦ Current_routine = Routines.at(i); + 98 ¦ ¦ return; + 99 ¦ } 100 } 101 } 102 @@ -171,8 +172,8 @@ if ('onhashchange' in window) { 108 ostringstream result; 109 const call_stack& calls = r->calls; 110 for (call_stack::const_iterator p = calls.begin(); p != calls.end(); ++p) { -111 if (p != calls.begin()) result << '/'; -112 result << get(Recipe, p->running_recipe).name; +111 ¦ if (p != calls.begin()) result << '/'; +112 ¦ result << get(Recipe, p->running_recipe).name; 113 } 114 return result.str(); 115 } @@ -193,11 +194,11 @@ if ('onhashchange' in window) { 130 // todo: test this 131 Current_routine = main_routine; 132 for (int i = 1; i < argc; ++i) { -133 vector<double> arg; -134 arg.push_back(new_mu_text(argv[i])); -135 assert(get(Memory, arg.back()) == 0); -136 put(Memory, arg.back(), 1); // update refcount -137 current_call().ingredient_atoms.push_back(arg); +133 ¦ vector<double> arg; +134 ¦ arg.push_back(new_mu_text(argv[i])); +135 ¦ assert(get(Memory, arg.back()) == 0); +136 ¦ put(Memory, arg.back(), 1); // update refcount +137 ¦ current_call().ingredient_atoms.push_back(arg); 138 } 139 run(main_routine); 140 } @@ -230,12 +231,12 @@ if ('onhashchange' in window) { 167 :(before "End Primitive Recipe Checks") 168 case START_RUNNING: { 169 if (inst.ingredients.empty()) { -170 raise << maybe(get(Recipe, r).name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end(); -171 break; +170 ¦ raise << maybe(get(Recipe, r).name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end(); +171 ¦ break; 172 } 173 if (!is_mu_recipe(inst.ingredients.at(0))) { -174 raise << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); -175 break; +174 ¦ raise << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +175 ¦ break; 176 } 177 break; 178 } @@ -245,11 +246,11 @@ if ('onhashchange' in window) { 182 new_routine->parent_index = Current_routine_index; 183 // populate ingredients 184 for (int i = 1; i < SIZE(current_instruction().ingredients); ++i) { -185 new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i)); -186 reagent/*copy*/ ingredient = current_instruction().ingredients.at(i); -187 canonize_type(ingredient); -188 new_routine->calls.front().ingredients.push_back(ingredient); -189 // End Populate start-running Ingredient +185 ¦ new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i)); +186 ¦ reagent/*copy*/ ingredient = current_instruction().ingredients.at(i); +187 ¦ canonize_type(ingredient); +188 ¦ new_routine->calls.front().ingredients.push_back(ingredient); +189 ¦ // End Populate start-running Ingredient 190 } 191 Routines.push_back(new_routine); 192 products.resize(1); @@ -295,7 +296,7 @@ if ('onhashchange' in window) { 232 start-running f2, 3 233 # wait for f2 to run 234 { -235 jump-unless 1:num, -1 +235 ¦ jump-unless 1:num, -1 236 } 237 ] 238 def f2 [ @@ -463,7 +464,7 @@ if ('onhashchange' in window) { 400 401 :(after "operator<<(ostream& os, unused end)") 402 if (Trace_stream && Trace_stream->curr_label == "error" && Current_routine) { -403 Current_routine->state = COMPLETED; +403 ¦ Current_routine->state = COMPLETED; 404 } 405 406 //:: Routines are marked completed when their parent completes. @@ -484,15 +485,15 @@ if ('onhashchange' in window) { 421 if (Routines.at(i)->parent_index < 0) continue; // root thread 422 // structured concurrency: http://250bpm.com/blog:71 423 if (has_completed_parent(i)) { -424 Routines.at(i)->state = COMPLETED; +424 ¦ Routines.at(i)->state = COMPLETED; 425 } 426 } 427 428 :(code) 429 bool has_completed_parent(int routine_index) { 430 for (int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) { -431 if (Routines.at(j)->state == COMPLETED) -432 return true; +431 ¦ if (Routines.at(j)->state == COMPLETED) +432 ¦ ¦ return true; 433 } 434 return false; 435 } @@ -521,12 +522,12 @@ if ('onhashchange' in window) { 458 :(before "End Primitive Recipe Checks") 459 case ROUTINE_STATE: { 460 if (SIZE(inst.ingredients) != 1) { -461 raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); -462 break; +461 ¦ raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +462 ¦ break; 463 } 464 if (!is_mu_number(inst.ingredients.at(0))) { -465 raise << maybe(get(Recipe, r).name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); -466 break; +465 ¦ raise << maybe(get(Recipe, r).name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +466 ¦ break; 467 } 468 break; 469 } @@ -535,10 +536,10 @@ if ('onhashchange' in window) { 472 int id = ingredients.at(0).at(0); 473 int result = -1; 474 for (int i = 0; i < SIZE(Routines); ++i) { -475 if (Routines.at(i)->id == id) { -476 result = Routines.at(i)->state; -477 break; -478 } +475 ¦ if (Routines.at(i)->id == id) { +476 ¦ ¦ result = Routines.at(i)->state; +477 ¦ ¦ break; +478 ¦ } 479 } 480 products.resize(1); 481 products.at(0).push_back(result); @@ -554,12 +555,12 @@ if ('onhashchange' in window) { 491 :(before "End Primitive Recipe Checks") 492 case STOP: { 493 if (SIZE(inst.ingredients) != 1) { -494 raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); -495 break; +494 ¦ raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +495 ¦ break; 496 } 497 if (!is_mu_number(inst.ingredients.at(0))) { -498 raise << maybe(get(Recipe, r).name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); -499 break; +498 ¦ raise << maybe(get(Recipe, r).name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +499 ¦ break; 500 } 501 break; 502 } @@ -567,10 +568,10 @@ if ('onhashchange' in window) { 504 case STOP: { 505 int id = ingredients.at(0).at(0); 506 for (int i = 0; i < SIZE(Routines); ++i) { -507 if (Routines.at(i)->id == id) { -508 Routines.at(i)->state = COMPLETED; -509 break; -510 } +507 ¦ if (Routines.at(i)->id == id) { +508 ¦ ¦ Routines.at(i)->state = COMPLETED; +509 ¦ ¦ break; +510 ¦ } 511 } 512 break; 513 } @@ -586,7 +587,7 @@ if ('onhashchange' in window) { 523 :(before "End Primitive Recipe Implementations") 524 case _DUMP_ROUTINES: { 525 for (int i = 0; i < SIZE(Routines); ++i) { -526 cerr << i << ": " << Routines.at(i)->id << ' ' << Routines.at(i)->state << ' ' << Routines.at(i)->parent_index << '\n'; +526 ¦ cerr << i << ": " << Routines.at(i)->id << ' ' << Routines.at(i)->state << ' ' << Routines.at(i)->parent_index << '\n'; 527 } 528 break; 529 } @@ -615,12 +616,12 @@ if ('onhashchange' in window) { 552 :(before "End Scheduler State Transitions") 553 if (Current_routine->limit >= 0) { 554 if (Current_routine->limit <= Scheduling_interval) { -555 trace(9999, "schedule") << "discontinuing routine " << Current_routine->id << end(); -556 Current_routine->state = DISCONTINUED; -557 Current_routine->limit = 0; +555 ¦ trace(9999, "schedule") << "discontinuing routine " << Current_routine->id << end(); +556 ¦ Current_routine->state = DISCONTINUED; +557 ¦ Current_routine->limit = 0; 558 } 559 else { -560 Current_routine->limit -= Scheduling_interval; +560 ¦ Current_routine->limit -= Scheduling_interval; 561 } 562 } 563 @@ -634,8 +635,8 @@ if ('onhashchange' in window) { 571 :(code) 572 bool any_routines_with_error() { 573 for (int i = 0; i < SIZE(Routines); ++i) { -574 if (Routines.at(i)->state == DISCONTINUED) -575 return true; +574 ¦ if (Routines.at(i)->state == DISCONTINUED) +575 ¦ ¦ return true; 576 } 577 return false; 578 } @@ -652,16 +653,16 @@ if ('onhashchange' in window) { 589 :(before "End Primitive Recipe Checks") 590 case LIMIT_TIME: { 591 if (SIZE(inst.ingredients) != 2) { -592 raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); -593 break; +592 ¦ raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); +593 ¦ break; 594 } 595 if (!is_mu_number(inst.ingredients.at(0))) { -596 raise << maybe(get(Recipe, r).name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); -597 break; +596 ¦ raise << maybe(get(Recipe, r).name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +597 ¦ break; 598 } 599 if (!is_mu_number(inst.ingredients.at(1))) { -600 raise << maybe(get(Recipe, r).name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); -601 break; +600 ¦ raise << maybe(get(Recipe, r).name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +601 ¦ break; 602 } 603 break; 604 } @@ -669,10 +670,10 @@ if ('onhashchange' in window) { 606 case LIMIT_TIME: { 607 int id = ingredients.at(0).at(0); 608 for (int i = 0; i < SIZE(Routines); ++i) { -609 if (Routines.at(i)->id == id) { -610 Routines.at(i)->limit = ingredients.at(1).at(0); -611 break; -612 } +609 ¦ if (Routines.at(i)->id == id) { +610 ¦ ¦ Routines.at(i)->limit = ingredients.at(1).at(0); +611 ¦ ¦ break; +612 ¦ } 613 } 614 break; 615 } @@ -690,12 +691,12 @@ if ('onhashchange' in window) { 627 :(before "End Primitive Recipe Checks") 628 case NUMBER_OF_INSTRUCTIONS: { 629 if (SIZE(inst.ingredients) != 1) { -630 raise << maybe(get(Recipe, r).name) << "'number-of-instructions' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); -631 break; +630 ¦ raise << maybe(get(Recipe, r).name) << "'number-of-instructions' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +631 ¦ break; 632 } 633 if (!is_mu_number(inst.ingredients.at(0))) { -634 raise << maybe(get(Recipe, r).name) << "first ingredient of 'number-of-instructions' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); -635 break; +634 ¦ raise << maybe(get(Recipe, r).name) << "first ingredient of 'number-of-instructions' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +635 ¦ break; 636 } 637 break; 638 } @@ -704,10 +705,10 @@ if ('onhashchange' in window) { 641 int id = ingredients.at(0).at(0); 642 int result = -1; 643 for (int i = 0; i < SIZE(Routines); ++i) { -644 if (Routines.at(i)->id == id) { -645 result = Routines.at(i)->instructions_run; -646 break; -647 } +644 ¦ if (Routines.at(i)->id == id) { +645 ¦ ¦ result = Routines.at(i)->instructions_run; +646 ¦ ¦ break; +647 ¦ } 648 } 649 products.resize(1); 650 products.at(0).push_back(result); @@ -718,7 +719,7 @@ if ('onhashchange' in window) { 655 def f1 [ 656 10:num/child-id <- start-running f2 657 { -658 loop-unless 20:num +658 ¦ loop-unless 20:num 659 } 660 11:num <- number-of-instructions 10:num 661 ] @@ -736,7 +737,7 @@ if ('onhashchange' in window) { 673 def f1 [ 674 10:num/child-id <- start-running f2 675 { -676 loop-unless 20:num +676 ¦ loop-unless 20:num 677 } 678 11:num <- number-of-instructions 10:num 679 ] @@ -759,7 +760,7 @@ if ('onhashchange' in window) { 696 1:&:num/raw <- new number:type 697 # wait for f2 to complete 698 { -699 loop-unless 4:num/raw +699 ¦ loop-unless 4:num/raw 700 } 701 ] 702 def f2 [ -- cgit 1.4.1-2-gfad0