int main(int argc, char* argv[]) { SharedVariable v; int runningTimeInSec = 10; if (argc == 2) { runningTimeInSec = atoi(argv[1]); } if (wiringPiSetup() == -1) { printf("Failed to setup wiringPi."); return 1; } printf("start"); // Initialize for the interfaces provided signal(SIGINT, signal_handler); init_deferred_buffer(1024*1024); // 1MB init_userspace_governor(); init_workload(); printf("stop"); // Initializers that you need to implement init_shared_variable(&v); init_sensors(&v); learn_workloads(&v); printf("Init scheduler start"); // Init scheduler int aliveTasks[NUM_TASKS]; init_scheduler(runningTimeInSec); set_by_max_freq(); // reset to the max freq printf("Init scheduler stop"); printDBG("Start Scheduling with %d threads\n", NUM_TASKS); TaskSelection sel; long long idleTime; while (v.bProgramExit != 1) { // 1. Prepare tasks idleTime = prepare_tasks(aliveTasks, &v); if (idleTime < 0) break; // 2. Select a process: You need to implement. sel = select_task(&v, aliveTasks, idleTime); if (sel.task < 0) break; // 3. Run the selected task execute_task(sel); } finish_workload(); release_buffer(fileno(stdout)); printf("Scheduler program finished.\n"); return 0; }
int select_action(int sel1, int sel2) { switch(sel1) { case 1 : { switch(sel2) { case 2: { select_task(); break; } case 4: { tcu_remove_form(&screen_form); if (task_elements(level_indicator)==0) { tcu_display_form(&screen_form,1,2); } break; } } break; } case 4 : { switch(sel2) { case 2 : { handle_form("sc_game"); break; } } break; } case 5 : { switch(sel2) { case 2 : { handle_form("sc_user"); break; } } break; } } }
int main(void) { /* * Inicializamos los componentes y periféricos necesarios */ inicializacion(); /* * Superloop. */ while(1) { a=array[m]; select_task(); } }
void CALifeMonsterBrain::update () { #if 0//def DEBUG if (!Level().MapManager().HasMapLocation("debug_stalker",object().ID)) { CMapLocation *map_location = Level().MapManager().AddMapLocation( "debug_stalker", object().ID ); map_location->SetHint (object().name_replace()); } #endif select_task (); if (object().m_smart_terrain_id != 0xffff) process_task (); else default_behaviour (); movement().update (); }