Dhaka International University: Lab Report
Dhaka International University: Lab Report
Lab Report
Experiment No: 04
Experiment Name: Implementation of Round Robin Scheduling Algorithm
Date of Experiment: 16 April 2025
Theory:
Round Robin is a preemptive scheduling algorithm where each process gets a fixed time unit
(time quantum) for execution before being preempted and placed back in the ready queue. This
approach ensures fair CPU allocation among all processes and prevents starvation.
Key Characteristics:
No process starvation
Formulas Used:
Source Code:
process = []
3
for i in range(n):
time = 0
final = []
queue = deque()
i=0
queue.append(process[i])
i += 1
if queue:
curr = queue.popleft()
time += execu_time
rbt -= execu_time
queue.append(process[i])
4
i += 1
if rbt > 0:
else:
ct = time
tat = ct - at
wt = tat - bt
else:
time += 1
print("-" * 65)
print(
Output:
Discussion:
The implemented Round Robin algorithm demonstrates several important characteristics of this
scheduling approach. The use of a time quantum ensures that no single process can monopolize
the CPU, creating a fair environment where all processes get regular execution opportunities.
In the execution phase, we observe how processes are cycled through the ready queue, each
receiving up to the specified time quantum for execution. This creates an interleaved execution
pattern where longer processes are broken into multiple chunks, while shorter processes may
complete within their first allocation. The algorithm efficiently handles new process arrivals by
adding them to the queue when they become ready.
The waiting time calculations reveal an interesting trade-off - while no process gets starved,
some may experience increased waiting times due to the overhead of frequent context
switches. This is particularly noticeable for processes with burst times just slightly longer than
the time quantum. The average waiting time serves as a key metric for evaluating the
algorithm's efficiency.
6
Conclusion:
The Round Robin algorithm provides an effective solution for time-sharing systems where
fairness and responsiveness are prioritized. While it guarantees no starvation, the choice of time
quantum significantly impacts performance - too small increases context switch overhead, while
too large may degrade response times.