Download presentation
Presentation is loading. Please wait.
Published byTracey Bertina Day Modified over 8 years ago
1
1 5.4.3 Round Robin Scheduling A preemptive scheduling designed for Time Sharing Systems The Ready Queue is treated as a circular queue A small execution time interval is defined as the Time Quantum, or time slice
2
2 Interrupts in Round Robin When the executing interval of a process reaches the time quantum, the timer will cause the OS to interrupt the process The OS carries out a context switch to the next selected process from the ready queue.
3
3 Length of the Time Quantum Time quantum that is too short will generate many context switching and results in lower CPU efficiency. Time quantum that is too long may result in poor performance time.
4
4 RR Scheduling (cont’d) Example: Five processes arrive at time 0, in the order: P1, P2, P3, P4, P5. Their CPU burst time are shown in the following table. Using RR with Quantum =40 msec, find the average turnaround time and average waiting time ProcessCPU burst (Unit: ms) P1135 P2102 P356 P4148 P5125
5
5 First round (First turn): 0 to 200 ms Execution time of each ProcessRemaining time P140 (run from 0 to 40) 135 – 40 = 95 P240 (run from 40 to 80) 102 – 40 = 62 P340 (run from 80 to 120) 56 – 40 = 16 P440 (run from 120 to 160) 148 – 40 = 108 P540 (run from 160 to 200) 125 – 40 = 85
6
6 Second round (Second turn): 200 to 376 ms Execution time of each ProcessRemaining time P140 (run from 200 to 240) 95 – 40 = 55 P240 (run from 240 to 280) 62 – 40 = 22 P316 (run from 280 to 296) P3 runs to completion Ta(P3) = 296 P440 (run from 296 to 336) 108 – 40 = 68 P540 (run from 236 to 376) 85 – 40 = 45
7
7 Third round (third turn): 376 to 518 ms Execution time of each ProcessRemaining time P140 (run from 376 to 416) 55 – 40 = 15 P222 (run from 416 to 438) P2 runs to completion Ta(P2) = 438 P440 (run from 438 to 478) 68 – 40 = 28 P540 (run from 478 to 518) 45 – 40 = 5
8
8 Fourth round (fourth turn): 518 to 566 ms Execution time of each ProcessRemaining time P115 (run from 518 to 533) P1 runs to completion Ta(P1) = 533 P428 (run from 533 to 561) P4 runs to completion Ta(P4) = 561 P55 (run from 561 to 566) P5 runs to completion Ta(P5) = 566 Average Turnaround Time = (Ta(P3)+Ta(P2) +Ta(P1)+Ta(P4)+Ta(P5)) / 5 = (296+438+533+561+566) / 5 = 478.8 ms
9
9 Example with Round Robin The chart for Round-Robin, with Quantum =40 msec., is:
10
10 Wait Time: Wait time P1533 – 135 = 398 P2438 – 102 = 336 P3296 – 56 = 240 P4561 – 148 = 413 P5566 – 125 = 441 Average Wait Time = (Tw(P1)+Tw(P2) +Tw(P3)+Tw(P4)+Tw(P5)) / 5 = (398+336+240+413+441) / 5 = 365.6 ms
11
11 5.4.4 Shortest Remaining Time First Shortest remaining time (SRTF) is a preemptive version of SPN scheduling. With this scheduling policy, a new process that arrives will cause the scheduler to interrupt the currently executing process if the CPU burst of the newly arrived process is less than the remaining service period of the process currently executing. There is then a context switch and the new process is started immediately.
12
12 SRTF Scheduling When there are no arrivals, the scheduler selects from the ready queue the process with the shortest CPU service period (burst). As with SPN, this scheduling policy can be considered multi-class because the scheduler gives preference to the group of processes with the shortest remaining service time and processes with the shortest CPU burst.
13
13 SRTF Example Process Arrival time CPU burst P10135 P20102 P3056 P40148 P50125 P620065
14
14 Gantt Chart for SRTF Example Turnaround Time: Ta(p3)=56, Ta(p2)=56+102=158 At time 200, P5 has executed during 42 msec and has remaining service time of 83 microseconds, which is greater than the CPU burst of P6 (i.e., 65 ms). Ta(p6) = 65, Ta(P5)= 56+102+42+65+83=348 Ta(P1) = 348+135 = 483 Ta(P4) = 483 + 148 = 631
15
15 Results of Example Using SRT ProcessStartCompletionWaitTurnaroundNtat P13484833484833.577 P256158561581.549 P30560561.0 P44836314836314.263 P51583482233482.784 P62002650651.0 The average wait period = (248+56+0+483+223+0)/6=185.0 microsec. The average turnaround time = (483+158+56+631+348+65) =290.16 microsec.
16
16 5.4.6 Dynamic Priority Scheduling Processes that request I/O service will typically start with CPU service; for a short time; request another I/O operation; and release the CPU. If these processes are given higher priority, they can keep the I/O devices busy without using a significant amount of CPU time. This will tend to maximize I/O utilization while using a relatively small amount of CPU time. The remaining CPU capacity will be available for processes that are requesting CPU bursts.
17
17 Dynamic Priority Scheduling (2) The CPU scheduler dynamically adjusts the priority of a process as the process executes. The typical approach is to adjust the priority based on the level of expectation that the process will carry out a system call (typically an I/O request). However, this requires the CPU scheduler to predict future process requests.
18
18 5.4.7 Other Scheduling Policies 5.4.7.1 Longest Process Next Not attractive
19
19 5.4.7.2 Real-Time Systems A system that maintains an on-going interaction with its environment One of the requirements of the system is its strict timing constraints The system depends on priorities and preemption
20
20 Real-Time Scheduling Policies One of the goals of real-time scheduling is to guarantee fast response of the high-priority real-time processes. The second general goal is to guarantee the processes van be scheduled in some manner to meet their individual deadline.
21
21 Real-time Processes The real-time processes, each with its own service demand, priority and deadline, compete for the CPU. Real-time processes must complete their service before their deadlines expire. The performance of the system is based on this guarantee.
22
22 Real-time Processes (2) The real-time processes can be: – Periodic processes need to be executed every specific interval (known as the period) – Sporadic processes can be started by external random events. The operating system uses a real-time scheduling policy based on priorities and preemption.
23
23 5.5 Multiple Processors For multiple-processor systems, there are several ways a system is configured. More advanced configurations and techniques for example, parallel computing, are outside the scope of this book.
24
24 Single Queue-Multiple Processors
25
25 Multiple Queues-Multiple Processors
26
26 5.6 Summary FCFS SJF RR SRT
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.