Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CPU Scheduling Simulation for scheduling algorithms FCFS,SRTF,RR using C program. Assignment 2: CPU Scheduling Simulation CSC 139 Operating System Principles - Spring 2019 Posted on

CPU Scheduling Simulation for scheduling algorithms FCFS,SRTF,RR using C program.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Assignment 2: CPU Scheduling Simulation CSC 139 Operating System Principles - Spring 2019 Posted on March 6, due on March 17 (11:59 pm) 1 Objectives This programming project is to simulate a few CPU scheduling policies discussed in the class. You will write a C 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. 2 Description The selected scheduling algorithms to implement in this project are 1) First Come First Serve (FCFS), 2) Round Robin (RR), and 3) Shortest Remaining Time First (SRTF). The detailed algorithms are already described in class slides and textbook Chapter 5 2.1 Task Information The task information wil be read from an input file. The format is pid arrival.time burst.time 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 The time unit for arrival.time, burst.time and interval is millisecond. 2.2 Command-line Usage and Examples Usage: proj2 input.file [FCFSIRRISRTF] [time.quant um] where input-file is the file name with task information. FCFS, RR, and SRIF are names of scheduling algorithms. The time quantum only applies to RR. FCFS is nonpreemptive, while RR and SRTF are all preemptive. The last argument is needed only for RR. (See following table for more examples) Examples proj2 input.1 ECES proj2 input.1 RR 2 - tar the files: FCTS scheduling with the data file "input.1 Simulate RR scheduling with time quantum 2 milliscconds (4d parameter is reuired venquantum 1 millen with the data file "input.1" Simulate SRTF scheduling with the data file" inpu. 1" Verify the files have been placed in a tar file: ta--tvf ECS username >-a5qmt2.tar - Compress the liles using grip: qzip -asqmt 2. tar.FZ proj2 input.1 SRTE 2.3 Sample Inputs and Outputs Sample input files and expected outputs are shown in Appendix. You can use it to verify your results 3 Requirements The project requires to simulate Ri S RR, and SRTI. scheduling for given tasks and to compute the average waiting timc, response time, tumaround time and overall CPU usage. You can find their detinitions in texthook 1. Implement scheduling algorithm for FCFS, RR. and SRTF. 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 1 average wailing me 2) average response lime, 3) average lurnaround me and 4) overall CPU usage Note: if you use static array to implement ready queue siructure, you can assume the maximum queue length is 20. 4 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 siructure similar to PCBach lask, though il will be much simpler 5 Deliverables Make sure your code can be compiled and work on Athena server correctly. Upload to Canvas the following: All source codes/liles thal you have aakled/modilied and the demonstralive resulls, A README.TXT file that briefly describes cach file, ow to compile the file(s). and how to run the file. These files should be placed in a directory called cECS username asgmt2. Use ar command lo place a he liles i a single lile called -asgmt2.tar Assuming you are in the directory -asgmt 2 do the following: - Gio the parent directory: ad. Appendix: about input file and output information by CPU scheduling simulato for FCFS, RR, and SRTF more input 3 16 6 09 ro Usage: proj2 input_file FCFS IRR ISRJF Iquantum] % proj2 input .1 FCFS Schdeuling algorithm: FCFS Total 6 tasks are read from "input.1". press 'enter' to start... process1 is running 1 is running 1 is running 1 is running 1 is running 1 is running time 1> process 2> process 3> process 4> process 5> process process 1 is running process 8> process 9> process 1 is running 1 is running 1 is running process process process process process process process process process system time18> process process process process process process 3 is running process process process process process process process process process5 is running process process process5 is running process5 is running system time34> process process process process process 6 is running process process process system time 41> process system time41> All processes finish 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is finished... 3 is running 3 is running 3 is running 3 is running 4 is running 4 is running 4 is running is running 5 is running 5 is running 5 is finished...._.. 6 is running 6 is running 6 is running 6 is running 6 is running 6 is running 6 is finished. . .-..... 100.00 Avarage waiting tin : 14.17 Avarag respons" t ine 14, 17 Avar age turnazound tin: 21.00 eyetem timeocess2 15 running proj2 input RR Scldeuling algozitha: RR Tot1 6 t5sk5 are read tron "1npot. 1". pre55 "enter, to tart. eyetem tie10 pcocess1s running cayatatina I> process 1 is running syaten Eime3 proceas 2 ia running systen tine rocess 1s running syaten Eine5 proceas ia running syaten tie proce 3 ia running Cayate 12 peoces 2 is unning eyeten tie1pcocess 2 1s running Cayate 14> peoces 2 is unning Cayate 15> peoces 2 is unning eyetem tie1 pcocess 2 1s running Cayate 1 peoces 2 is unning syaten Eimeproceas 2 ia running systen tine rocess2 1s running ayaten Eie 10x proceas ia running systen tine 11 process 1s running systen tine 12s procas4 ia running syaten tine 13> proceas4 la running systen tine 14s pro 3i running syaten Eie 15s procea 3 ia running systen tine 1b rocess ayaten Eine 17s procea S ia running systen tine rocess1s running systen tine 19s proca running systen tine 2Urocess 2 1s running systen tine 21s proc 2 ia running systen tine 22rocess 1s running systen tine 23rocess 1s running systen tine 24s procas4 i running systen tine 2process1s running Proce88 4 is finished. systen tine 25 rocess 1s running Prot:88 3 is finished systen tine 2rocess1s running Cayate 18> peoces system tine 192 proce 5 caya terti. 20) procesa iuning 5 i5 running 5 is running Cayat Cayate 22> proces5 i run ing 23> peoces iuning caya terti. 24> peace sa 6 is running yeten tine 2pcocess1s running Cayat 26> peoces is runn ing system tine 2.pcoce 5 is running Cayat t 28 pros is runn ing yten tine 29pocess1s running yeten tine 30pcocess1s running systen tie3cocess 1 1s running Cayat 32 pros is runn ing system tiecocess 1 1s running systent cocess 1 1s running systen tine 29rocess 1s running systen tine ans pros unning systen tine 3ls pro 2 i running systen tine 32rocess 2 1s running Prot:88 l is running systen tine rocess 1s running systent 3cocess 1 1s running systenticocess 1 1s running cgys ten, tine L> ALI process 5 finish. ysten tine 35rocess1s running systen ine 36s proS unning Prnrn88 5 is finished. oysten tine process1s running systen tine 3Rs pros unning ysten tine rocess 2 1s running va-ag waiting tine: 10.50 vaage response ti9.0U ysten tine process 1s running A1 processes finish Avaraqe esponse tine.00 Avarage turnaround tine: 29.33 s pro12 input.2 SRTE sehdnulingignrittin: SRTT Tatal 6 tkxar" rnsd from "input. .. pres enter. tnatart Assignment 2: CPU Scheduling Simulation CSC 139 Operating System Principles - Spring 2019 Posted on March 6, due on March 17 (11:59 pm) 1 Objectives This programming project is to simulate a few CPU scheduling policies discussed in the class. You will write a C 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. 2 Description The selected scheduling algorithms to implement in this project are 1) First Come First Serve (FCFS), 2) Round Robin (RR), and 3) Shortest Remaining Time First (SRTF). The detailed algorithms are already described in class slides and textbook Chapter 5 2.1 Task Information The task information wil be read from an input file. The format is pid arrival.time burst.time 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 The time unit for arrival.time, burst.time and interval is millisecond. 2.2 Command-line Usage and Examples Usage: proj2 input.file [FCFSIRRISRTF] [time.quant um] where input-file is the file name with task information. FCFS, RR, and SRIF are names of scheduling algorithms. The time quantum only applies to RR. FCFS is nonpreemptive, while RR and SRTF are all preemptive. The last argument is needed only for RR. (See following table for more examples) Examples proj2 input.1 ECES proj2 input.1 RR 2 - tar the files: FCTS scheduling with the data file "input.1 Simulate RR scheduling with time quantum 2 milliscconds (4d parameter is reuired venquantum 1 millen with the data file "input.1" Simulate SRTF scheduling with the data file" inpu. 1" Verify the files have been placed in a tar file: ta--tvf ECS username >-a5qmt2.tar - Compress the liles using grip: qzip -asqmt 2. tar.FZ proj2 input.1 SRTE 2.3 Sample Inputs and Outputs Sample input files and expected outputs are shown in Appendix. You can use it to verify your results 3 Requirements The project requires to simulate Ri S RR, and SRTI. scheduling for given tasks and to compute the average waiting timc, response time, tumaround time and overall CPU usage. You can find their detinitions in texthook 1. Implement scheduling algorithm for FCFS, RR. and SRTF. 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 1 average wailing me 2) average response lime, 3) average lurnaround me and 4) overall CPU usage Note: if you use static array to implement ready queue siructure, you can assume the maximum queue length is 20. 4 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 siructure similar to PCBach lask, though il will be much simpler 5 Deliverables Make sure your code can be compiled and work on Athena server correctly. Upload to Canvas the following: All source codes/liles thal you have aakled/modilied and the demonstralive resulls, A README.TXT file that briefly describes cach file, ow to compile the file(s). and how to run the file. These files should be placed in a directory called cECS username asgmt2. Use ar command lo place a he liles i a single lile called -asgmt2.tar Assuming you are in the directory -asgmt 2 do the following: - Gio the parent directory: ad. Appendix: about input file and output information by CPU scheduling simulato for FCFS, RR, and SRTF more input 3 16 6 09 ro Usage: proj2 input_file FCFS IRR ISRJF Iquantum] % proj2 input .1 FCFS Schdeuling algorithm: FCFS Total 6 tasks are read from "input.1". press 'enter' to start... process1 is running 1 is running 1 is running 1 is running 1 is running 1 is running time 1> process 2> process 3> process 4> process 5> process process 1 is running process 8> process 9> process 1 is running 1 is running 1 is running process process process process process process process process process system time18> process process process process process process 3 is running process process process process process process process process process5 is running process process process5 is running process5 is running system time34> process process process process process 6 is running process process process system time 41> process system time41> All processes finish 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is running 2 is finished... 3 is running 3 is running 3 is running 3 is running 4 is running 4 is running 4 is running is running 5 is running 5 is running 5 is finished...._.. 6 is running 6 is running 6 is running 6 is running 6 is running 6 is running 6 is finished. . .-..... 100.00 Avarage waiting tin : 14.17 Avarag respons" t ine 14, 17 Avar age turnazound tin: 21.00 eyetem timeocess2 15 running proj2 input RR Scldeuling algozitha: RR Tot1 6 t5sk5 are read tron "1npot. 1". pre55 "enter, to tart. eyetem tie10 pcocess1s running cayatatina I> process 1 is running syaten Eime3 proceas 2 ia running systen tine rocess 1s running syaten Eine5 proceas ia running syaten tie proce 3 ia running Cayate 12 peoces 2 is unning eyeten tie1pcocess 2 1s running Cayate 14> peoces 2 is unning Cayate 15> peoces 2 is unning eyetem tie1 pcocess 2 1s running Cayate 1 peoces 2 is unning syaten Eimeproceas 2 ia running systen tine rocess2 1s running ayaten Eie 10x proceas ia running systen tine 11 process 1s running systen tine 12s procas4 ia running syaten tine 13> proceas4 la running systen tine 14s pro 3i running syaten Eie 15s procea 3 ia running systen tine 1b rocess ayaten Eine 17s procea S ia running systen tine rocess1s running systen tine 19s proca running systen tine 2Urocess 2 1s running systen tine 21s proc 2 ia running systen tine 22rocess 1s running systen tine 23rocess 1s running systen tine 24s procas4 i running systen tine 2process1s running Proce88 4 is finished. systen tine 25 rocess 1s running Prot:88 3 is finished systen tine 2rocess1s running Cayate 18> peoces system tine 192 proce 5 caya terti. 20) procesa iuning 5 i5 running 5 is running Cayat Cayate 22> proces5 i run ing 23> peoces iuning caya terti. 24> peace sa 6 is running yeten tine 2pcocess1s running Cayat 26> peoces is runn ing system tine 2.pcoce 5 is running Cayat t 28 pros is runn ing yten tine 29pocess1s running yeten tine 30pcocess1s running systen tie3cocess 1 1s running Cayat 32 pros is runn ing system tiecocess 1 1s running systent cocess 1 1s running systen tine 29rocess 1s running systen tine ans pros unning systen tine 3ls pro 2 i running systen tine 32rocess 2 1s running Prot:88 l is running systen tine rocess 1s running systent 3cocess 1 1s running systenticocess 1 1s running cgys ten, tine L> ALI process 5 finish. ysten tine 35rocess1s running systen ine 36s proS unning Prnrn88 5 is finished. oysten tine process1s running systen tine 3Rs pros unning ysten tine rocess 2 1s running va-ag waiting tine: 10.50 vaage response ti9.0U ysten tine process 1s running A1 processes finish Avaraqe esponse tine.00 Avarage turnaround tine: 29.33 s pro12 input.2 SRTE sehdnulingignrittin: SRTT Tatal 6 tkxar" rnsd from "input. .. pres enter. tnatart

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

=+Could you create an interactive game on the website?

Answered: 1 week ago