Presentation on theme: "Washington WASHINGTON UNIVERSITY IN ST LOUIS Resource and Resource Access Control Fred Kuhns Applied Research Laboratory Computer Science and Engineering."— Presentation transcript:
Washington WASHINGTON UNIVERSITY IN ST LOUIS Resource and Resource Access Control Fred Kuhns Applied Research Laboratory Computer Science and Engineering Washington University in St. Louis
2 Fred Kuhns (6/5/2014)CS523 – Operating Systems Blocking Time Higher priority job is blocked by a lower priority job during a nonpreemptive interval: priority inversion. Nonpreemptivity: –b i (nb) = max(q k ), i+1 k n, q k e i Self-Suspension –b i (ss) = max SS of T i + sum[min(e k, max SS of T k ),k=1 to k=(i-1)] Context Switch –b i (cs) = 2CS
3 Fred Kuhns (6/5/2014)CS523 – Operating Systems Time Demand Analysis Updated TDA equation to include blocking time. But what about resource contention? w i (t) = e i + b i (ss) + (K i + 1)b i (np) + 2(K i + 1)CS + k = 1 i - 1 t pkpk ekek
4 Fred Kuhns (6/5/2014)CS523 – Operating Systems Effects of Resource Contention Add new term for blocking –b i (rb) Priority Inversion –Uncontrolled priority inversion Timing Anomalies –Resulting from priority inversion Deadlock –Circular wait
5 Fred Kuhns (6/5/2014)CS523 – Operating Systems Resource Access Protocols Resource Access protocol –Granting resource access requests –Scheduling of jobs which request resources Goals: –Bound delay due to Priority Inversion and Timing Anomalies –Prevent Deadlock Three Examples: –Nonpreemptive Critical Sections No deadlock, No uncontrolled Priority Inversion –Priority Inheritance Protocol Deadlock, No uncontrolled Priority Inversion –Priority Ceiling Protocol No deadlock, No uncontrolled Priority Inversion
6 Fred Kuhns (6/5/2014)CS523 – Operating Systems Some Notation J i is the i th job in Task T. Shorthand for J ji i = Assigned priority of Job J i ; i (t) = current priority of J i If the decision to change the priority of Job J i is made at t = t 1 then –t - = t - and t + = t + ; – i (t 1 - ) = priority at and immediately before t 1, – i (t 1 + ) = priority immediately after the priority change = nonexistent priority, lower than the lowest priority At time t 1 Job J i requests resource R k. –R k J l : Resource R k is held by Job J l –J i R k : J i blocked on R k (J i R k J l ) General scheduling and allocation assumptions: –Scheduling Rules: Ready Jobs scheduled on processors preemptively in a priority driven manner according to their current priorities, i (t). At Job release time the priority is equal to its assigned priority: if J i released at t, then i (t) = i –Resource allocation: If a resource is free then it is allocated when requested if not free then the request is denied and the requesting job is blocked
7 Fred Kuhns (6/5/2014)CS523 – Operating Systems Nonpreemptive Critical Sections Protocol Blocking time is bounded: b i (rc)=max(c k ) for k = i+1,...,n and c k is the max critical section time of any job in task T k. NCSP Rule: –If J i holds a resource it effectively has the highest priority in the system: i.e. it will not be preempted while holding a resource. So no deadlock. Assessment: –Advantage: simple and does not require prior knowledge of resource usage. Bounds delays and prevents deadlock. –Disadvantage, every job can be blocked by a lower priority job regardless of whether it contends for the same resources.
8 Fred Kuhns (6/5/2014)CS523 – Operating Systems Priority Inheritance Rules (PI) Scheduling Rule: consistent with assumptions Allocation Rule: consistent with assumptions Priority-Inheritance Rule: if J i R k J l and l (t 1 - ) < i (t 1 ) then l (t 1 + ) = i (t 1 ) until J l releases R k when l (t 2 + ) = l (t 1 - ) Assessment: –simple and works with any priority driven scheduler. Does not require foreknowledge. When no deadlock, no unbounded delay. –Two types of blocking: Direct and Priority Inheritance blocking –PI has the transitive property. –Does not result in minimal blocking time –Does not prevent deadlock
9 Fred Kuhns (6/5/2014)CS523 – Operating Systems Basic Priority Ceiling Rules Extends PI to prevent deadlock and reduce blocking time Assumptions: –general scheduling rule; fixed assigned priorities; resource requirements of tasks known – (R k )=priority ceiling for R k =max( i ) for all J i requiring R k –System priority ceiling = (t)=max[ (R k )] for all R k in use at time t. If no resource in use then (R k ) = Allocation Rule (J i requests R k at time t=t 1 ): –if J i R k J l at t = t 1 then block J i (no change) –else (R k free at t 1 ) if i (t 1 ) > (t), then R k J i else if for some R x J i and (R x ) = (t 1 ), then R k J i else deny and block ( J i R k ) Priority-Inheritance Rule: –if J i blocks on resource R k held by J l ( J i R k ) (note: R k J l and l (t 1 - )=priority of J l at t = t 1 - ) then l (t 1 + ) = i (t 1 ) (inherited priority) until J l releases all R x with (R x ) (t 1 ) at t = t 2, l (t 2 + ) = l (t 1 - )
10 Fred Kuhns (6/5/2014)CS523 – Operating Systems Comparisons Priority Ceiling –No deadlocks: Priority ceilings impose order on resources –bounded blocking time by at most the duration of one critical section. –Priority inheritance is greedy while priority ceiling is not –If π (t) of a Job J is > (t) then neither J nor any other job with priorities π (t) need any resource currently in use. JiJi RJkJk JhJh RJlJl JiJi RJkJk X Avoidance Blocking (Priority Ceiling Blocking) (X) π i (t) Directly Blocked Priority Inheritance blocking high priority job block by lower priority job that inherited a higher priority. π h >π l, π k >π l and π h >π k. But the current priority of J l, π h (t)=π h so J k is blocked from running. JkJk
11 Fred Kuhns (6/5/2014)CS523 – Operating Systems Stack-Based Priority Ceiling Protocol Update Current Ceiling in the usual manner –When no resources are held the (t) = –otherwise, (t) = max[ (R k )] for all R k in use at time t. Scheduling Rule: –when J i released it is blocked until its assigned priority = i (t) > (t) –When not blocked jobs are scheduled in a priority- driven, preemptive manner according to their assigned priorities. Allocation Rule: –Allocate when requested
12 Fred Kuhns (6/5/2014)CS523 – Operating Systems Stack-based Priority Ceiling Assume jobs never self suspend After a job is released, when it begins to execute all the resources it needs are free no job is ever blocked once its execution begins when a job is preempted, all the resources needed by the preempting job are available deadlock will not occur Has the same worst-case performance as the basic priority ceiling protocol
13 Fred Kuhns (6/5/2014)CS523 – Operating Systems Ceiling-Priority Protocol Update Current Ceiling in the usual manner If jobs never self suspend then the stack-based priority- ceiling and ceiling-priority protocols produce the same schedules. maximum blocking time is same as stack-based and basic priority ceiling protocols. Scheduling Rule: –No resources held then schedule according to assigned priorities (J i has priority i (t) = i ). Jobs with same priority are scheduled in FIFO order. –When a job, J i, holds one or more resources then its priority i (t) = max( (R x )) for all resource R x held by J i Allocation Rule: –Allocate when requested
14 Fred Kuhns (6/5/2014)CS523 – Operating Systems Comparison worst case performance of stack-based and basic ceiling protocols are the same stack-based version –supported by the Real-Time systems Annex of Ada95 –Jobs must not self-suspend when jobs do not self-suspend, stack-based and ceiling-priority protocols yield the same schedules. stack-based and ceiling-priority have the same worst- case blocking time.
Your consent to our cookies if you continue to use this website.