Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objective: In completion of this program, you will be able to compare the types of scheduling algorithms of a CPU scheduler. You will be able
Objective: In completion of this program, you will be able to compare the types of scheduling algorithms of a CPU scheduler. You will be able to simulate the execution of a process and the job of a CPU Scheduler. By implementing the Non-Preemptive Priority Scheduling, you can show that non-preemption and priority affects scheduling when considering which process to execute next. Description: Through your own methods, write a C/C++ program that imitates the job of a CPU scheduler implementing the Non-Preemptive Priority Scheduling Algorithm. Firstly, create a Process class with two integer values: ID - Unique ID of the process between 1000 and 9999. BTime - Remaining time of the process initialized to a random number between 1 and 10. Priority - A smaller priority number implies a higher priority. In this program: Create 5 mock processes which will be executed in order of the highest priority. Have a Ready List, an Executing List, and a Finished List for the processes. The processes should be loaded into the Ready List at the beginning and move each process into the Executing List to execute. Only one process can execute at a time. To simulate execution: Print the process ID and priority of the executing process. Create a loop that prints out the remaining time of the executing process for each iteration. Each iteration should decrement RTime by 1. Once the process is complete, move the process to the Finished List. Put the next appropriate process from the Ready List to the Executing List. To run this CPP program on Unix or Linux, type: g++ progi.cpp Sample Output -------PROCESS LIST--- Process 1000 with RTime 2 And Priority 3 Process 1001 with RTime 4 And Priority 1 Process 1002 with RTime 7 And Priority 3 Process 1003 with RTime 6 And Priority 4 Process 1004 with RTime 1 And Priority 6 ------Beginning Execution of Process 1001 with Priority 1-- Process 1001 with Remaining Time of 4 Process 1001 with Remaining Time of 3 Process 1001 with Remaining Time of 2 Process 1001 with Remaining Time of 1 Process 1001 finished and moved to Finished List ------Beginning Execution of Process 1000 with Priority 3--- Process 1000 with Remaining Time of 2 Process 1000 with Remaining Time of 1 Process 1000 finished and moved to Finished List ------Beginning Execution of Process 1002 with Priority 3------- Process 1002 with Remaining Time of 7 Process 1002 with Remaining Time of 6 Process 1002 with Remaining Time of 5 Process 1002 with Remaining Time of 4 Process 1002 with Remaining Time of 3 Process 1002 with Remaining Time of 2 Process 1002 with Remaining Time of 1 Process 1002 finished and moved to Finished List -------Beginning Execution of Process 1003 with Priority 4--- Process 1003 with Remaining Time of 6 Process 1003 with Remaining Time of 5 Process 1003 with Remaining Time of 4 Process 1003 with Remaining Time of 3 Process 1003 with Remaining Time of 2 Process 1003 with Remaining Time of 1 Process 1003 finished and moved to Finished List Submission instructions: Submit a single pdf file including your source program, and the output. Name the file Quiz2_cslogin.pdf", where the cslogin is your login ID for the Objective: In completion of this program, you will be able to compare the types of scheduling algorithms of a CPU scheduler. You will be able to simulate the execution of a process and the job of a CPU Scheduler. By implementing the Non-Preemptive Priority Scheduling, you can show that non-preemption and priority affects scheduling when considering which process to execute next. Description: Through your own methods, write a C/C++ program that imitates the job of a CPU scheduler implementing the Non-Preemptive Priority Scheduling Algorithm. Firstly, create a Process class with two integer values: ID - Unique ID of the process between 1000 and 9999. BTime - Remaining time of the process initialized to a random number between 1 and 10. Priority - A smaller priority number implies a higher priority. In this program: Create 5 mock processes which will be executed in order of the highest priority. Have a Ready List, an Executing List, and a Finished List for the processes. The processes should be loaded into the Ready List at the beginning and move each process into the Executing List to execute. Only one process can execute at a time. To simulate execution: Print the process ID and priority of the executing process. Create a loop that prints out the remaining time of the executing process for each iteration. Each iteration should decrement RTime by 1. Once the process is complete, move the process to the Finished List. Put the next appropriate process from the Ready List to the Executing List. To run this CPP program on Unix or Linux, type: g++ progi.cpp Sample Output -------PROCESS LIST--- Process 1000 with RTime 2 And Priority 3 Process 1001 with RTime 4 And Priority 1 Process 1002 with RTime 7 And Priority 3 Process 1003 with RTime 6 And Priority 4 Process 1004 with RTime 1 And Priority 6 ------Beginning Execution of Process 1001 with Priority 1-- Process 1001 with Remaining Time of 4 Process 1001 with Remaining Time of 3 Process 1001 with Remaining Time of 2 Process 1001 with Remaining Time of 1 Process 1001 finished and moved to Finished List ------Beginning Execution of Process 1000 with Priority 3--- Process 1000 with Remaining Time of 2 Process 1000 with Remaining Time of 1 Process 1000 finished and moved to Finished List ------Beginning Execution of Process 1002 with Priority 3------- Process 1002 with Remaining Time of 7 Process 1002 with Remaining Time of 6 Process 1002 with Remaining Time of 5 Process 1002 with Remaining Time of 4 Process 1002 with Remaining Time of 3 Process 1002 with Remaining Time of 2 Process 1002 with Remaining Time of 1 Process 1002 finished and moved to Finished List -------Beginning Execution of Process 1003 with Priority 4--- Process 1003 with Remaining Time of 6 Process 1003 with Remaining Time of 5 Process 1003 with Remaining Time of 4 Process 1003 with Remaining Time of 3 Process 1003 with Remaining Time of 2 Process 1003 with Remaining Time of 1 Process 1003 finished and moved to Finished List Submission instructions: Submit a single pdf file including your source program, and the output. Name the file Quiz2_cslogin.pdf", where the cslogin is your login ID for the
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started