Consider the following four processes with the arrival time and length of CPU burst given in milliseconds : The average waiting time for preemptive SJF scheduling algorithm isProcess Arrival Time Burst Time P 1 0 8 P 2 1 4 P 3 2 9 P 4 3 5
6.5 ms
The question asks us to find the average waiting time for four processes using the preemptive Shortest Job First (SJF) CPU scheduling algorithm. We are given the arrival time and CPU burst time for each process.
Preemptive SJF is a scheduling algorithm where the CPU is allocated to the process with the smallest burst time. When a new process arrives, if its burst time is less than the remaining time of the currently executing process, the currently executing process is preempted (interrupted), and the new process starts executing. This continues until a process completes or is preempted by a newly arriving process with a shorter remaining burst time.
Here is the information for the given processes:
| Process | Arrival Time (ms) | Burst Time (ms) |
|---|---|---|
| P1 | 0 | 8 |
| P2 | 1 | 4 |
| P3 | 2 | 9 |
| P4 | 3 | 5 |
Let's trace the execution of these processes using a Gantt chart. We will keep track of the remaining burst time for each process.
Based on the simulation, the Gantt chart looks like this:
| P1 (0-1) | P2 (1-5) | P4 (5-10) | P1 (10-17) | P3 (17-26) |
Waiting time for a process is the total time it spent waiting in the ready queue. This can be calculated as:
Waiting Time = (Completion Time - Arrival Time) - Burst Time
The waiting times are: P1 = 9 ms, P2 = 0 ms, P3 = 15 ms, P4 = 2 ms.
Average Waiting Time = (Sum of Waiting Times) / (Number of Processes)
Average Waiting Time = $\frac{9 + 0 + 15 + 2}{4} = \frac{26}{4} = 6.5$ ms.
The average waiting time for the preemptive SJF scheduling algorithm is 6.5 ms.
| Process | Arrival Time | Burst Time | Start Time | Completion Time | Turnaround Time (Completion - Arrival) |
Waiting Time (Turnaround - Burst) |
|---|---|---|---|---|---|---|
| P1 | 0 | 8 | 0, 10 | 17 | $17 - 0 = 17$ | $17 - 8 = 9$ |
| P2 | 1 | 4 | 1 | 5 | $5 - 1 = 4$ | $4 - 4 = 0$ |
| P3 | 2 | 9 | 17 | 26 | $26 - 2 = 24$ | $24 - 9 = 15$ |
| P4 | 3 | 5 | 5 | 10 | $10 - 3 = 7$ | $7 - 5 = 2$ |
Sum of Waiting Times = $9 + 0 + 15 + 2 = 26$ ms.
Number of Processes = 4.
Average Waiting Time = $\frac{26}{4} = 6.5$ ms.
CPU scheduling is the process of deciding which process will own the CPU for use, and when. It is fundamental to operating systems.
Understanding these concepts is crucial for analyzing the performance of different CPU scheduling algorithms.
Consider the following 3 processes with the length of the CPU burst time given in milliseconds :
| Process | Arrival Time | Burst Time |
| P1 | 0 | 8 |
| P2 | 1 | 4 |
| P3 | 2 | 9 |
What is the average waiting time for these processes if they are scheduled using preemptive shortest job first scheduling algorithm?
Which of the following is not a CPU scheduling Algorithm?
Which of the following statement(s) is/are true about CPU scheduling algorithm?
I. Shortest remaining time first scheduling may cause starvation
II. Round Robin is better than First Come First Serve in terms of response time
Processes P1, P2, P3 and P4 have CPU burst times 5, 7, 6 and 4 ms, respectively. All arrive at time 0, and the initial ready-queue order is P1, P2, P3, P4. Using Round-Robin scheduling with a 4 ms time quantum and no context-switch overhead, what is P4’s total waiting time in milliseconds?
A process residing in main memory and ready and waiting for execution, is kept on