Correct option is A
To find the waiting time for process P1 using the Round Robin scheduling algorithm with a time quantum of 4 milliseconds, we follow these steps:
1. First Round:
· P1: Runs for 4 ms (remaining 20 ms)
· P2: Runs for 3 ms (completed)
· P3: Runs for 3 ms (completed)
· P4: Runs for 4 ms (remaining 8 ms)
Time elapsed: 4+3+3+4=14 ms
2. Second Round:
· P1: Runs for 4 ms (remaining 16 ms)
· P4: Runs for 4 ms (remaining 4 ms)
Time elapsed: 14+4+4=22 ms
3. Third Round:
· P1: Runs for 4 ms (remaining 12 ms)
· P4: Runs for 4 ms (completed)
Time elapsed: 22+4+4=30 ms
4. Fourth Round:
· P1: Runs for 4 ms (remaining 8 ms)
Time elapsed: 30+4=34 ms
5. Fifth Round:
· P1: Runs for 4 ms (remaining 4 ms)
Time elapsed: 34+4=38 ms
6. Sixth Round:
· P1: Runs for 4 ms (completed)
Time elapsed: 38+4=42 ms
The waiting time for P1 is the total time minus the time it actually spent running:
Waiting time for P1=(Total time)−(Burst timeforP1)
Waiting time for P1=42 ms−24 ms= 18 ms
Important Key Points:
1. Round Robin (RR):
· Is a preemptive scheduling algorithm that assigns fixed time slices to each process.
· Ensures fairness and avoids process starvation.
2. Waiting Time: The total time a process spends waiting in the ready queue.
Knowledge Booster:
· Time Quantum: The fixed time each process gets to execute before the next process starts. It influences the performance of the Round Robin scheduling.
· Burst Time: The total time required by a process for execution on the CPU.
· Context Switching: The process of storing and restoring the state of a CPU so that multiple processes can share a single CPU resource.