int Main( int argc , char ** argv ) { int policy; int quantum; int id1, id2, id3; /* ID of child process */ if (argc == 3) { if (!strcmp(argv[1], "rr")) { policy = SCHEDPOLICY_RR; } else if (!strcmp(argv[1], "mlf")) { policy = SCHEDPOLICY_MF; } else { Printf("usage: %s [rr|mlf] <quantum>\n", argv[0]); Exit(); } quantum = atoi(argv[2]); Set_Scheduling_Policy(policy, quantum); } else { Printf("usage: %s [rr|mlf] <quantum>\n", argv[0]); Exit(); } id3 = Spawn_Program ( "/c/sched3.exe" ) ; id1 = Spawn_Program ( "/c/sched1.exe" ) ; id2 = Spawn_Program ( "/c/sched2.exe" ) ; Wait(id1); Wait(id2); Wait(id3); Printf("\n"); return 0; }
int Main( int argc , char ** argv ) { int policy; int start; int elapsed; int quantum; int scr_sem; /* sid of screen semaphore */ int id1, id2, id3; /* ID of child process */ if (argc == 3) { if (!strcmp(argv[1], "rr")) { policy = SCHEDPOLICY_RR; } else if (!strcmp(argv[1], "mlf")) { policy = SCHEDPOLICY_MF; } else { Printf("usage: %s [rr|mlf] <quantum>\n", argv[0]); Exit(); } quantum = atoi(argv[2]); Set_Scheduling_Policy(policy, quantum); } else { Printf("usage: %s [rr|mlf] <quantum>\n", argv[0]); Exit(); } start = Get_Time(); scr_sem = Init_Semaphore ( "screen" , 1 ) ; P ( scr_sem ) ; Printf ("************* Start Workload Generator *********\n"); V ( scr_sem ) ; id1 = Spawn_Program ( "/c/long.exe" ) ; P ( scr_sem ) ; Printf ("Process Long has been created with ID = %d\n",id1); V ( scr_sem ) ; id2 = Spawn_Program ( "/c/ping.exe" ) ; P ( scr_sem ) ; Printf ("Process Ping has been created with ID = %d\n",id2); V ( scr_sem ) ; id3 = Spawn_Program ( "/c/pong.exe" ) ; P ( scr_sem ) ; Printf ("Process Pong has been created with ID = %d\n",id3); V ( scr_sem ) ; Wait(id1); Wait(id2); Wait(id3); elapsed = Get_Time() - start; Printf ("\nTests Completed at %d\n", elapsed) ; return 0; }
int main(int argc, char **argv) { int policy = -1; int start; int elapsed; int scr_sem; /* sid of screen semaphore */ int id1, id2, id3; /* ID of child process */ if(argc == 2) { if(!strcmp(argv[1], "rr")) { policy = 0; } else if(!strcmp(argv[1], "mys")) { policy = 1; } else { Print("usage: %s [rr|mys]\n", argv[0]); Exit(1); } Set_Scheduling_Policy(policy, 20); } else { Print("usage: %s [rr|mys]\n", argv[0]); Exit(1); } start = Get_Time_Of_Day(); scr_sem = Open_Semaphore("screen", 1); P(scr_sem); Print("************* Start Workload Generator *********\n"); V(scr_sem); id1 = Spawn_Program("/c/long.exe", "/c/long.exe", 0); P(scr_sem); Print("Process Long has been created with ID = %d\n", id1); V(scr_sem); id2 = Spawn_Program("/c/long.exe", "/c/long.exe", 0); P(scr_sem); Print("Process Long #1 has been created with ID = %d\n", id2); V(scr_sem); #ifdef notdef id2 = Spawn_Program("/c/ping.exe", "/c/ping.exe", 0); P(scr_sem); Print("Process Ping has been created with ID = %d\n", id2); V(scr_sem); id3 = Spawn_Program("/c/pong.exe", "/c/pong.exe", 0); P(scr_sem); Print("Process Pong has been created with ID = %d\n", id3); V(scr_sem); #endif Wait(id1); Wait(id2); // Wait(id3); elapsed = Get_Time_Of_Day() - start; Print("\nTests Completed at %d\n", elapsed); return 0; }