The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
One of the main applications of priority queues is in operating systems - forscheduling jobson a CPU. In this assignment you are to build a program that schedules simulated CPU jobs. Your program should run in a loop, each iteration of which corresponds to atime slicefor 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 alengthvalue, which is an integer between 1 and 10, inclusive, indicating the number of time slices that are needed to process this job. When not interrupted, a job, when scheduled on the CPU, runs for a number of time slices equal to its length. Jobs, however, may be preempted. For example, when a new job with a higher priority arrives, execution of the current job will be suspended, with the unfinished time-slices as the new job length. For simplicity, overhead from context switches will not be accounted for. Also, jobs of the same priority are scheduled on a first-come-first-served (FCFS) basis.
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 jobnamewith lengthnand priorityp” or “no new job this slice”.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll