int main(int argc, char* argv[]) { // Initialize SharedVariable v; if (wiringPiSetup() == -1) { printf("Failed to setup wiringPi."); return 1; } init_shared_variable(&v); init_sensors(&v); pthread_t t_ultrasound, t_irled, t_linefollow,t_keypress,t_socket; // Create sensing threads thread_create(ultrasound); thread_create(irled); thread_create(linefollow); thread_create(keypress); thread_create(socket); // Wait until all threads finish thread_join(socket); thread_join(ultrasound); thread_join(irled); thread_join(linefollow); thread_join(keypress); return 0; }
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 main(int argc, char* argv[]) { // Initialize SharedVariable v; if (wiringPiSetup() == -1) { printf("Failed to setup wiringPi."); return 1; } init_shared_variable(&v); init_sensors(&v); pthread_t t_button, t_twocolor, t_temp, t_track, t_shock, t_rgbcolor, t_aled, t_buzzer; while (v.bProgramExit != 1) { // Create sensing threads thread_create(button); thread_create(twocolor); thread_create(temp); thread_create(track); thread_create(shock); thread_create(rgbcolor); thread_create(aled); thread_create(buzzer); // Wait until all threads finish thread_join(button); thread_join(twocolor); thread_join(temp); thread_join(track); thread_join(shock); thread_join(rgbcolor); thread_join(aled); thread_join(buzzer); delay(1); } printf("Program finished.\n"); return 0; }