Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Consider a CPU that has to run a bunch of jobs. You are asked to develop a scheduler for the CPU. Your program should

2. Consider a CPU that has to run a bunch of jobs. You are asked to develop a scheduler for the CPU. Your program should run in a loop, each iteration of which corresponds to a time slice for the CPU. Each job is assigned a priority, which is an integer between 20 (highest priority) and 19 (lowest priority), inclusive. From among all jobs waiting to be processed in a time slice, the CPU must work on a job with highest priority. In this simulation, each job will also come with a length value, which is an integer between 1 and 100, inclusive, indicating the number of time slices that are needed to process this job. For simplicity, you may assume jobs cannot be interruptedonce it is scheduled on the CPU, a job runs for a number of time slices equal to its length. Moreover, each time a job has spent x time slices in the waiting line its priority is increased by 1. Notice that after the priority of a job is increased its waiting time restarts from 0. Your simulator must output the name of the job running on the CPU in each time slice and must process a sequence of commands, one per time slice, each of which is of the form add job name with length n and priority p or no new job this slice. I want Python code using priority queue.

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

More Books

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago