Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot."— Presentation transcript:

1 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

2 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 R k Semaphore S k A critical section operating on R k Begins with a wait(S k ) End with a signal(S k )

3 Critical Sections

4 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.

5 Blocking

6 Chained Blocking

7 Priority Inversion

8 Deadlock

9 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.

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

11 Priority Inheritance Protocol

12

13

14 Some Properties:

15 Priority Ceiling Protocol (applicable for fixed priority scheduling – again think Rate Monotonic)

16 Priority Ceiling Protocol

17 Some Properties:

18 Stack Resource Policy (applicable for fixed or dynamic scheduling – think Rate Monotonic or Earliest Deadline First) Each task has: A priority p i (assigned either statically or dynamically), p a > p b means execution of a is more important than b A preemption level i (assigned statically) a > b D a < D b (relative deadlines) J a can preempt J b ONLY IF a > b Preemption levels are static and are used to predict potential blocking in

19 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): s max{C R1 : 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

20 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

21 Stack Resource Policy

22 Stack Resource Policy Example Given: (J 1 J 2 J 3 ) that share (R 1 R 2 R 3 ) where: R 1 consists of 3 units, R 2 of 1, R 3 of 3, and C R1 (3) = max 0 = 0 C R1 (2) = max { (J 3 ) } = max {1} = 1 C R1 (1) = max { (J 2 ), (J 3 ) } = max { 2, 1} = 2 C R1 (0) = max { (J 1 ), (J 2 ), (J 3 ) } = max { 3, 2, 1} = 3 = units available,= maximum requirement for the job

23 Stack Resource Policy Example Protocol: 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 t 0 : J 3 begins executing and the system ceiling = 0 because all resources are completely available. When J 3 enters its first critical section, it takes the unit of R 2. The ceiling is set to the highest preemption level among the tasks that could be blocked on R 2 ; that is s = 2 = 2. As a consequence, J 2 is blocked by the preemption test and J 3 continues to execute. t 1 : When J 3 enters its nested critical section, taking all units of R 1, the system ceiling is raised to s = 1 = 3. This causes J 1 to be blocked by the preemption test. t 2 : As J 3 releases R 1, the system ceiling becomes s = 2 = 2 (the highest preemption level among tasks that could be blocked on R 2 ; thus J 1 preempts J 3 and starts executing. Once J 1 is started, it is never blocked during its execution because the condition 1 < s guarantees that all the resources needed by J 1 are available. As J 1 terminates, J 3 resumes execution and releases resource R 2. t 3 : As R 2 is released, the system ceiling returns to zero and J 2 can preempt J 3. Again, once J 2 is started, all the resources it needs are available; thus J 2 is never blocked.

24 Stack Resource Policy Properties:

25 The End


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

Similar presentations


Ads by Google