Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI.

Similar presentations


Presentation on theme: "CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI."— Presentation transcript:

1 CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI

2 2.3.4 Round-Robin Scheduling (RRS)  In RRS algorithm the ready queue is treated as a FIFO circular queue.  The RRS traces the ready queue allocating the processor to each process for a time interval which is smaller than or equal to a predefined time called time quantum (slice). 1

3 2.3.4 Round-Robin Scheduling (RRS)  The OS using RRS, takes the first process from the ready queue, gives the processor to that process and sets a timer to interrupt when time quantum expires.  If the process has a processor burst time smaller than the time quantum, then it releases the processor voluntarily, either by terminating or by issuing an I/O request.  The OS then proceed with the next process in the ready queue. 2

4 2.3.4 Round-Robin Scheduling (RRS)  The performance of RRS depends heavily on the selected time quantum.  Time quantum    RRS becomes FCFS  Time quantum  0  RRS becomes processor sharing (It acts as if each of the n processes has its own processor running at processor speed divided by n)  However, if time quantum is too small then context switch time can not be ignored anymore.  For an optimum time quantum, it can be selected to be greater than 80 % of processor bursts and to be greater than the context switching time. 3

5 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 44 4 B28 : 81 -- C32 : 21 -- D71 : 11 1 RQ : A:4:4Proc in CPU:Q:3 : 0 FCFS RR next_cpu_burst : remaining_time Time quantum used 4

6 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 244 : 44 B28 : 81 -- C32 : 21 -- D71 : 11 1 RQ : B:8:8Proc in CPU:A:4:2Q:3 : 2 FCFS RR next_cpu_burst : remaining_time 5

7 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 81 -- C32 : 21 -- D71 : 11 1 RQ : B:8:8C:2:2A:4:1Proc in CPU:A:4:1Q:3 : 3 expires preemption p 6

8 2.2 Process States If more than one processes are to enter the Ready Queue at the same time then give priority as: 1: process just submitted 2: process completed I/O 3: process preempted CPU I/O requested I/O completed START WAITING READY RUNNING HALTED preeemption 132 7

9 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : 21 -- D71 : 11 1 RQ : C:2:2A:4:1B:8:5Proc in CPU:B:8:5Q:3 : 3 expires preemption pp 8

10 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : 112 : 2-- D71 : 11 1 RQ : A:4:1B:8:5D:1:1Proc in CPU:C:2:1Q:3 : 1 expires pp 9

11 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 144 : 44 B28 : 518 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : A:4:1B:8:5D:1:1Proc in CPU:Q:3 : 0 expires pp 10

12 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 518 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : B:8:5D:1:1C:2:2Proc in CPU:Q:3 : 0 expires pp 11

13 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 2-- D71 : 11 1 RQ : D:1:1C:2:2B:8:2Proc in CPU:B:8:2Q:3 : 3 expires pp preemption p 12

14 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 2-- D71 : 011 : 11 RQ : C:2:2B:8:2A:4:4Proc in CPU:Q:3 : 0 expires ppp 13

15 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 012 : 1-- D71 : 011 : 11 RQ : B:8:2A:4:4D:1:1Proc in CPU:C:2:1Q:3 : 1 expires ppp 14

16 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 218 : 8-- C32 : 01 -- D71 : 011 : 11 RQ : B:8:2A:4:4D:1:1Proc in CPU:Q:3 : 0 expires ppp 15

17 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 44 B28 : 018 : 8-- C32 : 01 -- D71 : 011 : 11 RQ : A:4:4D:1:1Proc in CPU:Q:3 : 0 expires ppp 16

18 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 344 : 4 B28 : 018 : 8-- C32 : 01 -- D71 : 011 : 11 RQ : D:1:1B:8:8Proc in CPU:A:4:3Q:3 : 1 expires ppp 17

19 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 8-- C32 : 01 -- D71 : 011 : 11 RQ : D:1:1B:8:8A:4:1Proc in CPU:A:4:1Q:3 : 3 expires ppp preemption p 18

20 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 8-- C32 : 01 -- D71 : 01 11 : 1 RQ : B:8:8A:4:1Proc in CPU:Q:3 : 0 expires pppp 19

21 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 7-- C32 : 01 -- D71 : 01 11 : 1 RQ : A:4:1D:1:1Proc in CPU:B:8:7Q:3 : 1 expires pppp 20

22 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 044 : 144 : 4 B28 : 018 : 5-- C32 : 01 -- D71 : 01 11 : 1 RQ : A:4:1D:1:1B:8:5Proc in CPU:B:8:5Q:3 : 3 expires ppppp preemption 21

23 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 44 : 4 B28 : 018 : 5-- C32 : 01 -- D71 : 01 11 : 1 RQ : D:1:1B:8:5Proc in CPU:Q:3 : 0 expires ppppp 22

24 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 44 : 4 B28 : 018 : 5-- C32 : 01 -- D71 : 01 1 RQ : B:8:5Proc in CPU:Q:3 : 0 expires ppppp 23

25 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 44 : 4 B28 : 018 : 2-- C32 : 01 -- D71 : 01 1 RQ : A:4:4B:8:2Proc in CPU:B:8:2Q:3 : 0 expires ppppp preemption p 24

26 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 44 : 1 B28 : 018 : 2-- C32 : 01 -- D71 : 01 1 RQ : B:8:2A:4:1Proc in CPU:A:4:1Q:3 : 3 expires ppppp preemption pp 25

27 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 44 : 1 B28 : 01 -- C32 : 01 -- D71 : 01 1 RQ : A:4:1Proc in CPU:Q:3 : 0 expires ppppppp 26

28 2.3.4 Round-Robin Scheduling (RRS) ProcessArrival time 1 st exec1 st I/O2 nd exec2 nd I/O3 rd exec A04 : 04 4 B28 : 01 -- C32 : 01 -- D71 : 01 1 RQ : Proc in CPU:Q:3 : 0 expires ppppppp 27

29 2.3.4 Round-Robin Scheduling (RRS)  Processor utilization = (35 / 35) * 100 = 100 %  Throughput = 4 / 35 ppppppp 28

30 2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = (35 + 32 + 12 + 19) / 4 = 24. p pppppp 29

31 2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = (35 + 32 + 12 + 19) / 4 = 24. p pppppp 30

32 2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = (35 + 32 + 12 + 19) / 4 = 24. p pppppp 31

33 2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = (35 + 32 + 12 + 19) / 4 = 24. p pppppp 32

34 2.3.4 Round-Robin Scheduling (RRS)  Turn around time: tat A = 35 – 0 = 35 tat B = 34 – 2 = 32 tat C = 15 – 3 =12 tat D = 26 – 7 = 19 tat AVG = (35 + 32 + 12 + 19) / 4 = 24 p pppppp 33

35 2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = (15 + 12 + 7 + 11) / 4 = 11.25 p pppppp 34

36 2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = (15 + 12 + 7 + 11) / 4 = 11.25 p pppppp 35

37 2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = (15 + 12 + 7 + 11) / 4 = 11.25 p pppppp 36

38 2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = (15 + 12 + 7 + 11) / 4 = 11.25 p pppppp 37

39 2.3.4 Round-Robin Scheduling (RRS)  Waiting time: wt A = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15 wt B = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15 wt C = (6 – 3) + (13 – 9) = 7 wt D = (12 – 7) + (20 – 14) + (25 – 22) = 14 wt AVG = (15 + 12 + 7 + 11) / 4 = 11.25 p pppppp 38

40 2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = (0 + 1 + 3 + 5) / 4 = 2.25 p pppppp 39

41 2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 3 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = (0 + 1 + 3 + 5) / 4 = 2.25 p pppppp 40

42 2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = (0 + 1 + 3 + 5) / 4 = 2.25 p pppppp 41

43 2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 36 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = (0 + 1 + 3 + 5) / 4 = 2.25 p pppppp 42

44 2.3.4 Round-Robin Scheduling (RRS)  Response time: rt A = 0 – 0 = 0 rt B = 3 – 2 = 1 rt C = 6 – 3 = 3 rt D = 12 – 7 = 5 rt AVG = (0 + 1 + 3 + 5) / 4 = 2.25 p pppppp 43

45 2.3.4 Round-Robin Scheduling (RRS)  In Round Robin Scheduling it is guaranteed that rt max ≤ (n-1)*Q where n : multiprogramming degree Q: time quantum 44

46 comparison FCFSSPFSRTFRR tat avg 28.2523.5018.7524.50 wt avg 16.5010.50 6.2512.25 rt avg 4.50 3.00 1.25 2.25 Easy to implement Not possible to know next CPU burst exactly, it can only be guessed Implementable, rt max is important for interactive systems 45

47 2.3.5 Priority Scheduling  In this type of algorithms a priority is associated with each process and the processor is given to the process with the highest priority. Equal priority processes are scheduled with FCFS method.  To illustrate, SPF is a special case of priority scheduling algorithm where Priority(i) = 1 / next processor burst time of process i or Priority(i) = K - next processor burst time of process i 46

48 2.3.5 Priority Scheduling  Priorities can be fixed externally or they may be calculated by the OS from time to time.  Externally, if all users have to code time limits and maximum memory for their programs, priorities are known before execution.  Internally, a next processor burst time prediction such as that of SPF can be used to determine priorities dynamically. 47

49 2.3.5 Priority Scheduling  A priority scheduling algorithm can leave some low-priority processes in the ready queue indefinitely.  If the system is heavily loaded, it is a great probability that there is a higher-priority process to grab the processor.  This is called the starvation problem.  One solution for the starvation problem might be to gradually increase the priority of processes that stay in the system for a long time. 48

50 2.3.5 Priority Scheduling Example: Following may be used as a priority defining function: Priority (i) = 10 + t now – t s (i) – t rq (i) – t cpu (i) Where t s (i): the time process n is submitted to the system T rq (i): the time process n entered to the ready queue last time T cpu (i): next processor burst length of process n t now : current time  P(i)=t now – t rq (i)≈FCFS  P(i)=K – t cpu (i)≈SPF  P(i)= α (t now – t rq (i))+(1- α )(K – t cpu (i)), ≈combination of FCFS & SPF 49


Download ppt "CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI."

Similar presentations


Ads by Google