Assume that the following tasks are to be executed on a single processor system. All tasks have arrived at 0 msec. How long does it take for task "a" to complete if the scheduling time slice is a round-robin with 1 ms?Job ID CPU a 4 b 1 c 7 d 2
10
This problem asks us to determine the completion time of a specific task, task "a", when multiple tasks are scheduled on a single processor using the Round Robin scheduling algorithm. All tasks arrive at the same time (0 msec), and the scheduling uses a fixed time slice (quantum) of 1 ms.
Round Robin (RR) is a CPU scheduling algorithm where each process is assigned a fixed time slice (quantum) in a cyclic way. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval up to one time slice. If a process finishes its burst time within the time slice, it is terminated. If not, the process is preempted and added to the end of the ready queue.
We have the following tasks with their CPU burst times:
All tasks arrive at time 0 msec. The time slice for Round Robin is 1 ms.
Let's simulate the execution of these tasks using the 1 ms time slice. We will assume the initial ready queue order is [a, b, c, d].
| Time Interval (ms) | Task Executing | Remaining CPU Burst | Ready Queue (after execution/preemption) | Notes |
|---|---|---|---|---|
| 0 - 1 | a | a=3, b=1, c=7, d=2 | [b, c, d, a] | 'a' runs for 1ms. Preempted, added to end. |
| 1 - 2 | b | a=3, b=0, c=7, d=2 | [c, d, a] | 'b' runs for 1ms. Finishes. |
| 2 - 3 | c | a=3, c=6, d=2 | [d, a, c] | 'c' runs for 1ms. Preempted, added to end. |
| 3 - 4 | d | a=3, c=6, d=1 | [a, c, d] | 'd' runs for 1ms. Preempted, added to end. |
| 4 - 5 | a | a=2, c=6, d=1 | [c, d, a] | 'a' runs for 1ms. Preempted, added to end. |
| 5 - 6 | c | a=2, c=5, d=1 | [d, a, c] | 'c' runs for 1ms. Preempted, added to end. |
| 6 - 7 | d | a=2, c=5, d=0 | [a, c] | 'd' runs for 1ms. Finishes. |
| 7 - 8 | a | a=1, c=5 | [c, a] | 'a' runs for 1ms. Preempted, added to end. |
| 8 - 9 | c | a=1, c=4 | [a, c] | 'c' runs for 1ms. Preempted, added to end. |
| 9 - 10 | a | a=0, c=4 | [c] | 'a' runs for 1ms. Finishes. |
From the simulation table, we can see the timeline of execution. Task 'a' runs during the intervals 0-1, 4-5, 7-8, and 9-10.
Task 'a' completes its required 4 ms of CPU burst at the end of the time interval 9-10 msec. Therefore, the completion time for task "a" is 10 msec.
Task "a" requires a total CPU burst of 4 ms.
Task 'a' finishes exactly at the 10 msec mark.
Thus, the time it takes for task "a" to complete is 10 msec.
| Concept | Description |
|---|---|
| Round Robin (RR) Scheduling | A preemptive scheduling algorithm where each process gets a fixed time slice (quantum) of CPU time in a cyclic order. |
| Time Slice (Quantum) | A small unit of time assigned to each process in RR scheduling. After this time, the process is preempted. |
| CPU Burst | The amount of time a process needs the CPU to complete its execution. |
| Completion Time | The time at which a process finishes its execution. |
While Round Robin is used here, other common CPU scheduling algorithms include:
Each algorithm has different characteristics regarding throughput, turnaround time, waiting time, and response time.
| Process | CPU Burst Time (MS) |
| P1 | 24 |
| P2 | 3 |
| P3 | 3 |
Consider the following table about processes, their burst time and arrival time
| Process | Burst Time | Arrival Time |
| P1 | 09 | 0 |
| P2 | 30 | 0 |
| P3 | 04 | 0 |
| P4 | 08 | 2 |
| P5 | 11 | 6 |
Now which of the process shall finish second last as per the respective GANTT charts for the non- preemptive SJF and Round Robin (time quantum = 10) scheduling methods.