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 set of processes and the length of CPU burst time given in milliseconds:
Process | CPU Burst time (ms) |
P 1 | 5 |
P 2 | 7 |
P 3 | 6 |
P 4 | 4 |
Assume that processes being scheduled with Round-Robin Scheduling Algorithm with Time Quantum 4ms. Then the waiting time for P 4is _________ ms.
Consider three intensive processes, which requires 10,20 and 30 units of time and arrive at times 0,2 and 6 respectively. how many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
Which of the following CPU scheduling algorithms is/are supported by LINUX operating system?
Given CPU time slice of 2 ms and the following list of processes.
Process | Burst time (ms) | Arrival time (ms) |
p 1 | 3 | 0 |
p 2 | 4 | 2 |
p 3 | 5 | 5 |
Find average turnaround time and average waiting time using round-robin CPU scheduling?
In which of the following scheduling criteria, context switching will never take place?