Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise Ms.Reema alOraini

Similar presentations


Presentation on theme: "Exercise Ms.Reema alOraini"— Presentation transcript:

1 Exercise Ms.Reema alOraini
CPU SCHEDULING Exercise Ms.Reema alOraini

2 Burst Time (millisecond)
Question 1 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5

3 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer P1

4 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 1 P1

5 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 P2 had higher priority so it will be execution Timer 2 P1 P2 2

6 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 3 p2 is finished with execution Timer 3 P1 P2 2 3

7 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 So p1 will be continue execution Timer 3 P1 P2 P1 2 3

8 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 4 P1 P2 P1 2 3

9 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 5 P1 P2 P1 2 3

10 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 6 P1 P2 P1 2 3

11 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 7 p1 is finished with execution And p3 does not arrive yet Timer 7 P1 P2 P1 2 7 3

12 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 P3 is arrive so it will be execution Timer 8 P1 P2 P1 P3 8 2 7 3

13 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 9 P1 P2 P1 P3 8 2 7 3

14 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 10 p3 is finished with execution Timer 10 P1 P2 P1 P3 8 2 7 10 3

15 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p1 = 7-0=7 P1 P2 P1 P3 2 7 8 10 3

16 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 TAT for p2 = 3-2=1 P1 P2 P1 P3 2 7 8 10 3

17 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 TAT for p3 = 10-8=2 P1 P2 P1 P3 2 7 8 10 3

18 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p1=7-6=1 P1 P2 P1 P3 2 7 8 10 3

19 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p2=1-1=0 P1 P2 P1 P3 2 7 8 10 3

20 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p3=2-2=0 P1 P2 P1 P3 2 7 8 10 3

21 preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 P1 P2 P1 P3 Average TAT=(7+1+2)/3=3.3 Average WT=(1+0+0)/3=0.33 2 7 8 10 3

22 Burst Time (millisecond)
Question 1 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using NON- preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5

23 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer P1

24 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 1 P1

25 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 2 P1

26 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 3 P1

27 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 4 P1

28 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 5 P1

29 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 6 p1 finished execution 6 P1 P2 6

30 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 7 p2 finished execution 7 P1 P2 6 7

31 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 8 p3 will be execution 8 P1 P2 6 7 8

32 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 9 P1 P2 p3 6 7 8

33 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 10 P1 P2 p3 6 7 8 10

34 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p1 = 6-0=6 P1 P2 p3 6 7 8 10

35 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p2 = 7-2=5 P1 P2 p3 6 7 8 10

36 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 TAT for p3 = 10-8=2 P1 P2 p3 6 7 8 10

37 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 WT for p1 = 6-6=0 P1 P2 p3 6 7 8 10

38 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 WT for p2= 5-1=4 P1 P2 p3 6 7 8 10

39 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 4 P3 8 WT for p3=2-2=0 P1 P2 p3 6 7 8 10

40 Non-preemptive Priority algorithm
Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 4 P3 8 Average TAT=(6+5+2)/3=4.33 Average WT=(0+4+0)/3=1.33 P1 P2 p3 6 7 8 10

41 D. For the given set of processes , which algorithm is better? Why?
Non-preemptive Priority algorithm preemptive Priority algorithm Average TAT=(6+5+2)/3=4.33 Average WT=(0+4+0)/3=1.33 Average TAT=(7+1+2)/3=3.3 Average WT=(1+0+0)/3=0.33 By Comparing Waiting Time and Turnaround Time So , the Preemptive algorithm is better

42 Burst Time (millisecond)
Question 2 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3

43 Round-Robin algorithm where time quantum=5 millisecond.
Timer Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

44 Round-Robin algorithm where time quantum=5 millisecond.
Timer 1 Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

45 Round-Robin algorithm where time quantum=5 millisecond.
Timer 2 Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

46 Round-Robin algorithm where time quantum=5 millisecond.
Timer 3 Queue : P1 p2 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

47 Round-Robin algorithm where time quantum=5 millisecond.
Timer 4 Queue : P1 p2 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

48 Round-Robin algorithm where time quantum=5 millisecond.
Timer 5 Queue : P1 P2 p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1 5

49 Round-Robin algorithm where time quantum=5 millisecond.
Timer 6 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 5 6

50 Round-Robin algorithm where time quantum=5 millisecond.
Timer 7 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 5 7 6

51 Round-Robin algorithm where time quantum=5 millisecond.
Timer 8 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 P3 5 6 7

52 Round-Robin algorithm where time quantum=5 millisecond.
Timer 9 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 P3 5 6 7 9

53 Round-Robin algorithm where time quantum=5 millisecond.
Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 P2 2 1 P3 WT for p1=(0-0)+(6-5)=1 P1 P2 P1 P3 5 6 7 9

54 Round-Robin algorithm where time quantum=5 millisecond.
Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 P3 WT for p2=(5-2)=3 P1 P2 P1 P3 5 6 7 9

55 Round-Robin algorithm where time quantum=5 millisecond.
Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 3 P3 WT for p3=(7-6)=1 P1 P2 P1 P3 5 6 7 9

56 Round-Robin algorithm where time quantum=5 millisecond.
Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 3 P3 Average WT =(1+3+1)/3 =1.67 P1 P2 P1 P3 5 6 7 9

57 Burst Time (millisecond)
Draw the Gantt Charts that illustrates the execution of these processes using FCFS algorithm , preemptive SJF and Non- preemptive SJF Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3

58 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

59 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 1 P1

60 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 2 P1

61 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 3 P1

62 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 4 P1

63 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 5 P1

64 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6 P1 P2 6

65 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 7 P1 P2 6 7

66 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 8 P1 P2 P3 6 7

67 The FCFS algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 9 P1 P2 P3 6 7 9

68 The FCFS algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 P1 P2 P3 WT for p1 =0-0=0 6 7 9

69 The FCFS algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 P1 P2 P3 WT for p2 =6-2=4 6 7 9

70 The FCFS algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 P1 P2 P3 WT for p3 =7-6=1 6 7 9

71 The FCFS algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 P1 P2 P3 Average WT =(0+4+1)/3=1.67 6 7 9

72 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

73 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 1 P1

74 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 2 P2 shorter than p1 P1 P2 2

75 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 3 6-2=4 P1 P2 P1 2 3

76 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 4 6-2=4 P1 P2 P1 2 3

77 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 5 6-2=4 P1 P2 P1 2 3

78 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6 6-2=4 P1 P2 P1 2 3

79 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 7 6-2=4 P1 P2 P1 P3 2 3 7

80 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 8 6-2=4 P1 P2 P1 P3 2 3 7

81 The preemptive SJF (short job first) algorithm Gantt Chat is :
Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 9 6-2=4 P1 P2 P1 P3 2 3 7 9

82 The preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p1 =(0-0)+(3-2)=1 P1 P2 P1 P3 2 3 7 9

83 The preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 WT for p2= 2-2=0 P1 P2 P1 P3 2 3 7 9

84 The preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 WT for p3=7-6=1 P1 P2 P1 P3 2 3 7 9

85 The preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 Average WT=(1+0+1)/3=0.67 P1 P2 P1 P3 2 3 7 9

86 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer P1

87 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 1 P1

88 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 2 P1

89 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 3 P1

90 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 4 P1

91 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 5 P1

92 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 6 P2 is shorter than p3 P1 P2 6

93 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 7 P1 P2 6 7

94 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 8 P1 P2 P3 6 7

95 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 9 P1 P2 P3 6 7 9

96 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p1=0-0=0 P1 P2 P3 6 7 9

97 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p2=6-2=4 P1 P2 P3 6 7 9

98 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 WT for p3=7-6=1 P1 P2 P3 6 7 9

99 The Non-preemptive SJF (short job first) algorithm Gantt Chat is :
Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 Average WT=(0+4+1)/3=1.67 P1 P2 P3 6 7 9

100 Question 2 cont. D. For the given set of processes and algorithms which algorithm is better? Why? preemptive SJF (short job first) algorithm Non-preemptive SJF (short job first) algorithm FCFS algorithm Average WT =(0+4+1)/3= 1.67 Average WT=(1+0+1)/3=0.67 Average WT=(0+4+1)/3=1.67 By Comparing Waiting Time So , the Preemptive SJF algorithm is better


Download ppt "Exercise Ms.Reema alOraini"

Similar presentations


Ads by Google