40
CHAPTER 2 PROCESSOR SCHEDULING PART II by Ugur HALICI

CHAPTER 2 PROCESSOR SCHEDULING PART II

  • Upload
    leland

  • View
    39

  • Download
    1

Embed Size (px)

DESCRIPTION

CHAPTER 2 PROCESSOR SCHEDULING PART II. by Ugur HALICI. 2.5 Processor Scheduling algorithms. The goal of a scheduling algorithm is to select the most appropriate process in the ready queue. For simplicity, we will assume that we have a single I/O server and a single device queue , - PowerPoint PPT Presentation

Citation preview

Page 1: CHAPTER 2 PROCESSOR SCHEDULING PART II

CHAPTER 2PROCESSOR SCHEDULINGPART II

by Ugur HALICI

Page 2: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.5 Processor Scheduling algorithms2

The goal of a scheduling algorithm is to select the most appropriate process in the ready queue.

For simplicity, we will assume that we have a single I/O server and a single

device queue, device queue always implemented with

FCFS (FIFO) method. We also will neglect the switching time

between processes (context switching).

Page 3: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.5 Processor Scheduling algorithms3

We will consider the following processes and will apply different scheduling algorithms on it.Process Arrival

time1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4

B 2 8 1 8 - -

C 3 2 1 2 - -

D 7 1 1 1 1 1

Page 4: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 4

In this algorithm, the process to be selected is the process which requests the processor first.

This is the process whose PCB is at the head of the ready queue.

Contrary to its simplicity, its performance may often be poor compared to other algorithms.

Page 5: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 5

FCFS may cause processes with short processor bursts to wait for a long time.

If one process with a long processor burst gets the processor, all the others will wait for it to release it and the ready queue will be crowded.

This is called the convoy effect.

Page 6: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 6

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

A

Page 7: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 7

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

B

Page 8: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 8

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

B C

Page 9: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 9

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

B C

Page 10: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 10

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

C D

Page 11: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 11

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

C D A

Page 12: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 12

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

C D A

Page 13: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 13

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

D A B

Page 14: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 14

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

D A B

Page 15: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 15

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

A B C

Page 16: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 16

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

B C D

Page 17: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 17

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

B C D

Page 18: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 18

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

C D A

Page 19: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 19

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

C D A

Page 20: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 20

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

RQ:

D A

Page 21: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 21

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

Page 22: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 22

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

Page 23: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 23

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

Page 24: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 24

Process Arrival time

1st exec 1st I/O 2nd exec 2nd I/O 3rd exec

A 0 4 4 4 4 4B 2 8 1 8 - -C 3 2 1 2 - -D 7 1 1 1 1 1

Page 25: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 25

Processor utilization = (35 / 35) * 100 = 100 % Throughput = 4 / 35=0.11

Page 26: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 26

Turn around time:tatA = 34 – 0 = 34

tatB = 27 – 2 = 25

tatC = 29 – 3 = 26

tatD = 35 – 7 = 28 

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

Page 27: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 27

Turn around time:tatA = 34 – 0 = 34

tatB = 27 – 2 = 25

tatC = 29 – 3 = 26

tatD = 35 – 7 = 28 

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

Page 28: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 28

Turn around time:tatA = 34 – 0 = 34

tatB = 27 – 2 = 25

tatC = 29 – 3 = 26

tatD = 35 – 7 = 28 

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

Page 29: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 29

Turn around time:tatA = 34 – 0 = 34

tatB = 27 – 2 = 25

tatC = 29 – 3 = 26

tatD = 35 – 7 = 28 

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

Page 30: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 30

Turn around time:tatA = 34 – 0 = 34

tatB = 27 – 2 = 25

tatC = 29 – 3 = 26

tatD = 35 – 7 = 28 

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

Page 31: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 31

Waiting time:wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14

wtB = (4 – 2) + (19 – 13) = 8

wtC = (12 – 3) + (27 – 15) = 21

wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

 

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

Page 32: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 32

Waiting time:wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14

wtB = (4 – 2) + (19 – 13) = 8

wtC = (12 – 3) + (27 – 15) = 21

wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

 

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

Page 33: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 33

Waiting time:wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14

wtB = (4 – 2) + (19 – 13) = 8

wtC = (12 – 3) + (27 – 15) = 21

wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

 

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

Page 34: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 34

Waiting time:wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14

wtB = (4 – 2) + (19 – 13) = 8

wtC = (12 – 3) + (27 – 15) = 21

wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

 

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

Page 35: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 35

Waiting time:wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14

wtB = (4 – 2) + (19 – 13) = 8

wtC = (12 – 3) + (27 – 15) = 21

wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

 

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

Page 36: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 36

Response time:rtA = 0 – 0 = 0

rtB = 4 – 2 = 2

rtC = 12 – 3 = 9

rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

Page 37: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 37

Response time:rtA = 0 – 0 = 0

rtB = 4 – 2 = 2

rtC = 12 – 3 = 9

rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

Page 38: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 38

Response time:rtA = 0 – 0 = 0

rtB = 4 – 2 = 2

rtC = 12 – 3 = 9

rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

Page 39: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 39

Response time:rtA = 0 – 0 = 0

rtB = 4 – 2 = 2

rtC = 12 – 3 = 9

rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

Page 40: CHAPTER 2 PROCESSOR SCHEDULING PART II

2.3.1 First-Come-First-Served (FCFS) 40

Response time:rtA = 0 – 0 = 0

rtB = 4 – 2 = 2

rtC = 12 – 3 = 9

rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5