Round Robin Scheduling Program in C

In this tutorial you will learn about round robin scheduling program in C.

Process scheduling is an important component for process management. In a multi-user and a time-sharing system, response time is one of the most important objective to be accomplished.

There are many scheduling algorithms in C for process management such as:

1. First Come First Serve
2. Shortest Job First
3. Priority Scheduling
4. Round Robin Scheduling

However, this tutorial will get you clear with understanding of Round Robin Scheduling program in C.

Round Robin Scheduling Algorithm

1. The queue structure in ready queue is of First In First Out (FIFO) type.

2. A fixed time is allotted to every process that arrives in the queue. This fixed time is known as time slice or time quantum.

3. The first process that arrives is selected and sent to the processor for execution. If it is not able to complete its execution within the time quantum provided, then an interrupt is generated using an automated timer.

4. The process is then stopped and is sent back at the end of the queue. However, the state is saved and context is thereby stored in memory. This helps the process to resume from the point where it was interrupted.

5. The scheduler selects another process from the ready queue and dispatches it to the processor for its execution. It is executed until the time Quantum does not exceed.

6. The same steps are repeated until all the process are finished.

The round robin algorithm is simple and the overhead in decision making is very low. It is the best scheduling algorithm for achieving better and evenly distributed response time.


Lets take one example to understand it.

Time Quantum = 2

Process Arrival Time Burst Time
P1 0 9
P2 1 5
P3 2 3
P4 3 4


Process Arrival Time Burst Time (x) Turnaround Time(t) Normalized Turnaround Time(t/x) Waiting Time
P1 0 9 21 2.34 12
P2 1 5 17 3.4 12
P3 2 3 11 3.67 8
P4 3 4 12 3 8

Average Turnaround Time = 15.25
Average Normalized Turnaround Time = 3.10
Average Waiting Time = 10

Round Robin Scheduling Program in C


Round Robin Scheduling Program in C

If you found anything incorrect or have any doubts regarding above round robin scheduling program in C then comment below.

38 thoughts on “Round Robin Scheduling Program in C

  1. Rajesh Kumar

    Input Arrival time and BT shown blow. after compile with these value the output is incorrect.
    Please check and update this code.
    [P.No->1,2,3,4,5,6], [AT->0,1,2,3,4,6],[BT->4,5,2,1,6,3],[TAT->8,17,4,6,17,13],[WT->4,12,2,5,11,10]

  2. Sumit

    ur code is not suitable for all the problem…………….update ur code…………..

    [P.No->1,2,3,4,5,6], [AT->0,1,2,3,4,6],[BT->4,5,2,1,6,3],[TAT->8,17,4,6,17,13],[WT->4,12,2,5,11,10]

      1. Parth

        She is right. It doesn’t work for all cases. Try implementing with different test cases.

  3. Bilal Samed Şahin

    Do you have hrrn and mlfq scheduling program in C ?Thanks in advance

  4. vikramjeetsingh

    Enter Total Process: 6
    Enter Arrival Time and Burst Time for Process Process Number 1 :0
    Enter Arrival Time and Burst Time for Process Process Number 2 :1
    Enter Arrival Time and Burst Time for Process Process Number 3 :2
    Enter Arrival Time and Burst Time for Process Process Number 4 :3
    Enter Arrival Time and Burst Time for Process Process Number 5 :4
    Enter Arrival Time and Burst Time for Process Process Number 6 :6
    Enter Time Quantum: 2

    it is giving wrong answer for this

  5. osama saad

    thats the reason i love india u r the best in the earth and u will rech your goal

  6. alireza

    Hi everybody .
    I am industrial engineering student and I need a c++ code .
    thats greateful if someone help me .
    tnx a lot .
    please send me email to explain the problem .

  7. Azeem

    yes i doesnt work in all cases but u can implement more advanced but the solution is here … 🙂

  8. lakshmanarao karaka

    if(rt[count]0) why this condition use please explain that condition

  9. dhruva

    can you post multicore scheduler c program for Earliest Deadline First scheduler

  10. Manish

    sir, we need algorithm and flow chart FCFS,SJF,Round Robin and other scheduling algorithm…. can you please send me the algorithm and flow charts … My mail address:

  11. Elhag beshir

    Thank you for this program I ask about program for how to keep trak in banking balance in multi threading

  12. emma

    need an urgent question:

    how to implement multilevel Round Robin feedback queue scheduling program in c

    1. pawan

      burst time means service time. in other words burst time is the time taken to complete the execution of the job.

  13. ashish chaurasiya

    Design a scheduling program that is capable of scheduling many processes that comes
    in at some time interval and are allocated the CPU not more that 10 time units. CPU must
    schedule processes having short execution time first. CPU is idle for 3 time units and does not
    entertain any process prior this time. Scheduler must maintain a queue that keeps the order of
    execution of all the processes. Compute average waiting and turnaround time.

    plz suggest me ho to solve this problem…..


Leave a Reply

Your email address will not be published. Required fields are marked *