Escolar Documentos
Profissional Documentos
Cultura Documentos
P1 P2 P3
0 24 27 30
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
• FCFS is non preemptive. Once CPU has been allocated to a process that process
keeps the CPU until it terminates or IO request comes. This is particularly
troublesome for time sharing systems where each user needs to get a share of CPU
at regular intervals. It would be disastrous to allow one process to keep CPU for an
extended period.
• Convoy effect short process behind long process. All processes are waiting for one
big process to get off the CPU. This effect results in lower CPU utilization.
FCFS Scheduling (Cont)
Suppose that the processes arrive in the order
P2 , P3 , P1
• The Gantt chart for the schedule is:
P2 P3 P1
0 3 6 30
P4 P1 P3 P2
0 3 9 16 24
• Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
Process Arrival time Burst time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
P1 P2 P4 P1 P1 P3
0 1 5 10 17 26
• Aging factor= waiting time- remaining CPU time / Total CPU time
process burst time priority
p1 10 3
p2 1 1
p3 2 3
p4 1 4
p5 5 2
Round Robin (RR)
• RR scheduling is specially designed for the time sharing systems.
• It is similar to the FCFS scheduling but preemption is added to switch
between the processes.
• Each process gets a small unit of CPU time (time quantum), usually 10-
100 milliseconds. After this time has elapsed, the process is
preempted and added to the end of the ready queue.
• New processes are added to the tail of the queue. CPU scheduler
picks the first process from the ready queue, sets a timer to interrupt
after 1 time quantum and dispatches the process.
• RR approach is called processor sharing.
Example of RR with Time
Quantum = 4
Process Burst Time
P1 24
P2 3
P3 3
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30