Presentation is loading. Please wait.

Presentation is loading. Please wait.

Real-Time Process Scheduling Concepts, Design and Implementations

Similar presentations


Presentation on theme: "Real-Time Process Scheduling Concepts, Design and Implementations"— Presentation transcript:

1 Real-Time Process Scheduling Concepts, Design and Implementations
CS 314 Operating Systems Real-Time Process Scheduling Concepts, Design and Implementations Department of Computer Science Southern Illinois University Edwardsville Spring, 2019 Dr. Hiroshi Fujinoki RT_Schedule/000

2 CS 314 Operating Systems Real-Time Systems
= (Computer) systems that are designed to execute “real-time tasks” “Real-time tasks” are activities (or sets of activities) that should (or must) be executed within some time limits. RT_Schedule/001

3 CS 314 Operating Systems Real-Time Systems - as embedded-systems
RT_Schedule/002

4 CS 314 Operating Systems Real-Time Systems
Example: NASA Mars Rover Landing Mission RT_Schedule/003

5 CS 314 Operating Systems Real-Time Systems
Real-time process schedulers schedule processes based on process’ “execution deadlines” RT_Schedule/004

6 CS 314 Operating Systems Real-Time Systems
= (Computer) systems that are designed to execute “real-time tasks” “Real-time tasks” are activities (or sets of activities) that should (or must) be executed within some time limits. The real-time systems that should execute tasks in time limits The real-time systems that must execute tasks in time limits “soft real-time systems” “hard real-time systems”  Determinism “Time limits”  Responsiveness  Response Time RT_Schedule/005

7 CS 314 Operating Systems     Determinism & Responsiveness
Response Time Determinism Responsiveness What are going here? t0 t1 t2 Time A processor is assigned by the short-term scheduler A task arrives (for execution) This task is completed Context Switching  Another task is being executed  Save the process state (and the processor registers) of this process to memory  Process scheduler overhead (the scheduler needs to select who is next)  Load the process state (and its registers) of the next process RT_Schedule/006

8 CS 314 Operating Systems Determinism & Responsiveness Response Time
What makes meeting this deadline difficult?  Accurately predicting how long a task takes is sometime difficult.  A higher-priority task (than this) can preempt this task  Unpredictable interrupts can (will) happen - Hardware interrupt (at clock-ticks from real-time hardware clock) - Software interrupt (“signal” message to a process on “wait”) RT_Schedule/007

9 CS 314 Operating Systems Determinism & Responsiveness Determinism
Time needed before the OS initiates a required task (since a task is requested). “Initiates” here means the task is assigned a processor by the short-term scheduler (not by the long-term scheduler). Important metric for “start deadline” Responsiveness Time the OS completes an initiated task Response-Time = Determinism + Responsiveness RT_Schedule/008

10 CS 314 Operating Systems Four Different Classes of Real-Time Scheduling Table-Driven Priority-Driven  Static Table-Driven Scheduling  Static Priority-Driven Static Scheduling Create a schedule first Real-Time Scheduling Follow the schedule without a change Dynamic Scheduling Planning-Based Best-Effort  Dynamic Planning-Based Scheduling  Dynamic Best-Effort Can create a schedule first Dynamically update the schedule RT_Schedule/009

11 CS 314 Operating Systems Four Different Classes of Real-Time Scheduling = To be discussed  Static Table-Driven Scheduling (a) Completion-Time Earliest-Deadline (b) Start-Time Earliest-Deadline  Static Priority-Driven Scheduling Rate Monotonic Scheduling (RMS)  Dynamic Planning-Based Scheduling  Dynamic Best-Effort Scheduling (a) Priority-Driven Non-Preemptive (b) Priority-Driven Immediate Preemption (c) Priority-Driven Immediate Preemption on (periodic) preemption-points (d) Round-Robin RT_Schedule/010

12 CS 314 Operating Systems  Static Table-Driven Scheduling
- For periodic real-time tasks Event interval should be known for each real-time process Task-processing time should be known Process Arrival Time Execution Time Ending Deadline When to Start    A(1) A(2) A(3) B(1) B(2) 20 40 10 60 50 25 100    The short-term scheduler pre-calculates when to start RT_Schedule/011

13 CS 314 Operating Systems  Static Table-Driven Scheduling
Scheduling happens when:  A new task arrives Completion-time (response time) deadline OR Earliest-Deadline First  A task is completed Preemptive The short-term scheduler pre-calculates this in advance No priority B1 preempted B2 preempted Time 50 100 A1 B1 A2 B1 B1 A3 A3 B2 A4 B2 B2 A5 10 20 30 40 60 70 80 90 110 120 A1(20) B1(50) B1(50) B1(50) B1(50) B2(100) A5(100) B2(100) A2(40) A3(60) B1(50) A3(60) A4(80) B2(100) A3(60) B2(100) A5(100) B2(100) RT_Schedule/012

14 CS 314 Operating Systems  Static Priority-Driven Scheduling
Performs both short/long-term scheduling Rate-Monotonic-Scheduling Priority-based scheduling (for the short-term scheduling) Concept of “rate” in RMS For periodic real-time tasks Rate = 1/P P P Idle Time T1 T2 T3 Time C (Running Time) RMS Assign the highest priority to the process that has the largest rate RT_Schedule/013

15 CS 314 Operating Systems  Static Priority-Driven Scheduling
Short-term Scheduling Long-term Scheduling For each new process i Short-Term Priority H L Rate (=1/P) Calculate the utilization (Ui) as Ui = Ci/Pi RMS-Feasibility Test Then, the RMS long-term scheduler rejects the new process if: RT_Schedule/014

16 CS 314 Operating Systems  Static Priority-Driven Scheduling Processes
Preemptive priority-based scheduling Processes Running Time (C) Task Period (P) Rate (1/P) Priority Process 1 Process 2 Process 3 20 40 100 100 150 350 0.01 0.006 0.002 H L M Long-Term Feasibility Test: =  1.0 =  n(21/n-1) (These three processes are schedulable for MRS) Assign Short-Term Priority: Since 0.2 (P1) < (P2) < (P3) Process 1 Process 2 Process 3 Highest Priority Lowest Priority Medium Priority RT_Schedule/015

17 CS 314 Operating Systems  Static Priority-Driven Scheduling
RMS uses this sufficient condition  Static Priority-Driven Scheduling Processes Running Time (C) Cycle (T) Rate (1/T) Process 1 Process 2 20 100 30 145 Process 3 68 150 0.200 0.206 0.453 Necessary Condition = = 0.859  1.0 Sufficient Condition =  n(21/n-1) = 0.779 RT_Schedule/016

18 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
Task N has the highest priority (a) Priority-Driven Non-Preemptive Meeting responsiveness for task N? Meeting determinism for task N? (Because of non-preemptive) Although N has a higher priority, N can’t start since 1 does not give up (Because of non-preemptive) Task-N is completed at t2 t2 Determinism(N) Responsiveness(N) tX Task-1 releases the processor at t1 t1 Responsiveness(1) Task 1 Task N t0 Time N Task-N with a higher priority arrives at t0  Determinism is out-of-control RT_Schedule/017

19 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
(b) Priority-Driven Immediate Preemptive Although N has a higher priority, N can’t start since 1 does not give up Task-N is completed at t2 Determinism Responsiveness t0 t1 t2 Task 1 Task N Time Task-N with a higher priority arrives at t0 Task-1 releases the processor at t1 RT_Schedule/018

20 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
(b) Priority-Driven Immediate Preemptive (continued) Meeting determinism (N)? Meeting responsiveness (N)? N’s determinism tR Task-N-1 is completed at tR Task-N is completed at tC tC Let N preempts 1 immediately = 0 Responsiveness(N) tX t0 Task-N with a higher priority arrives at t0 Task-1 Responsiveness Task 1 Task N Task (N-1) Task 1 Time  Responsiveness is out-of-control RT_Schedule/019

21 after Task-N is requested
CS 314 Operating Systems  Dynamic Best-Effort Scheduling (c) Priority-Driven Preemption on (periodic) preemption-points C = a hardware-clock interrupt Hardware-clock interrupt is a special interrupt caused by the hardware-clock periodically at a fixed time interval C C t C t C t tS t0 Task-N with a higher priority arrives at t0 tC1 tC2 tC3 Responsiveness Task 1 Task N Time tX The first HC interrupt after Task-N is requested Determinism(N): Responsiveness(N): tX – t0 guaranteed up to t RT_Schedule/020

22 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
(c) Priority-Driven Immediate Preemption on (periodic) preemption-points Although N has a higher priority, N can’t start since 1 does not give up If non-preemptive Responsiveness Task N Task-1 releases the processor at t1 t1 Task-N is completed at t2 t2 Determinism Task 1 t0 Time Task-N with a higher priority arrives at t0  Determinism is out-of-control RT_Schedule/021

23 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
If (task time) < (time-slice) this is the responsiveness (d) Round-Robin Time-Slice Determinism Task 1 Task 2 Task 3 Task (N-1)    Task N t0 Time Meeting responsiveness Meeting determinism Depends on what? RT_Schedule/022

24 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
(d) Round-Robin (continued) Time-Slice Determinism Task 1 Task 2 Task 3 Task (N-1)    Task N t0 Time Time-Slice TN Time-Slice TN    Time-Slice TN    Determinism Task-N finishes T1 T2 T3 TN-1    Time t0 Responsiveness RT_Schedule/023

25 CS 314 Operating Systems  Dynamic Best-Effort Scheduling
Determinism T1 T2 T3 TN-1    Time-Slice TN Time t0 Responsiveness Task-N finishes Meeting “determinism” requirement easier if: Meeting “responsiveness” requirement easier if: Reduce the degree of multi-tasking Same Reduce the degree of multi-tasking Reduce Round-Robin Time Slice Increase Round-Robin Time Slice Tradeoff RT_Schedule/024

26 CS 314 Operating Systems Priority Inversion
A situation where a higher-priority task must wait for a lower-priority task even in a preemptive priority-based scheduling. Something that should not happen H - A high-priority task L - A low-priority task R - Resource that requires exclusive access H L R (H waits on R)  Request  Request  Assigned H requests R H starts H gets blocked H L t3 H gets R and ready L starts first L gets the processor t0 t1 t2 t4 L releases R L locks on R Time Priority-Inversion RT_Schedule/025

27 CS 314 Operating Systems M Unbounded Priority Inversion H
- A high-priority task L - A low-priority task R - Resource that requires exclusive access H L R  Request  Assigned  Request (H waits on R) M - A medium-priority task H requests R H L t0 t1 t2 t3 t4 L releases R L locks on R Time Priority-Inversion RT_Schedule/026

28 1. Mars Pathfinder Priority Inversion Incident
On July 4th, 1997, the Mars Pathfinder landed to a media fanfare and began to transmit data back to Earth. Days later and the flow of information and images was interrupted by a series of total systems resets.

29 CS 314 Operating Systems Unbounded Priority Inversion M H
- A high-priority task L - A low-priority task R - Resource that requires exclusive access H L R  Request  Assigned  Request (H waits on R) M - A medium-priority task H requests R M requests for execution (requests for the processor) H L  We never know when L releases R M2 t3 M t4 t0 t1 L locks on R t2 L can not release R Priority-Inversion Unbounded Priority-Inversion RT_Schedule/027


Download ppt "Real-Time Process Scheduling Concepts, Design and Implementations"

Similar presentations


Ads by Google