From a654e4ecace2d506d1b10f1dde2c287ebe84ef37 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 26 Mar 2016 23:59:59 -0700 Subject: 2812 --- html/062scheduler.cc.html | 107 +++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 49 deletions(-) (limited to 'html/062scheduler.cc.html') diff --git a/html/062scheduler.cc.html b/html/062scheduler.cc.html index a81f8841..93810126 100644 --- a/html/062scheduler.cc.html +++ b/html/062scheduler.cc.html @@ -3,29 +3,37 @@ Mu - 062scheduler.cc - - + + - + + + + -
+
 //: Run a second routine concurrently using 'start-running', without any
 //: guarantees on how the operations in each are interleaved with each other.
 
@@ -46,9 +54,9 @@ def f2 [
 //: first, add a deadline to run(routine)
 //: these changes are ugly and brittle; just close your nose and get through the next few lines
 :(replace "void run_current_routine()")
-void run_current_routine(long long int time_slice)
-:(replace "while (!Current_routine->completed())" following "void run_current_routine(long long int time_slice)")
-long long int ninstrs = 0;
+void run_current_routine(int time_slice)
+:(replace "while (!Current_routine->completed())" following "void run_current_routine(int time_slice)")
+int ninstrs = 0;
 while (Current_routine->state == RUNNING && ninstrs < time_slice)
 :(after "Running One Instruction")
 ninstrs++;
@@ -68,8 +76,8 @@ state = RUNNING;
 
 :(before "End Globals")
 vector<routine*> Routines;
-long long int Current_routine_index = 0;
-long long int Scheduling_interval = 500;
+int Current_routine_index = 0;
+int Scheduling_interval = 500;
 :(before "End Setup")
 Scheduling_interval = 500;
 Routines.clear();
@@ -99,7 +107,7 @@ Routines.clear();
 }
 
 bool all_routines_done() {
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  for (int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->state == RUNNING) {
       return false;
     }
@@ -111,7 +119,7 @@ Routines.clear();
 void skip_to_next_routine() {
   assert(!Routines.empty());
   assert(Current_routine_index < SIZE(Routines));
-  for (long long int i = (Current_routine_index+1)%SIZE(Routines);  i != Current_routine_index;  i = (i+1)%SIZE(Routines)) {
+  for (int i = (Current_routine_index+1)%SIZE(Routines);  i != Current_routine_index;  i = (i+1)%SIZE(Routines)) {
     if (Routines.at(i)->state == RUNNING) {
       Current_routine_index = i;
       Current_routine = Routines.at(i);
@@ -131,7 +139,7 @@ string current_routine_label() }
 
 :(before "End Teardown")
-for (long long int i = 0; i < SIZE(Routines); ++i)
+for (int i = 0; i < SIZE(Routines); ++i)
   delete Routines.at(i);
 Routines.clear();
 Current_routine = NULL;
@@ -145,7 +153,7 @@ Current_routine = NULL;// pass in commandline args as ingredients to main
   // todo: test this
   Current_routine = main_routine;
-  for (long long int i = 1; i < argc; ++i) {
+  for (int i = 1; i < argc; ++i) {
     vector<double> arg;
     arg.push_back(new_mu_string(argv[i]));
     current_call().ingredient_atoms.push_back(arg);
@@ -158,9 +166,9 @@ Current_routine = NULL;//: 'start-running' will return a unique id for the routine that was created.
 //: routine id is a number, but don't do any arithmetic on it
 :(before "End routine Fields")
-long long int id;
+int id;
 :(before "End Globals")
-long long int Next_routine_id = 1;
+int Next_routine_id = 1;
 :(before "End Setup")
 Next_routine_id = 1;
 :(before "End routine Constructor")
@@ -170,7 +178,7 @@ Next_routine_id++;
 //: routines save the routine that spawned them
 :(before "End routine Fields")
 // todo: really should be routine_id, but that's less efficient.
-long long int parent_index;  // only < 0 if there's no parent_index
+int parent_index;  // only < 0 if there's no parent_index
 :(before "End routine Constructor")
 parent_index = -1;
 
@@ -195,7 +203,7 @@ put(Recipe_ordinal,new routine(ingredients.at(0).at(0));
   new_routine->parent_index = Current_routine_index;
   // populate ingredients
-  for (long long int i = 1; i < SIZE(current_instruction().ingredients); ++i) {
+  for (int i = 1; i < SIZE(current_instruction().ingredients); ++i) {
     new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i));
     reagent ingredient = current_instruction().ingredients.at(i);
     canonize_type(ingredient);
@@ -214,9 +222,9 @@ def f1 [
   2:number <- copy 0
 ]
 +schedule: f1
-+run: 1:number <- copy 0
++run: {1: "number"} <- copy {0: "literal"}
 +schedule: f1
-+run: 2:number <- copy 0
++run: {2: "number"} <- copy {0: "literal"}
 
 :(scenario scheduler_interleaves_routines)
 % Scheduling_interval = 1;
@@ -230,15 +238,15 @@ def f2 [
   4:number <- copy 0
 ]
 +schedule: f1
-+run: start-running f2
++run: start-running {f2: "recipe-literal"}
 +schedule: f2
-+run: 3:number <- copy 0
++run: {3: "number"} <- copy {0: "literal"}
 +schedule: f1
-+run: 1:number <- copy 0
++run: {1: "number"} <- copy {0: "literal"}
 +schedule: f2
-+run: 4:number <- copy 0
++run: {4: "number"} <- copy {0: "literal"}
 +schedule: f1
-+run: 2:number <- copy 0
++run: {2: "number"} <- copy {0: "literal"}
 
 :(scenario start_running_takes_ingredients)
 def f1 [
@@ -330,7 +338,7 @@ def f1 [
 -schedule: f1
 
 :(before "End Scheduler Cleanup")
-for (long long int i = 0; i < SIZE(Routines); ++i) {
+for (int i = 0; i < SIZE(Routines); ++i) {
   if (Routines.at(i)->state == COMPLETED) continue;
   if (Routines.at(i)->parent_index < 0) continue;  // root thread
   if (has_completed_parent(i)) {
@@ -339,8 +347,8 @@ def f1 [
 }
 
 :(code)
-bool has_completed_parent(long long int routine_index) {
-  for (long long int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) {
+bool has_completed_parent(int routine_index) {
+  for (int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) {
     if (Routines.at(j)->state == COMPLETED)
       return true;
   }
@@ -371,7 +379,7 @@ put(Recipe_ordinal,:(before "End Primitive Recipe Checks")
 case ROUTINE_STATE: {
   if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got " << to_string(inst) << '\n' << end();
+    raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end();
     break;
   }
   if (!is_mu_number(inst.ingredients.at(0))) {
@@ -382,9 +390,9 @@ put(Recipe_ordinal,}
 :(before "End Primitive Recipe Implementations")
 case ROUTINE_STATE: {
-  long long int id = ingredients.at(0).at(0);
-  long long int result = -1;
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  int id = ingredients.at(0).at(0);
+  int result = -1;
+  for (int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
       result = Routines.at(i)->state;
       break;
@@ -404,7 +412,7 @@ put(Recipe_ordinal,:(before "End Primitive Recipe Checks")
 case RESTART: {
   if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got " << to_string(inst) << '\n' << end();
+    raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end();
     break;
   }
   if (!is_mu_number(inst.ingredients.at(0))) {
@@ -415,8 +423,8 @@ put(Recipe_ordinal,}
 :(before "End Primitive Recipe Implementations")
 case RESTART: {
-  long long int id = ingredients.at(0).at(0);
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  int id = ingredients.at(0).at(0);
+  for (int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
       Routines.at(i)->state = RUNNING;
       break;
@@ -432,7 +440,7 @@ put(Recipe_ordinal,:(before "End Primitive Recipe Checks")
 case STOP: {
   if (SIZE(inst.ingredients) != 1) {
-    raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got " << to_string(inst) << '\n' << end();
+    raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end();
     break;
   }
   if (!is_mu_number(inst.ingredients.at(0))) {
@@ -443,8 +451,8 @@ put(Recipe_ordinal,}
 :(before "End Primitive Recipe Implementations")
 case STOP: {
-  long long int id = ingredients.at(0).at(0);
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  int id = ingredients.at(0).at(0);
+  for (int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
       Routines.at(i)->state = COMPLETED;
       break;
@@ -463,7 +471,7 @@ put(Recipe_ordinal,}
 :(before "End Primitive Recipe Implementations")
 case _DUMP_ROUTINES: {
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  for (int i = 0; i < SIZE(Routines); ++i) {
     cerr << i << ": " << Routines.at(i)->id << ' ' << Routines.at(i)->state << ' ' << Routines.at(i)->parent_index << '\n';
   }
   break;
@@ -503,7 +511,7 @@ DISCONTINUED,
 }
 
 :(before "End routine Fields")
-long long int limit;
+int limit;
 :(before "End routine Constructor")
 limit = -1;  /* no limit */
 
@@ -514,7 +522,7 @@ put(Recipe_ordinal,:(before "End Primitive Recipe Checks")
 case LIMIT_TIME: {
   if (SIZE(inst.ingredients) != 2) {
-    raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got " << to_string(inst) << '\n' << end();
+    raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got " << to_original_string(inst) << '\n' << end();
     break;
   }
   if (!is_mu_number(inst.ingredients.at(0))) {
@@ -529,8 +537,8 @@ put(Recipe_ordinal,}
 :(before "End Primitive Recipe Implementations")
 case LIMIT_TIME: {
-  long long int id = ingredients.at(0).at(0);
-  for (long long int i = 0; i < SIZE(Routines); ++i) {
+  int id = ingredients.at(0).at(0);
+  for (int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
       Routines.at(i)->limit = ingredients.at(1).at(0);
       break;
@@ -561,3 +569,4 @@ def f2 [
 
+ -- cgit 1.4.1-2-gfad0