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

* CODE IN PYTHON3 *

* CODE IN PYTHON3 * One of the main applications of priority

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 will run for a maximum of 50 time slices at a time. If a job has length value > 50, then it will run for 50 time slices the first time it is scheduled and for the remaining, it will be re-inserted into the priority queue with a priority value that is 10 less than its original priority. 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 (this includes the time spent in the priority queue if the job only runs partially the first time it is scheduled). 9. Also output the number of jobs that are still in the priority queue at the end of your simulation. Note: You must use heaps to implement a priority queue

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!