Bài giảng Real-time Systems: Week 4: Basic concepts of scheduling

52 69 0
Bài giảng Real-time Systems: Week 4: Basic concepts of scheduling

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Cùng tìm hiểu Introduction of scheduling; Constraints of real-time tasks; Classification of scheduling algorithms; Scheduling anomalies được trình bày cụ thể trong Bài giảng Real-time Systems: Week 4: Basic concepts of scheduling.

Real-time Systems Week 4: Basic concepts of scheduling Ngo Lam Trung Dept of Computer Engineering NLT, SoICT, 2015 Contents  Introduction of scheduling  Constraints of real-time tasks  Classification  Scheduling of scheduling algorithms anomalies NLT, SoICT, 2015 Introduction  Why we need scheduling? There are always more tasks than processors  Multiple tasks run concurrently on uniprocessor system   Scheduling policy: the criterion to assign the CPU time to concurrent tasks  Scheduling algorithm: the set of rules that determines the order in which tasks are executed  What is the main difference between scheduling in RTOS and GPOS? NLT, SoICT, 2015 An illustration of scheduling (1)  All activated tasks enters “ready queue” at first  The scheduler selects one task in the Ready queue according to the tasks’ priorities allocated based on the scheduling algorithm  The selected task is dispatched and becomes in “running” state  After the selected task is completed, it is removed from the Ready queue Scheduler task activate Start/ dispatched Ready queue terminate running preempted released Wait queues Wait/blocked NLT, SoICT, 2015 Preemption  The running task can be interrupted at any point, so that a more important task that arrives can immediately gain the processor  The to-be-preempted task is interrupted and inserted to the ready queue, while CPU is assigned to the most important ready task which just arrived  Preemption is the solution for dynamic OS  Why preemption is needed in real-time systems?     Exception handling of a task Treating with different criticalities of tasks, permits to anticipate the execution of the most critical activities Efficient scheduling to improve system responsiveness FreeRTOS NLT, SoICT, 2015 Notation of scheduling (1) J = {J1,…,Jn}  :R+N  A set of tasks A schedule A function mapping from time to task to assign task to CPU If (t)=i for t[t1,t2), task Ji is executed during time duration [t1,t2)  If (t)=0, the CPU is idle   Simple translation  CPU time is divided in to time slices [t1,t2)  During a time slice (t)=const, representing the task that is executed NLT, SoICT, 2015 Notation of scheduling(2) Notation of scheduling (2) Idle J1 J2 J3 idle (t) A time slice t1 t2 t3 t4 Context switching are performed at these times NLT, SoICT, 2015 Notation of scheduling (3)  Preemptive  A schedule in which the running task can be arbitrarily suspended at any time, to assign the CPU to another task  Feasible  schedule schedule A schedule that all tasks can be completed according to a set of specified constraints  Schedulable  set of tasks A set of tasks that has at least one feasible schedule by some scheduling algorithm NLT, SoICT, 2015 Example of preemptive schedule J1 t J2 t J3 t (t) t NLT, SoICT, 2015 Types of task constraints  Timing constraints  Precedence  Resource constraints constraints NLT, SoICT, 2015 Best-effort algorithms  In soft real-time systems, some deadline misses can be acceptable  Ex Multimedia applications  Best-effort algorithms Accepts all tasks that arrived  Aborts some tasks under real overload conditions  Cannot guarantee feasibility   Demerit: domino effect  Merit: good average performance & avoiding unnecessary rejection NLT, SoICT, 2015 Metrics for performance evaluation(1)  Performance of scheduling algorithms is evaluated by a cost function  An optimal scheduling algorithm generates a schedule that minimizes a given cost function  Examples of cost functions Average response time  Total completion time  Weighted sum of completion times  Maximum lateness  Maximum number of late tasks  Utility functions  NLT, SoICT, 2015 Cost functions table NLT, SoICT, 2015 Example d1 d2 L1=3 L2=2 J1 J2 d4 d3 10 L4=1 L3=1 J3 d5 L5=2 J4 12 14 16 J5 18 20 22 24 d2 L1=23 J2 d5 L4=-5 L3=-5 J4 d4 d3 L2=-4 J3 t Minimize Lmax Lmax = L1 =3 d1 26 L5=-4 J5 10 12 14 J1 16 Lmax = L1 =23 18 20 22 24 26 t Only one task fails deadline NLT, SoICT, 2015 Utility function  A kind of cost function with respect to the completion time of a task  Evaluates lateness in a real-time task that depends on the completion time  Typical utility functions      Non real-time Soft On-time Firm To evaluate whole schedule, the cumulative value of utility function values of all tasks is used NLT, SoICT, 2015 Examples of cost functions v(fi) v(fi) Non real - time soft fi (a) (b) di fi v(fi) v(fi) on time (c) firm di di fi (d) NLT, SoICT, 2015 Scheduling anomalies  Real-time computing  fast computing of computing power  improvement of the performance  Increase  Graham’s  theorem If a task set is optimally scheduled on a multiprocessor with some priority assignment, a fixed number of processors, fixed execution times, and precedence constraints, then increasing the number of processors, reducing execution times, or weakening the precedence constraints can increase the schedule length NLT, SoICT, 2015 Examples of Graham’s theorem(1) J = {J1,…,J9}: A task set Sorted by decreasing priorities  Has the precedence constraints in next slide   Three processors  Optimal schedule * in Figure next slide  Global completion time is 12  NLT, SoICT, 2015 Task precedence constraints J1 (3) J2 (2) J3 J4 (2) (2) J9 (9) J8 (4) J7 (4) J6 (4) J5 (4) priority(Ji) > priority(Jj) for all i < j NLT, SoICT, 2015 Optimal schedule P1 J1 P2 J2 P3 J3 J9 J4 J5 J7 J6 J8 10 11 12 13 14 15 t optimal schedule of task set J on a three-processor machine  Find the global completion time if • Extra processors are added • Tasks execution time are reduced • Precedence constrain is weakened NLT, SoICT, 2015 Examples of Graham’s theorem(2)  Increasing  the number of processors Global completion time is 15 J1 P1 J8 P2 J4 J5 P3 J2 J6 P4 J3 J7 J9 10 11 12 13 14 15 t Schedule of task set J on a four-processor machine NLT, SoICT, 2015 Examples of Graham’s theorem(3)  Reducing  computation time Global completion time is 13 P1 J1 J5 P2 J2 J4 J6 P3 J3 J7 J8 J9 10 11 12 13 14 15 t Schedule of task set J on a three-processor machine with computation times reduced by one unit of time NLT, SoICT, 2015 Examples of Graham’s theorem(4)  Weakening  precedence constraints Global completion time is 16 J1 (3) J2 (2) J3 (2) J4 (2) J9 (9) J8 (4) J7 (4) J6 (4) J5 (4) Precedence graph of task set J obtained by removing the constraints on task J5 and J6 NLT, SoICT, 2015 Examples of Graham’s theorem(4)  Weakened  precedence constraints Global completion time is 16 J1 P1 P2 J2 P3 J3 J8 J4 J9 J5 J7 J6 10 11 12 13 14 15 16 Schedule of task set J on a three-processor machine with precedence constraints weakened NLT, SoICT, 2015 t Examples of Graham’s theorem(5)  Anomalies under resource constrains   In real-time tasks with shared resource Global completion time is increased by reducing the computation time J1 J2 J3 J4 J1 10 12 14 16 18 20 22 24 26 t J2 J3 tc = 17 J5 J4 10 12 tc = 22 J5 14 16 18 20 22 24 26 t NLT, SoICT, 2015 ...Contents  Introduction of scheduling  Constraints of real-time tasks  Classification  Scheduling of scheduling algorithms anomalies NLT, SoICT, 2015 Introduction  Why we need scheduling? There... 2015 Notation of scheduling( 2) Notation of scheduling (2) Idle J1 J2 J3 idle (t) A time slice t1 t2 t3 t4 Context switching are performed at these times NLT, SoICT, 2015 Notation of scheduling. .. SoICT, 2015 Complexity of scheduling algorithm  Complexity of scheduling decision problem  NP-complete in general  Has strong influence on the performance of dynamic real-time systems  Practical

Ngày đăng: 30/01/2020, 01:18

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan