Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JURULUULUU 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,

image text in transcribed
image text in transcribed
JURULUULUU 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 Time 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++ progl.cpp Sample Output -------PROCESS LIST........ Process 1000 with RTime 2 And Priori Process 1001 with RTime 4 And Priorit 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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions