Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Processor Manager You will develop a processor manager for a single-processor, multi-programming system. The processor manager will include the tasks of the job scheduler

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Processor Manager You will develop a processor manager for a single-processor, multi-programming system. The processor manager will include the tasks of the job scheduler and the process scheduler. The job scheduler will use a first-in, first out policy. The process scheduler will use the round-robin algorithm with a quantum of 5ms.. Define the following structures in your code: 1. Process Control Block You can define a class or a struct for the PCB. The PCB should have fields for pid, state, arrival time, completion time, total burst, burst so far, priority. class PCB public: int pid; string state; I waiting, running, complete int arrivaltime; // time it arrived at the Ready Quue int startTime; // this will be the clock time (in ms) int completionTime; int totalBurst; int burstSoFar; // increment each time process gets a ms on the cpu int priority: Feel free to define the class with private members and public getters/setters if you wish (that really is the correct way to do it) 2. Job Queue 2. Job Queue vector jobQueue; // jobs arriving into the system will get added here 3. Ready Queue vector readyToRunQueue; // jobs that are waiting to run are in this queue Upon start up, your program will read the file jobs.txt to get a list of the jobs. These jobs are added to the jobQueue. The file contains a list of 5 space-delimited records that define a job and has the following structure: pid state arrival-time start-time completion-time total-burst burst-so-far priority Here is an example: jobs.txt 2 hold 200701 8 hold 100602 1 hold 5 00302 5 hold 0 00804 4 hold 3 0 0 2 05 The file jobs.txt is in this project. Your processor manager should work with any file data that meets the structure described above. Here is pseudo code for the Processor Manager: Read quantumSize from command line clock = 0; Read the jobs file and add the jobs to jobsQueue (This means reading each one into a PCB object and then adding that object to the jobs while( there are jobs in jobsQueue with arrival time >= clock or jobs in ready To RunQueue ) { Remove jobs from the jobsQueue with an arrival time = clock and add them to the readyToRunQueue. Change state of jobs to ready to run if( ready To RunQueue is not empty ) { running job (R) - Get the first job in the ready To RunQueue; quantumCount - @ change R.state - running change R.startTime - clock while( R.state = waiting and R.state complete) { clock++ quantumCount++ increment R.burstSoFar by 1 if( R.burstSoFar == totalBurst) chantate commet 7:16 PM 1. Processor Manager if( R.burstSofar -- totalBurst) change R.state = complete change R.completionTime = clock update statistics: wait time, completion time, turnaround time else if( quantumCount == quantum) change R.state = waiting add R to readyToRunQueue Remove jobs from the jobsQueue with an arrival time = clock and add to them readyToRunQueue } // end while quantun not } else { // readyqueue empty, there are future jobs, cpu idle clock } // while Jobs available At the end of the simulation your Processor Manager should generate the following report: Job | TOTAL WAIT TIME I COMPLETION TIME TURNAROUND TIME 0101012 110102 Total simulation time: 5 Average Turnaround time: 2 Average Waiting time: 2 When your program is executed, the quantum size will be passed on the command line. ./a.out 5 int main(int argc, char** argv) { if( arge jobQueue; // jobs arriving into the system will get added here 3. Ready Queue vector readyToRunQueue; // jobs that are waiting to run are in this queue Upon start up, your program will read the file jobs.txt to get a list of the jobs. These jobs are added to the jobQueue. The file contains a list of 5 space-delimited records that define a job and has the following structure: pid state arrival-time start-time completion-time total-burst burst-so-far priority Here is an example: jobs.txt 2 hold 200701 8 hold 100602 1 hold 5 00302 5 hold 0 00804 4 hold 3 0 0 2 05 The file jobs.txt is in this project. Your processor manager should work with any file data that meets the structure described above. Here is pseudo code for the Processor Manager: Read quantumSize from command line clock = 0; Read the jobs file and add the jobs to jobsQueue (This means reading each one into a PCB object and then adding that object to the jobs while( there are jobs in jobsQueue with arrival time >= clock or jobs in ready To RunQueue ) { Remove jobs from the jobsQueue with an arrival time = clock and add them to the readyToRunQueue. Change state of jobs to ready to run if( ready To RunQueue is not empty ) { running job (R) - Get the first job in the ready To RunQueue; quantumCount - @ change R.state - running change R.startTime - clock while( R.state = waiting and R.state complete) { clock++ quantumCount++ increment R.burstSoFar by 1 if( R.burstSoFar == totalBurst) chantate commet 7:16 PM 1. Processor Manager if( R.burstSofar -- totalBurst) change R.state = complete change R.completionTime = clock update statistics: wait time, completion time, turnaround time else if( quantumCount == quantum) change R.state = waiting add R to readyToRunQueue Remove jobs from the jobsQueue with an arrival time = clock and add to them readyToRunQueue } // end while quantun not } else { // readyqueue empty, there are future jobs, cpu idle clock } // while Jobs available At the end of the simulation your Processor Manager should generate the following report: Job | TOTAL WAIT TIME I COMPLETION TIME TURNAROUND TIME 0101012 110102 Total simulation time: 5 Average Turnaround time: 2 Average Waiting time: 2 When your program is executed, the quantum size will be passed on the command line. ./a.out 5 int main(int argc, char** argv) { if( arge

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

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions