Stacks and Queues Lab Write a program to simulate job scheduling in an operating system In this simulation, we will have jobs which need to be run on a processor to complete. Each job will take a varying number of clock cycles to execute. When the required number of clock cycles has passed, the job is removed from the processor and is considered to be At the start of each clock cycle, the processor checks if it is currently running a job. If it is, it spends another cycle working on that job. If the processor is not running a job, it gets a job from the input queue and begins running it. The input queue contains all jobs which need to be executed. Jobs have priority as well. A jobs priority is represented by an integer value between 1 and 4, where 1 is the highest priority and 4 is the lowest priority. At the start of each clock cycle, the processor checks the first job in the input queue. If that job has a lower priority that the job currently being run by the processor (or the processor is not currently running a job), then the system behaves as described in the previous paragraph. But if the first job in the input queue has a higher priority than job the processor is currently running, then the job from the queue is run by the processor. The job which was being run by the processor is pushed onto the active job stack. Jobs placed on the active job stack keep all the work that had been completed while being run by the processor. (So if a job needs to run for 5 clock cycles to complete, and had run for 2 clock cycles before being placed on the active job stack, it would only need to be run for 3 more clock cycles before being completed) At the end of each clock cycle, we determine if the current job has been run for the necessary number of clock cycles. If it has, the job is completed and we remove it from the processor Once removed, we pop the top element off the active job stack and place it back on the processor. Once placed the clock cycle ends and the process starts over from the start. The simulation is considered complete when the input queue is empty, the active job stack is empty, and there is no job being run by the processor

Stacks and Queues Lab Write a program to simulate job scheduling in an operating system In this simulation, we will have jobs which need to be run on a processor to complete. Each job will take a varying number of clock cycles to execute. When the required number of clock cycles has passed, the job is removed from the processor and is considered to be At the start of each clock cycle, the processor checks if it is currently running a job. If it is, it spends another cycle working on that job. If the processor is not running a job, it gets a job from the input queue and begins running it. The input queue contains all jobs which need to be executed. Jobs have priority as well. A job’s priority is represented by an integer value between 1 and 4, where 1 is the highest priority and 4 is the lowest priority. At the start of each clock cycle, the processor checks the first job in the input queue. If that job has a lower priority that the job currently being run by the processor (or the processor is not currently running a job), then the system behaves as described in the previous paragraph. But if the first job in the input queue has a higher priority than job the processor is currently running, then the job from the queue is run by the processor. The job which was being run by the processor is pushed onto the active job stack. Job’s placed on the active job stack keep all the work that had been completed while being run by the processor. (So if a job needs to run for 5 clock cycles to complete, and had run for 2 clock cycles before being placed on the active job stack, it would only need to be run for 3 more clock cycles before being completed) At the end of each clock cycle, we determine if the current job has been run for the necessary number of clock cycles. If it has, the job is completed and we remove it from the processor Once removed, we pop the top element off the active job stack and place it back on the processor. Once placed the clock cycle ends and the process starts over from the start. The simulation is considered complete when the input queue is empty, the active job stack is empty, and there is no job being run by the processor Show transcribed image text Stacks and Queues Lab Write a program to simulate job scheduling in an operating system In this simulation, we will have jobs which need to be run on a processor to complete. Each job will take a varying number of clock cycles to execute. When the required number of clock cycles has passed, the job is removed from the processor and is considered to be At the start of each clock cycle, the processor checks if it is currently running a job. If it is, it spends another cycle working on that job. If the processor is not running a job, it gets a job from the input queue and begins running it. The input queue contains all jobs which need to be executed. Jobs have priority as well. A job’s priority is represented by an integer value between 1 and 4, where 1 is the highest priority and 4 is the lowest priority. At the start of each clock cycle, the processor checks the first job in the input queue. If that job has a lower priority that the job currently being run by the processor (or the processor is not currently running a job), then the system behaves as described in the previous paragraph. But if the first job in the input queue has a higher priority than job the processor is currently running, then the job from the queue is run by the processor. The job which was being run by the processor is pushed onto the active job stack. Job’s placed on the active job stack keep all the work that had been completed while being run by the processor. (So if a job needs to run for 5 clock cycles to complete, and had run for 2 clock cycles before being placed on the active job stack, it would only need to be run for 3 more clock cycles before being completed) At the end of each clock cycle, we determine if the current job has been run for the necessary number of clock cycles. If it has, the job is completed and we remove it from the processor Once removed, we pop the top element off the active job stack and place it back on the processor. Once placed the clock cycle ends and the process starts over from the start. The simulation is considered complete when the input queue is empty, the active job stack is empty, and there is no job being run by the processor