Question: CODE REQUIRED IN PYTHON 3 One of the main applications of priority queues is in operating systemsfor scheduling jobs on a CPU. In this project

CODE REQUIRED IN PYTHON 3

One of the main applications of priority queues is in operating systemsfor scheduling jobs on a CPU. In this project you are to build a program that schedules simulated CPU jobs.

1. Your program should run in a loop, each iteration of which corresponds to a time slice for the CPU.

2. At every time slice, there is either 0 new jobs (96% probability) or 1 new job (4% probability) with random priority (see point 3) and random length (see point 4) added to the queue. You should assign a unique Job ID to each new job.

3. 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.

4. 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.

5. Jobs cannot be interruptedonce it is scheduled on the CPU, a job runs for a number of time slices equal to its length.

6. Your simulator must output the Job ID of the job running on the CPU in each time slice.

7. Run your simulation for 7*24*60 time slices.

8. Compute the average waiting time that jobs spent in the priority queue before being serviced.

9. Also output the number of jobs that are still in the priority queue at the end of your simulation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!