Question: ******** U S E C C O D E ******** AND PLEASE DONT FORGET TO SOLVE >>>>>>>>>>> 4. Preemptive Priority (PP) C O D E
******** U S E C C O D E ********
AND PLEASE DONT FORGET TO SOLVE >>>>>>>>>>>4. Preemptive Priority (PP) C O D E
Project Objectives:
This programming project is to simulate a few CPU scheduling policies discussed in the class. You will write a program to implement a simulator with different scheduling algorithms. The simulator selects a task to run from ready queue based on the scheduling algorithm. Since the project intends to simulate a CPU scheduler, so it does not require any actual process creation or execution. When a task is scheduled, the simulator will simply print out what task is selected to run at a time. It outputs the way similar to Gantt chart style.
Project Descriptions:
The selected scheduling algorithms to implement in this project are
1. First Come First Serve (FCFS).
2. Round Robin (RR).
3. Shortest Remaining Time First (SRTF).
4. Preemptive Priority (PP)
Task Information
The process information will be read from an input file. The format is pid arrival_time burst_time priority All of fields are integer type where pid is a unique numeric process ID arrival_time is the time when the task arrives in the unit of milliseconds burst_time the is the CPU time requested by a task, in the unit of milliseconds priority number (integer) is associated with each process
Command-line Usage and Examples Usage
proj input_file [FCFS|RR|SRTF|PP] [time_quantum]
where input_file is the file name with process information. FCFS, RR, SRTF and PP are names of scheduling algorithms. The time_quantum only applies to RR. FCFS is nonpreemptive while RR, SRTF and PP are all preemptive. The last argument is needed only for RR.
Design
The simulator first reads process information from input file and stores all data in a data structure. Then it starts simulating one scheduling algorithm in a time-driven manner. At each time unit (or slot), it adds any newly arrived task(s) into the ready queue and calls a specific scheduler algorithm in order to select appropriate task from ready queue. When a task is chosen to run, the simulator prints out a message indicating what process ID is chosen to execute for this time slot. If no process is running (i.e. empty ready queue), it prints out an idle message. Before advancing to the next time unit, the simulator should update all necessary changes in process and ready queue status.
Sample Inputs and Outputs
Sample input files and expected outputs are shown in Appendix. You can use it to verify your results. Notice that these input files are not for testing and grading your program.
Requirements: The project requires to simulate FCFS, RR, SRTF, and PP scheduling for given processes and to compute the average waiting time, response time, turnaround time and overall CPU usage.
1. Implement scheduling algorithm for FCFS, RR, SRTF, and PP. The program should schedule tasks and print progress of task every unit time (millisecond) as shown in sample outputs.
2. Print statistical information. As soon as all tasks are completed, the program should compute and print
a. average waiting time,
b. average response time
c. average turnaround time
d. overall CPU usage.
Suggested Methodology
1. Implement one scheduling algorithm at each step
2. You can use circular linked list as a queue structure
3. You can use a data structure similar to PCB for each task, though it will be much simpler
Submission
1. All source code files
2. A readme file that briefly describes each file, how to compile the file(s), and how to run the file.



The image is just an example on how the simple GUI should be implemented, the code can be done without this specific GUI. Thank you
more input. 1 1 0 10 2 0 335 7 5 10 6 6 10 7 *** proj2 Usage: proj2 input_file FCFSRRI SRJF quantum) proj2 input. 1 FCFS Schdeuling algorithm: FCFS Total 6 tasks are read from "input. 1". press 'enter' to start.. process 1 is running 1> process 1 is running 2> process 1 is running 3> process 1 is running 4> process 1 is running 5> process 1 is running 6> process 1 is running 7> process 1 is running 8> process 1 is running 9> process 1 is running 10> process 1 is finished...... 10> process 2 18 running 11> process 2 is running 12> process 2 is running 13> process 2 is running 14> process 2 is running 15> process 2 is running 16> process 2 is running 17> process 2 is running 18> process 2 is running 19> process 2 is finished... 19> process 3 is running 20> process 3 is running 21> process 3 is running 22> process 3 is running 23> process 3 is running 24> process 3 is finished..... 24> process 4 is running 25> process 4 is running 26> process 4 is running 27> process 4 is running 28> process 4 is finished..... 28> process 5 is running 29> process 5 is running 30> process 5 is running 31> process 5 is running 32> process 5 is running 33> process 5 is running 34> process 5 is finished..... 34 process 6 is running 35> process 6 is running 36> process 6 is running 37> process 6 is running 38> process 6 is running 39> process 6 is running 40> process 6 is running 41> process 6 is finished.... 41> All processes finish Avarage cpu usage : 100.00 Avarage waiting time 14.17 Avarage response time 14.17 Avarage turnaround time: 21.00 + proj2 input. 1 RR 2 Sehdeuling algorithm: RR Total 6 tasks are read from input.1". press 'enter' to start... csystem time process 1 is running 2> process 2 is running 3> process 2 is running 4> process 1 is running 5> process 1 is running 6> process 3 is running 7> process 3 is running 8> process 2 is running 9> process 2 is running 10> process 1 is running 11> process 1 is running 12> process 4 is running 13> process 4 is running 14 process 3 is running 15> process 3 is running 16> process 5 is running 17> process 5 is running 18> process 6 is running 19> process 6 is running 20> process 2 is running 21> process 2 is running 22> process 1 is running 23> process 1 is running 24> process 4 is running 25> process 4 is running 26> process 4 is finished... 26> process 3 is running 27 process 3 is finished... 27> process 5 is running 28> process 5 is running 29> process 6 is running 30> process 6 is running 31> process 2 is running 32> process 2 is running 33> process 1 is running 34> process 1 is running 35> process 1 is finished... 35> process 5 is running 36> process 5 is running 37 process 5 is finished...... 37> process 6 is running 38> process 6 is running 39> process 2 is running 40> process 2 is finished... 40> process 6 is running 41> process 6 is finished. 41> All processes finish Avarage cpu usage : 100.00 % Avarage waiting time : 22.50 Avarage response time 14.00 Avarage turnaround time: 29.33 proj2 input. 1 SRTE Schdeuling algorithm: SRTE Total 6 tasks are read from "input.l". press 'enter' to start... process 2 is running 2> process 2 is running 3> process 3 is running 4> process 3 is running 5> process 3 is running 6> process 3 is running 7> process 3 is running 8> process 3 is finished..... 8> process 4 is running 9> process 4 is running 10> process 4 is running 11> process 4 is running 12> process 4 is finished..... 12> process 2 is running 13> process 2 is running 14> process 2 is running 15> process 2 is running 16> process 2 is running 17> process 2 is running 18> process 2 is finished..... 1R> process 5 is running 19> process 5 is running 20> process 5 is running 21> process 5 is running 22> process 5 is running 23> process 5 is running 24> process 5 is finished.... 24> process 6 is running 25> process 6 is running 26> process 6 is running 27> process 6 is running 28> process 6 is running 29> process 6 is running 30> process 6 is running 31> process 6 is finished... 31> process 1 is running 32> process 1 is running 33> process 1 is running 34> process 1 is running 35> process 1 is running 36> process 1 is running 37> process 1 is running 38> process 1 is running 39> process 1 is running 40> process 1 is running 41> process 1 is finished.. 41> All processes Finish Avarage cpu usage : 100.00 Avarage waiting time : 10.50 Avarage response time : 9.00 Avarage turnaround time: 17.33 more input. 1 1 0 10 2 0 335 7 5 10 6 6 10 7 *** proj2 Usage: proj2 input_file FCFSRRI SRJF quantum) proj2 input. 1 FCFS Schdeuling algorithm: FCFS Total 6 tasks are read from "input. 1". press 'enter' to start.. process 1 is running 1> process 1 is running 2> process 1 is running 3> process 1 is running 4> process 1 is running 5> process 1 is running 6> process 1 is running 7> process 1 is running 8> process 1 is running 9> process 1 is running 10> process 1 is finished...... 10> process 2 18 running 11> process 2 is running 12> process 2 is running 13> process 2 is running 14> process 2 is running 15> process 2 is running 16> process 2 is running 17> process 2 is running 18> process 2 is running 19> process 2 is finished... 19> process 3 is running 20> process 3 is running 21> process 3 is running 22> process 3 is running 23> process 3 is running 24> process 3 is finished..... 24> process 4 is running 25> process 4 is running 26> process 4 is running 27> process 4 is running 28> process 4 is finished..... 28> process 5 is running 29> process 5 is running 30> process 5 is running 31> process 5 is running 32> process 5 is running 33> process 5 is running 34> process 5 is finished..... 34 process 6 is running 35> process 6 is running 36> process 6 is running 37> process 6 is running 38> process 6 is running 39> process 6 is running 40> process 6 is running 41> process 6 is finished.... 41> All processes finish Avarage cpu usage : 100.00 Avarage waiting time 14.17 Avarage response time 14.17 Avarage turnaround time: 21.00 + proj2 input. 1 RR 2 Sehdeuling algorithm: RR Total 6 tasks are read from input.1". press 'enter' to start... csystem time process 1 is running 2> process 2 is running 3> process 2 is running 4> process 1 is running 5> process 1 is running 6> process 3 is running 7> process 3 is running 8> process 2 is running 9> process 2 is running 10> process 1 is running 11> process 1 is running 12> process 4 is running 13> process 4 is running 14 process 3 is running 15> process 3 is running 16> process 5 is running 17> process 5 is running 18> process 6 is running 19> process 6 is running 20> process 2 is running 21> process 2 is running 22> process 1 is running 23> process 1 is running 24> process 4 is running 25> process 4 is running 26> process 4 is finished... 26> process 3 is running 27 process 3 is finished... 27> process 5 is running 28> process 5 is running 29> process 6 is running 30> process 6 is running 31> process 2 is running 32> process 2 is running 33> process 1 is running 34> process 1 is running 35> process 1 is finished... 35> process 5 is running 36> process 5 is running 37 process 5 is finished...... 37> process 6 is running 38> process 6 is running 39> process 2 is running 40> process 2 is finished... 40> process 6 is running 41> process 6 is finished. 41> All processes finish Avarage cpu usage : 100.00 % Avarage waiting time : 22.50 Avarage response time 14.00 Avarage turnaround time: 29.33 proj2 input. 1 SRTE Schdeuling algorithm: SRTE Total 6 tasks are read from "input.l". press 'enter' to start... process 2 is running 2> process 2 is running 3> process 3 is running 4> process 3 is running 5> process 3 is running 6> process 3 is running 7> process 3 is running 8> process 3 is finished..... 8> process 4 is running 9> process 4 is running 10> process 4 is running 11> process 4 is running 12> process 4 is finished..... 12> process 2 is running 13> process 2 is running 14> process 2 is running 15> process 2 is running 16> process 2 is running 17> process 2 is running 18> process 2 is finished..... 1R> process 5 is running 19> process 5 is running 20> process 5 is running 21> process 5 is running 22> process 5 is running 23> process 5 is running 24> process 5 is finished.... 24> process 6 is running 25> process 6 is running 26> process 6 is running 27> process 6 is running 28> process 6 is running 29> process 6 is running 30> process 6 is running 31> process 6 is finished... 31> process 1 is running 32> process 1 is running 33> process 1 is running 34> process 1 is running 35> process 1 is running 36> process 1 is running 37> process 1 is running 38> process 1 is running 39> process 1 is running 40> process 1 is running 41> process 1 is finished.. 41> All processes Finish Avarage cpu usage : 100.00 Avarage waiting time : 10.50 Avarage response time : 9.00 Avarage turnaround time: 17.33