Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Java or C++ Problem statement: Implement the simulation of a process scheduler. We have a single CPU machine The proposed algorithm is a

Please use Java or C++

image text in transcribed

image text in transcribed

Problem statement: Implement the simulation of a process scheduler. We have a single CPU machine The proposed algorithm is a simplified variant of the algorithm in [1]. t is priority based and works as follows: Scheduler has two queues, one queue is flagged as active the other flagged as expired The scheduler considers and schedules for execution the processes from the active queue Several processes may exist in the system and each process has its own PID, arrival time, burst time and priority Priorities are between 1 and 139 Scheduler starts at second "1" t assigns to the first process in the active queue its time slot and gives it the CPU. Once the time slot expires, this process is movedto the expired queue. Time slots are calculated as follows: o Ts (140-priority) 20 second) if priority 100 o Ts (140-priority) 5 second) if priority 100 When a new process arrives, its PID is inserted in the expired queue. The expired queue is arranged in an increasing order of process priorities The scheduler keeps scheduling for execution processes from the active queue. When the active queue is empty, it switches the flags of the two queues and then starts executing the processes from the new active queue The scheduler's logic is basically a cycle of two activities o 1- Execute the processes in the queue flagged as active o 2- If the queue flagged as active is empty, change flags of both queues and go back to 1 The scheduler updates the priority of any process that has been granted two time slots. The priority update is done as follows: o waiting time sum of waiting times o bonus [10 waiting time/( now arrival time)]. With [x] Ce o New priority max(100,min (old priority-bonus+5,139)) Example: The scheduler is using two queues, Q1 and Q2 with Q1 flagged as active and Q2 flagged as expired at time 0. Before time 1, process P1 arrives and is put into Q2. Assume P1 has a priority of 90 and a burst time of 2.5 seconds. At time 1, the scheduler checks Q1 and finds it empty, as a result it changes the flags of both queues. Q1 becomes the expired queue and Q2 the active one. Q2 contains P1 P1 will then execute its first 1 second time slot and goes into Q1. Suppose at time 2 another process P2 arrives with priority 120 and a burst time of 100ms. This process is inserted into Q1 right after P1 (the queue should remain sorted), then the scheduler switches the flags of Q1 and Q2 (since Q2 is now empty), Problem statement: Implement the simulation of a process scheduler. We have a single CPU machine The proposed algorithm is a simplified variant of the algorithm in [1]. t is priority based and works as follows: Scheduler has two queues, one queue is flagged as active the other flagged as expired The scheduler considers and schedules for execution the processes from the active queue Several processes may exist in the system and each process has its own PID, arrival time, burst time and priority Priorities are between 1 and 139 Scheduler starts at second "1" t assigns to the first process in the active queue its time slot and gives it the CPU. Once the time slot expires, this process is movedto the expired queue. Time slots are calculated as follows: o Ts (140-priority) 20 second) if priority 100 o Ts (140-priority) 5 second) if priority 100 When a new process arrives, its PID is inserted in the expired queue. The expired queue is arranged in an increasing order of process priorities The scheduler keeps scheduling for execution processes from the active queue. When the active queue is empty, it switches the flags of the two queues and then starts executing the processes from the new active queue The scheduler's logic is basically a cycle of two activities o 1- Execute the processes in the queue flagged as active o 2- If the queue flagged as active is empty, change flags of both queues and go back to 1 The scheduler updates the priority of any process that has been granted two time slots. The priority update is done as follows: o waiting time sum of waiting times o bonus [10 waiting time/( now arrival time)]. With [x] Ce o New priority max(100,min (old priority-bonus+5,139)) Example: The scheduler is using two queues, Q1 and Q2 with Q1 flagged as active and Q2 flagged as expired at time 0. Before time 1, process P1 arrives and is put into Q2. Assume P1 has a priority of 90 and a burst time of 2.5 seconds. At time 1, the scheduler checks Q1 and finds it empty, as a result it changes the flags of both queues. Q1 becomes the expired queue and Q2 the active one. Q2 contains P1 P1 will then execute its first 1 second time slot and goes into Q1. Suppose at time 2 another process P2 arrives with priority 120 and a burst time of 100ms. This process is inserted into Q1 right after P1 (the queue should remain sorted), then the scheduler switches the flags of Q1 and Q2 (since Q2 is now empty)

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

Step: 3

blur-text-image

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

4. Explain the characteristics of successful mentoring programs.

Answered: 1 week ago