Beruflich Dokumente
Kultur Dokumente
Reference: http://www.sciencehq.com/computing-technology/first-come-first-
served-algorithm.html
FCFS also termed as First-In-First-Out i.e. allocate the CPU in order in which the process
arrive. When the CPU is free, it is allowed to process, which is occupying the front of the
queue. Once this process goes into running state, its PCB is removed from the queue. This
algorithm is non-preemptive.
Advantage
Disadvantage
Waiting time can be large if short request wait behind the long process.
It is not suitable for time sharing system where it is important that each user should
get the CPU for equal amount of time interval.
Examples
Consider the following set of processes having their CPU-burst time. CPU burst time
indicates that for how much time, the process needs the CPU.
If the processes have arrived in order P1, P2, P3 then the average waiting time for process
will be obtained from Gantt chart.
STA. ANA, RONA MAE IT 3Y2-1
Reference: http://www.sciencehq.com/computing-technology/shortest-job-first-
scheduling.html
Let us consider, the following set of processes having their CPU burst time mentioned in
millisecond and having arrived almost at the same time.
p1 10
STA. ANA, RONA MAE IT 3Y2-1
p2 5
p3 2
Reference: http://www.sciencehq.com/computing-technology/shortest-
remaining-time-scheduling.html
p1 10 0
p2 5 1
p3 2 2
STA. ANA, RONA MAE IT 3Y2-1
In this, the CPU will be taken away from the currently executing process whenever a
process will less CPU burst time.
As shown in figure, the time when P2 arrives P1 needs 9 millisecond more to finish. As B’s
cpu burst in 5 millisecond < 9 millisecond, therefore, P1’s execution will be preempted and
P2 will be executed but against as P3 arrives P2’s execution needs 3 more millisecond where
as P3 needs only 2 millisecond to execute, thus P3 takes over P2 and so on.
Reference: http://www.sciencehq.com/computing-technology/round-robin-
scheduling.html
As shown in figure: first p1 gets the cpu and get executed for 2 millisecond, then context
switching occurs and P2 get cpu for 2 millisecond, then again content switching occur and
P3 get cpu for 2 millisecond, since its cpu burst time is 2 millisecond only, therefore it
complete its execution and thus do not get the cpu again. P1 and P2 similarly continue to
share the CPU in the same fashion till they are done.
If time quantum is large than the CPU burst then this algorithm become same as
FCFS and thus performance degrade.
STA. ANA, RONA MAE IT 3Y2-1
If the time quantum size is very small, then the number of content switches
increases and the time quantum almost equal the time taken to switch the CPU from
one process to another. Therefore 50% of time spent in switching of processes.
The number of context switches should not be too many to slow down the overall execution
of all the processes. Time quantum should be large with respect to the context switch time.
5. Priority Scheduling
Reference: http://www.sciencehq.com/computing-technology/priority-
scheduling.html
Priority scheduling
Each process in the system if given a priority, then the scheduling must be done according
to the priority of each process. A higher priority job should get CPU whereas lower priority
job can be made to wait. Priority scheduling is necessarily a form of preemptive scheduling
where priority is the basic of preemption.
Example:
Let us consider a set of processes P1, P2, P3 having priorities ranging from 1 to 3. Let us
assume that 1 is the highest priority whereas 3 is the least priority. Let us also assume that
p1 arrive first and P3 arrives in the last.
p1 10 3 0
p2 5 2 1
p3 2 1 2
Here, the preemption is based on the priority when P1 execute, P2 arrive with priority 2,
which is higher than priority 3 of P1, and thus P1 is preempted. Similarly when P2 execute,
P3 arrive with Priority 1 which is the highest priority and thus P2 is preempted and soon.
The main question arise here is if two processes have been assigned same priorities. Priority
may be assigned by user or by the operating system depending upon the important of
process. In that case comparison will be done with their CPU burst time. The process with
short CPU burst time will be executed first.