Docsity

Priority and Round-Robin Scheduling, Exams of Operating Systems

Toggle sidebar
bg1
Table
A. Priority Scheduling
1. Gantt Chart
P0 P1 P3 P5 P4 P2
0 15 23 44 58 71 78
Solution:
Process Queue Completion Time Turnaround Time Waiting Time
P0 15 15 โ€“ 0 = 15 15 โ€“ 15 = 0
P1 23 23 โ€“ 0 = 23 23 โ€“ 8 = 15
P2 78 78 โ€“ 0 = 78 78 โ€“ 7 = 71
P3 44 44 โ€“ 0 = 44 44 โ€“ 21 = 23
P4 71 71 โ€“ 0 = 71 71 โ€“ 13 = 58
P5 58 58 โ€“ 0 = 58 58 โ€“ 14 = 44
Average Turn Around Time = (15 +23 + 78 + 44 + 71 + 58) / 6 = 48.16 ms
Average Waiting Time = (0 + 15 + 71 + 23 + 58 + 44) / 6 = 35.16 ms
Process Queue Burst Time Priority Time Quantum = 4
P0 15 1
P1 8 2
P2 7 5
P3 21 2
P4 13 4
P5 14 3
Turnaround Time = Completion โ€“ Arrival time
Waiting Time = Turnaround time โ€“ Burst time
pf3
pf4

Partial preview of the text

Download Priority and Round-Robin Scheduling and more Exams Operating Systems in PDF only on Docsity!

Table A. Priority Scheduling

  1. Gantt Chart P0 P1 P3 P5 P4 P 0 15 23 44 58 71 78 Solution: Process Queue Completion Time Turnaround Time Waiting Time P0 15 15 โ€“ 0 = 15 15 โ€“ 15 = 0 P1 23 23 โ€“ 0 = 23 23 โ€“ 8 = 15 P2 78 78 โ€“ 0 = 78 78 โ€“ 7 = 71 P3 44 44 โ€“ 0 = 44 44 โ€“ 21 = 23 P4 71 71 โ€“ 0 = 71 71 โ€“ 13 = 58 P5 58 58 โ€“ 0 = 58 58 โ€“ 14 = 44 Average Turn Around Time = (15 +23 + 78 + 44 + 71 + 58) / 6 = 48.16 ms Average Waiting Time = (0 + 15 + 71 + 23 + 58 + 44) / 6 = 35.16 ms Process Queue Burst Time Priority Time Quantum = 4 P0 15 1 P1 8 2 P2 7 5 P3 21 2 P4 13 4 P5 14 3 Turnaround Time = Completion โ€“ Arrival time Waiting Time = Turnaround time โ€“ Burst time

B. Round Robin Scheduling

  1. Gantt Chart P0 P1 P2 P 3

P4 P5 P0 P1 P2 P

P4 P5 P

P3 P4 P5 P0 P3 P

P5 P3 P

0 4 8 12 16 20 24 28 32 35 39 43 47 51 55 59 63 66 70 71 73 77 78

  1. AWT Solution: Waiting Time = Last Start Time โ€“ Arrival time โ€“ (Preemption x Time Quantum) Process Queue Waiting Time P0 51 โ€“ 0 โ€“ (3x4) = 39 P1 4 โ€“ 0 โ€“ (1x4) = 0 P2 12 โ€“ 0 โ€“ (1x4) = 8 P3 77 โ€“ 0 โ€“ (5x4) = 57 P4 55 โ€“ 0 โ€“ (4x4) = 47 P5 63 โ€“ 0 โ€“ (3x4) = 51 Average Waiting Time = (39 + 0 + 8 + 57 + 47 + 51) / 6 = 202 / 6 = 33.66 ms Test II. For Midterm exam Process Allocation Max Available A B C D A B C D A B C D P1 0 0 1 2 0 0 1 2 1 5 2 0 P2 1 0 0 0 1 7 5 0 P3 1 3 5 4 2 3 5 6 P4 0 6 3 2 0 6 5 2 P5 0 0 1 4 0 6 5 6

P4 0 0 2 0

P5 0 6 4 2

  1. Supply the table for each process to determine the safe state. Then state if the processes are safe to state. Process Allocation Need Available A B C D A B C D A B C D P1 0 0 1 2 0 0 0 0 1 5 3 2 P2 1 0 0 0 0 7 5 0 2 5 3 2 P3 1 3 5 4 1 0 0 2 3 8 8 6 P4 0 6 3 2 0 0 2 0 3 14 11 8 P5 0 0 1 4 0 0 0 0 3 14 12 12 = Processes are safe to state.