• No results found

lecture 11 chapter 2

N/A
N/A
Protected

Academic year: 2020

Share "lecture 11 chapter 2"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

07/10/2020 1

Lecture 11

Chapter 2

Processes and Threads

discover yourself

(2)

Three- level Scheduling

discover yourself

(3)

10/07/2020 3

Robin (RR) Scheduling

Processes are dispatched in a FIFO manner

but are given a limited amount of CPU time

called a time-slice or a quantum.

discover yourself

(4)

Robin (RR) Scheduling

1.

list of runable processes

2.

list of runable processes after B uses up its quantum

3.

Length of quantum too short means too much context switching.

discover yourself

(5)

10/07/2020 5

Example: The time slot could be 100 milliseconds. If a job1 takes a total time of 250ms to complete, the round-robin scheduler will suspend the job after 100ms and give other jobs their time on the CPU. Once the other jobs have had their equal share (100ms each), job1 will get another allocation of CPU time and the cycle will repeat. This process continues until the job finishes and needs no more time on the CPU.

Job1 = Total time to complete 250ms (quantum 100ms). 1.First allocation = 100ms.

2.Second allocation = 100ms.

3.Third allocation = 100ms but job1 self-terminates after 50ms. 4.Total CPU time of job1 = 250ms.

Round Robin (RR) Scheduling

discover yourself

(6)

Round Robin (RR) Scheduling

APPLICATION

Using round-robin scheduling allots a slice of time to each

process that is running. In a computer for example, the user

starts three applications,

Email

, a web browser, and a

word processor

. These applications are loaded into system

memory as processes and each is allowed to run without the

user considering which applications are running in the

background.

discover yourself

(7)

10/07/2020 7

Burst Waiting Turnaround Process Time Time Time

P1 24 6 30

P2 3 4 7

P3 3 7 10

Average - 5.66 15.66

Time Quantum= 4ms (without priority)

discover yourself

(8)

Time Quantum= 1ms (without priority)

discover yourself

(9)

10/07/2020 9

discover yourself

inspire posterity

Process

Burst

P1

8

P2

6

P3

1

P4

9

P5

3

Q-

Assume that you have the following processes all arriving at

time 0:

(10)

discover yourself

inspire posterity

Process B.T Priority W.T T.T

P1 8 4 12 20

P2 6 1 16 22

P3 1 2 8 9

P4 9 2 18 27

P5 3 3 13 16

average     67/5=13.4 94/5=18.8

P1

P2

P3

P4

P5

P1

P2

P4

P4

0         4        8       9         13         16      20 22         26        27

(11)

10/07/2020 11

discover yourself

inspire posterity

Process

Burst

Priority

P1

8

4

P2

6

1

P3

1

2

P4

9

2

P5

3

3

Q-

Assume that you have the following processes all arriving at

time 0:

(12)

discover yourself

inspire posterity

P2

P3

P4

P5

P1

P2

P4

P1

P4

0         4       5       9      12        16        18         22        26     27

Process B.T Priority W.T T.T

P2 6 1 12 18

P3 1 2 4 5

P4 9 2 18 27

P5 3 3 9 12

P1 8 4 18 26

average     12.2 17.6

(13)

10/07/2020 13

Time Quantum= 2ms (without priority)

discover yourself

inspire posterity

Process

Arrival

Burst Time

P1

0

3

P2

1

2

P3

2

1

Total Waiting Time = (WT of Process 1)+ (WT of Process 2) + (WT of Process 3) = (3+1+2)s

(14)

discover yourself

inspire posterity

Processes Burst time Arrival time

P1 8 0.0

P2 4 1.0

P3 2 2.0

P4 5 3.0

Q-

Assume that you have following processes with arrival time and burst time given in milliseconds.

Draw a Gantt chart to determine average process waiting time of each process using round robin scheduling algorithm (Quantum Time = 2ms). Ignore process switching overhead.

(15)

10/07/2020 15

Priority Scheduling

1. Each process is assigned a priority, and priority is

allowed to run. Equal-Priority processes are

scheduled in FCFS order.

2. The shortest-Job-First (SJF) algorithm is a special

case of general priority scheduling algorithm.

discover yourself

(16)

Priority Scheduling

discover yourself

(17)

10/07/2020 17

Burst   Waiting Turnaround

Process Time Priority Time Time

P1 10 3 6 16

P2 1 1 0 1

P3 2 4 16 18

P4 1 5 18 19

P5 5 2 1 6

Average - - 8.2 12

discover yourself

inspire posterity

(18)

discover yourself

(19)

10/07/2020 19

discover yourself

inspire posterity

Process Priority AT BT

P1 2 0 4

P2 4 1 2

P3 6 2 3

P4 10 3 5

P5 8 4 1

P6 12 5 4

P7 9 6 6

Priority Scheduling-Non-Preemptive

EXAMPLE-3

(20)

discover yourself

inspire posterity

P1

P4

P6

P7

P5

P3

P2

Process W.T TAT

P1 0 4

P2 22 24

P3 18 21

P4 1 6

P5 15 16

Priority Scheduling-Non-Preemptive

SOLUTION

(21)

10/07/2020 21

discover yourself

inspire posterity

Process Priority AT BT

P1 2 0 4

P2 4 1 2

P3 6 2 3

P4 10 3 5

P5 8 4 1

P6 12 5 4

P7 9 6 6

Priority Scheduling-Preemptive

EXAMPLE- 4

(22)

discover yourself

inspire posterity

P1

P2

P3

P4

P6

P4

P7

P5

P3

P2

P1

Process W.T TAT RT

P1 21 25 0

P2 19 21 0

P3 16 19 0

P4 4 9 0

P5 14 15 14

Priority Scheduling-Preemptive

SOLUTION

(23)

10/07/2020 23

Priority Scheduling

In this example, Tasks B and C are at the same priority, which is higher than that of Task A.

Task A is running when Task B becomes ready to run. Task A is preempted so that Task B can run. While Task B is running, Task C also becomes ready to run. The scheduler therefore allows Task B to run for a time slice period. After this period expires, the scheduler gives Task C an opportunity to run. Then Task C completes its work. Because Task B still has work to complete and has the highest priority of all ready tasks, the scheduler allows Task B to run. Once Task B completes its work, Task A can finish.

discover yourself

(24)

HOME READING

HOME READING

1. Multiple Queues Scheduling

2. Fair Share Scheduling

discover yourself

(25)

07/10/2020 25

End of Chapter 2

discover yourself

References

Related documents

The Compliance paper was intended to provide high-level principles on banks’ management of compliance risks, which the Committee defines as “the risk of legal or regulatory sanctions,

TABLE V - Mean concentrations of curcuminoid pigments in pig ear skin (µg pigment/g skin) during in vitro skin permeation studies of different formulations containing curcumin

Open collector output 48V, 50mA or less 26 Speed agree detection Activates when the freq.. Figure 13 Control Circuit Terminal Arrangement.. .39 Digital Operator Display at

In the task, the workers will see a short video snippet of five seconds and are asked to identify semantic events and mark the team, the time, and the position on the field of the

• They have been at their chamber 11-15 years • They receive an average of 24 vacation days • They oversee a staff of 4.75 FTEs. • They have

This conclusion is further supported by the following observations: (i) constitutive expression of stdE and stdF in a Dam + background represses SPI-1 expression (Figure 5); (ii)

profits of competitors: neither for the insider firms, whose joint profits even the sum of insiders’ pre- merger profits, since * * ; nor for the outsider whose

lower for the high CR rates. In the low density case, the OH abundance increases with CR rate in the radical region, since the temperature increases about an order of magnitude.