We are given with the n processes with their corresponding burst time and time quantum and the task is to find the average waiting time and average turnaround time and display the result.,What is Round Robin Scheduling?,Round robin is a CPU scheduling algorithm that is designed especially for time sharing systems. It is more like a FCFS scheduling algorithm with one change that in Round Robin processes are bounded with a quantum time size. A small unit of time is known as Time Quantum or Time Slice. Time quantum can range from 10 to 100 milliseconds. CPU treat ready queue as a circular queue for executing the processes with given time slice. It follows preemptive approach because fixed time are allocated to processes. The only disadvantage of it is overhead of context switching.,What we need to calculate?,Completion Time is the time required by the process to complete its execution,Turnaround Time is the time interval between the submission of a process and its completion.,Turnaround Time = completion of a process – submission of a process,Waiting Time is the difference between turnaround time and burst time,Waiting Time = turnaround time – burst time,We are given with 3 processes P1, P2 and P3 with their corresponding burst time as 24, 3 and 3,Since the time quantum is of 4 milliseconds, process P1 gets the first 4 milliseconds but it requires another 20 millisecond to complete its execution but CPU will preempt it after the first time quantum and CPU will be allocated to the next process P2. As shown in the table, Process P2 requires only 3 milliseconds to complete its execution so CPU will be allocated for time quantum of 3 milliseconds only instead of 4 milliseconds.,Using the Gantt chart, Average waiting time is calculated as given below −,Average waiting time = 17/3 = 5.66 milliseconds,登录后复制,实例演示,登录后复制,以上就是循环调度的C程序的详细内容,更多请关注www.xfxf.net其它相关文章!