Operating System Lecture 8
Operating System Lecture 8
2- Throughput is small.
1- Is a non-preemptive scheduling.
2- Process keeps the CPU until it releases the CPU, either by terminating or by
requesting I/O.
Example 1:
Suppose you have the following processes that arrive at time zero (0) in order given,
with the length of the CPU-burst time given in millisecond.
10 P1
1 P2
2 P3
1 P4
5 P5
1
Solution: Gantt chart
P1 P2 P3 P4 P5
0 10 11 13 14 19
Example 2:-
Consider the following set of processes that arrive at time 0, with the length of the
CPU-burst time given in milliseconds:
24 P1
3 P2
3 P3
Solution:-
P1 P2 P3
0 24 27 30
2
Note:-
If the processes arrive in order P2, P3, P1, however, the results will be as shown in
the following Gantt chart:
P2 P3 P1
0 3 6 30
) قصير ينتظر لفترة طويلة للحصول علىCPU burst time( الذي فترة تنفيذه أوprocess إن الـ
هذا واضح من.) طويلCPU burst time) لهprocess ) أذا كان وصوله إلى النظام خلفCPU( المعالج
:) وهذه الخاصية تسمى بP2,P3,P1( ) وعندما كان التسلسلP1,P2,P3( المثال أعاله عندما كان التسلسل
Convoy effect
Convoy effect:- Short process being behind long or big process. Or all the other processes
wait for the one big process to get off the CPU. This effect results in lower CPU and device
utilization.
Example 3: (Homework)
Consider the following set of processes that arrive at different times, with the length of the
execution time given in milliseconds:
P1 0 10
P2 0 1
P3 2 2
P4 3 1
P5 5 5
Calculate the average of: 1- T.A.T 2- W.T by using FCFS scheduling scheme?
3
2- Short Job First Scheduling Algorithm (SJFS):-
When the CPU is available, it is assigned to the process that has the smallest
next CPU burst time. Also called Shortest Next CPU Burst. If two processes
have the same length next CPU burst, FCFS scheduling is used to break the
time. The SJF algorithm be non-preemptive.
By moving a short process before a long one the waiting time of the short process
decreases more than it increases the waiting time of the long process, the average
waiting time decreases.
Example 1: Consider the following set of processes that arrive at different times,
with the length of the execution time given in milliseconds:
P1 0 7
P2 2 4
P3 4 1
P4 5 4
Solution:-
P1 P3 P2 P4
0 7 8 12 16
4
Example 2: Consider the following set of processes that arrive at different times,
with the length of the execution time given in milliseconds:
P1 1 6
P2 1 3
P3 3 1
P4 3 4
CPU idle P2 P3 P4 P1
0 1 4 5 9 15
Example: - Consider the following set of processes that arrive at different times,
with the length of the execution time given in milliseconds: (Homework)
P1 1 6
P2 1 3
P3 12 1
P4 12 4