+ All Categories
Home > Documents > Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical...

Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical...

Date post: 30-Mar-2015
Category:
Upload: brent-kearley
View: 219 times
Download: 1 times
Share this document with a friend
Popular Tags:
25
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot be preempted until it finishes the critical section Priority Inheritance Protocol (for static scheduled systems) A job that is blocking a high priority job that seek the critical section, has its priority elevated to cause it to finish using the critical section Priority Ceiling Protocol (for static scheduled system) Jobs are not allowed to enter a critical section if there are jobs that can block it. Stack Resource Policy (for static or dynamic scheduled systems) A job that needs a resource that is not available, is blocked at the time it attempts to preempt, instead of at the later time when it would request the resource
Transcript
Page 1: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Chapter 7 - Resource Access Protocols (Critical Sections)

Protocols:

No Preemptions During Critical Sections Once a job enters a critical section, it cannot be preempted until it finishes the critical section

Priority Inheritance Protocol (for static scheduled systems)

A job that is blocking a high priority job that seek the critical section, has its priority elevated to

cause it to finish using the critical section

Priority Ceiling Protocol (for static scheduled system) Jobs are not allowed to enter a critical section if there are jobs that can block it.

Stack Resource Policy (for static or dynamic scheduled systems) A job that needs a resource that is not available, is blocked at the time it attempts to preempt,

instead of at the later time when it would request the resource

Page 2: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Definitions

Resource Types – private, shared, mutually exclusive

Critical Sections – code executed under mutual exclusion: At most one task can be holding the resource at a given time. All other tasks ready to use the resources are “blocked”

Semaphores - Resource Rk Semaphore Sk

A critical section operating on Rk

Begins with a wait(Sk) End with a signal(Sk)

Page 3: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Critical Sections

Page 4: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Implications

Implications of Critical Sections:

Protocols must include max delays due to potential blocking in worst-case computation times when scheduling.

Leads to necessity for very conservative scheduling to guarantee not missing deadlines.

Page 5: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Blocking

Page 6: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Chained Blocking

Page 7: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inversion

Page 8: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Deadlock

Page 9: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Denying Preemptions during Critical Sections

Denying preemption during execution of a critical section eliminates priority inversion.

Leads to unnecessary blocking (delay) of higher priority tasks.

Page 10: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inheritance Protocol(applicable for fixed priority scheduling – think Rate Monotonic)

Page 11: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inheritance Protocol

Page 12: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inheritance Protocol

Page 13: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inheritance Protocol

Page 14: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Inheritance Protocol

Some Properties:

Page 15: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Ceiling Protocol

(applicable for fixed priority scheduling – again think Rate Monotonic)

Page 16: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Ceiling Protocol

Page 17: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Priority Ceiling Protocol

Some Properties:

Page 18: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy(applicable for fixed or dynamic scheduling – think Rate Monotonic or Earliest Deadline First)

Each task has: A priority pi (assigned either statically or dynamically),

pa > pb means execution of a is more important than b

A preemption level i (assigned statically)

a > b Da < Db (relative deadlines)

Ja can preempt Jb ONLY IF a > b

Preemption levels are static and are used to predict potential blocking in

Page 19: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy

Definitions (Current Ceilings):

Current Resource Ceiling (computed as a function of the units of R that are available):

Denotes the number of units of R that are currently available

Denotes the maximum requirement of job J for R

System Ceiling (the maximum of the current ceilings of all of the resources):

smax{CR1 : I= 1,2,…,m)

i.e., the highest preemption level of those jobs that could be blocked on R

i.e., the maximum of the Current Resource Ceilings

Page 20: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy

Protocol:

A job is not allowed to preempt until:

its priority is the highest among those jobs ready to run, and

its preemption level is higher than the system ceiling

Page 21: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy

Page 22: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy Example

Given: (J1 J2 J3) that share (R1 R2 R3) where:

R1 consists of 3 units, R2 of 1, R3 of 3 ,

and

CR1(3) = max 0 = 0

CR1(2) = max { (J3) } = max {1} = 1

CR1(1) = max { (J2), (J3) } = max { 2, 1} = 2

CR1(0) = max { (J1), (J2), (J3) } = max { 3, 2, 1} = 3

= units available, = maximum requirement for the job

Page 23: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource Policy ExampleProtocol:

A job is not allowed to preempt until:

its priority is the highest among those jobs ready to run,

its preemption level is higher than the system ceiling

t0 : J3 begins executing and the system ceiling = 0 because all resources are completely available.

When J3 enters its first critical section, it takes the unit of R2 . The ceiling is set to the highest preemption level among the tasks that could

be blocked on R2 ; that is s = 2 = 2.

As a consequence, J2 is blocked by the preemption test and J3 continues to execute.

t1 : When J3 enters its nested critical section, taking all units of R1 , the system ceiling is raised to s = 1 = 3 . This causes J1 to be blocked by the

preemption test.

t2 : As J3 releases R1 , the system ceiling becomes s = 2 = 2 (the highest preemption level among tasks that could be blocked on R2 ; thus J1

preempts J3 and starts executing.

Once J1 is started, it is never blocked during its execution because the condition 1 < s guarantees that all the resources needed by

J1 are available.

As J1 terminates, J3 resumes execution and releases resource R2 .

t3 : As R2 is released, the system ceiling returns to zero and J2 can preempt J3 .

Again, once J2 is started, all the resources it needs are available; thus J2 is never blocked.

Page 24: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

Stack Resource PolicyProperties:

Page 25: Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.

The End


Recommended