Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Module 2: Non-Preemptive Priority Scheduling Objective: In completion of this program, you will be able to compare the types of scheduling algorithms of a CPU

image text in transcribedimage text in transcribed

Module 2: Non-Preemptive Priority Scheduling 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. RTime - 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

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions