ECE 5780 RealTime Systems FixedPriority Scheduling Slides adapted

  • Slides: 25
Download presentation
ECE 5780 Real-Time Systems Fixed-Priority Scheduling Slides adapted from various sources

ECE 5780 Real-Time Systems Fixed-Priority Scheduling Slides adapted from various sources

Last Time • Cyclic scheduling – Offline scheduling, lookup table – Scheduler wakes up,

Last Time • Cyclic scheduling – Offline scheduling, lookup table – Scheduler wakes up, dispatches the next job, sets the timer, and goes to sleep • Cyclic Executives – Divide time into equal-sized frames • Timer value is fixed – Schedule (offline) inside each frame • Scheduler wakes up, dispatches the new jobs, and goes to sleep 2

Scheduling Paradigms • Static table-driven – Static analysis and schedule • Static priority driven

Scheduling Paradigms • Static table-driven – Static analysis and schedule • Static priority driven – Static analysis, no (explicit) schedule • Dynamic planning based – Feasibility check at run-time – Based on WCET • Dynamic best effort – No feasibility check, attempts to meet deadlines but no guarantee (usually OK on average) 3

Priority-Based Scheduling • A preemptive method where the priority of the task determines whether

Priority-Based Scheduling • A preemptive method where the priority of the task determines whether it continues to run or is disrupted (most important process first) • On-line scheduler (no lookup table) • Fixed priorities – Same priority for all jobs of a task • Dynamic priorities – Different priorities to individual jobs in each task 4

Fixed-Priority Scheduling (FPS) • Robust/Predictable • Each task has a fixed, static, priority which

Fixed-Priority Scheduling (FPS) • Robust/Predictable • Each task has a fixed, static, priority which is determined prior to runtime • The runnable tasks are executed in the order determined by their priority • In real-time systems, the “priority” of a task is usually derived from its temporal requirements, not its importance to the correct functioning of the system or its integrity 5

Rate Monotonic Scheduling (RM) • Also known as RMS • Features – On-line –

Rate Monotonic Scheduling (RM) • Also known as RMS • Features – On-line – Preemptive – Priority-based with static priorities • The shorter the period, the higher the priority – If Ti < Tj then πi > πj 6

Example Task C T τ1 1 4 τ2 2 5 τ3 5 20 π

Example Task C T τ1 1 4 τ2 2 5 τ3 5 20 π The above tasks have implicit deadlines, i. e. , Di = Ti, i = 1, …, n 7

Utilization-Based Analysis • Can we determine if a task set is schedulable under RM?

Utilization-Based Analysis • Can we determine if a task set is schedulable under RM? • A simple sufficient but not necessary schedulability test exists • The above test has a linear time complexity 8

Utilization Bounds n Utilization Bound 1 100% 2 82. 8% 3 78. 0% 4

Utilization Bounds n Utilization Bound 1 100% 2 82. 8% 3 78. 0% 4 75. 7% 5 74. 3% 10 71. 8% 9

Remember • The test is sufficient, not necessary! Task C T τ1 τ2 τ3

Remember • The test is sufficient, not necessary! Task C T τ1 τ2 τ3 1 4 2 5 5 20 • U = 0. 25 + 0. 4 + 0. 25 = 0. 9 > 0. 78 n Utilization Bound 1 100% 2 82. 8% 3 78. 0% 4 75. 7% 5 74. 3% 10 71. 8% 10

Response-Time Analysis (1) • Idea: determine how long each task can be delayed by

Response-Time Analysis (1) • Idea: determine how long each task can be delayed by higher priority tasks • The worst-case response time (WCRT) of the highest priority task is equal to its worst-case execution time (WCET) • The WCRT of the second highest priority tasks is equal to its WCET + the time taken by the highest priority task – Depends on how often the highest priority task is executed 11

Response-Time Analysis (2) • The worst-case response time of τi is – Ii is

Response-Time Analysis (2) • The worst-case response time of τi is – Ii is the interference due to higher priority tasks • For each higher priority task τj, the number of jobs released during time interval Wi is • And the interference of τj on τi is 12

Response-Time Analysis (3) where hp(i) is the set of tasks with priority higher than

Response-Time Analysis (3) where hp(i) is the set of tasks with priority higher than τi Solve by forming a recurrence relationship The set of values is monotonically non-decreasing When the solution to the equation has been found 13

Response-Time Analysis (4) • A task set is schedulable under RM if and only

Response-Time Analysis (4) • A task set is schedulable under RM if and only if • Do we apply test until the hyperperiod? • Actually, that is not necessary! – Critical instant • When lower priority tasks have the maximum response time • When does this occur? 14

Determining Critical Instant Critical instant: Time 0 to longest period [0, Tmax] 15

Determining Critical Instant Critical instant: Time 0 to longest period [0, Tmax] 15

Response-Time Analysis (5) • Sufficient and necessary (exact) • If the task set passes

Response-Time Analysis (5) • Sufficient and necessary (exact) • If the task set passes the test they will meet all their deadlines; if they fail the test then, a task will miss its deadline – Unless some tasks do not require their worst-case execution times

Response-Time Algorithm 17

Response-Time Algorithm 17

Example (1) Task C T Π a 3 7 3 b 3 12 2

Example (1) Task C T Π a 3 7 3 b 3 12 2 c 5 20 1

Example (2)

Example (2)

Example (3) • Wa = 3 ≤ D a = 7 • Wb =

Example (3) • Wa = 3 ≤ D a = 7 • Wb = 6 ≤ Db = 12 • Wc = 20 ≤ Dc = 20 • So the task set is schedulable under RM 20

Comments • The response time analysis for fixed priority scheduling works perfectly for values

Comments • The response time analysis for fixed priority scheduling works perfectly for values of D less than T as long as the stopping criteria becomes • It also works perfectly well with any priority ordering – hp(i) always gives the set of higher-priority tasks

Response-Time Algorithm 22

Response-Time Algorithm 22

Deadline Monotonic Algorithm • Use relative deadlines – The shorter the relative deadline, the

Deadline Monotonic Algorithm • Use relative deadlines – The shorter the relative deadline, the higher the priority 23

Optimality of RM and DM • If a task set is schedulable by a

Optimality of RM and DM • If a task set is schedulable by a fixed-priority scheduling algorithm, it is also schedulable by RM • RM and DM are identical if the relative deadline is proportional to the period • For D < T, DM is an optimal fixed-priority scheduling algorithm – DM outperforms RM in this case 24

Scheduling Paradigms • Static table-driven – Static analysis and schedule • Static priority driven

Scheduling Paradigms • Static table-driven – Static analysis and schedule • Static priority driven – Static analysis, no (explicit) schedule • Dynamic planning based – Feasibility check at run-time – Based on WCET • Dynamic best effort – No feasibility check, attempts to meet deadlines but no guarantee (usually OK on average) 25