Laboratory 1 Sem 1 2425
Laboratory 1 Sem 1 2425
Objective :
To simulate the CPU scheduling algorithm round-robin
Advantages:
Disadvantages:
The efficiency of the system is decreased if the quantum value is low as frequent switching
takes place.
The system may become unresponsive if the quantum value is high.
Algorithm
1. Firstly, create a queue where the processes are arranged in first come first serve order.
2. A quantum value is allocated to execute each process.
3. The first process is executed until the end of the quantum value. After this, an interrupt is
generated and the state is saved.
4. The CPU then moves to the next process and the same method is followed.
5. Same steps are repeated till all the processes are over.
In the code, it is asking the user to enter the number of processes and arrival time and burst
time for each process. Then, the code calculates the waiting time and the turn around time using the
round-robin algorithm.
The main part is calculating the turn around time and the waiting time. Turn around time is
calculated by adding the total time taken and subtracting the arrival time.
The waiting time is calculated by subtracting the arrival time and burst time from the total
and adding it t0 the waiting time. This is how the round-robin scheduling takes place.