Top Banner
2008 Chapter-8 L16: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 REAL TIME OPERATING SYSTEMS Lesson-16 : Task Scheduling Cooperative Models Task Scheduling Cooperative Models
25

REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

Mar 09, 2018

Download

Documents

VuongNgoc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

1

REAL TIME OPERATING SYSTEMS

Lesson-16:Task Scheduling Cooperative ModelsTask Scheduling Cooperative Models

Page 2: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

2

1. Common scheduling models 1. Common scheduling models

Page 3: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

3

Common scheduling modelsCommon scheduling models

• Cooperative Scheduling of ready tasks in a circular queue. It closely relates to function queue scheduling.

• Cooperative Scheduling with Precedence Constraints

• Cyclic Scheduling of periodic tasks and Round Robin Time Slicing Scheduling of equal priority tasks

• Preemptive Scheduling • Scheduling using 'Earliest Deadline First' (EDF)

precedence.

Page 4: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

4

Common scheduling modelsCommon scheduling models

Rate Monotonic Scheduling using ‘higher rate of events occurrence First’ precedence

Fixed Times Scheduling Scheduling of Periodic, sporadic and aperiodic

Tasks Advanced scheduling algorithms using the

probabilistic Timed Petri nets (Stochastic) or Multi Thread Graph for the multiprocessors and complex distributed systems.

Page 5: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

5

2. Cooperative Scheduling in the cyclic 2. Cooperative Scheduling in the cyclic order order

Page 6: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

6

Cooperative Scheduling in the cyclic order Cooperative Scheduling in the cyclic order Each task cooperate to let the running task

finish Cooperative means that each task

cooperates to let the a running one finish. None of the tasks does block in-between

anywhere during the ready to finish states. The service is in the cyclic order

Page 7: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

7

WorstWorst--case latency case latency

Same for every task Tworst = {(sti + eti )1 + (sti + eti )2 +...+ (sti + eti

)N-1 + (sti + eti )N} + tISR. tISR is the sum of all execution times for the ISRs For an i-th task, switching time from one task to

another be is sti and task execution time be is eti

i = 1, 2, …, N 1 , N, when number of tasks = N

Page 8: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

8

Program counter assignments (switch) at different times, when the on the scheduler calls the o tasks from the list one by one in the circular queue from

the list.

Page 9: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

9

Cyclic scheduling model in tasks scheduling

Page 10: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

10

First three tasks among N- tasks in washing machine tasks scheduling

Page 11: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

11

Messages from the scheduler and task programs contexts at various instances in washing machine

tasks scheduling

Page 12: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

12

2. Cooperative Scheduling of Ready Tasks 2. Cooperative Scheduling of Ready Tasks in List in List

Page 13: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

13

Cooperative Scheduling in the order in Cooperative Scheduling in the order in which a task is initiated on interrupt which a task is initiated on interrupt

None of the tasks does block in-between anywhere during the ready to finish states.

The service is in the order in which a task is initiated on interrupt.

Page 14: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

14

WorstWorst--case latency case latency

Same for every task in the ready list Tworst = {(dti + sti + eti )1 + (dti + sti + eti )2

+...+ (dti + sti + eti )n-1 + (dti + sti + eti )n} + tISR. tISR is the sum of all execution times for the ISRs For an i-th task, let the event detection time with

when an event is brought into a list be is dti , switching time from one task to another be is stiand task execution time be is eti

i = 1, 2, …, n 1 , n

Page 15: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

15

Scheduler in which the scheduler inserts into a list the ready tasks for a sequential execution in a

cooperative mode

Page 16: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

16

3. Cooperative Scheduling of Ready Tasks 3. Cooperative Scheduling of Ready Tasks Using an Ordered List as per precedence Using an Ordered List as per precedence

Constraints Constraints

Page 17: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

17

Cooperative Scheduling in the order of Cooperative Scheduling in the order of Ready Tasks using an Ordered List as per Ready Tasks using an Ordered List as per

priority precedence priority precedence Scheduler using a priority parameter,

taskPriority does the ordering of list of the tasks─ ordering according to the precedence of the interrupt sources and tasks.

The scheduler first executes only the first task at the ordered list, and the total, equals the to period taken by the first task on at the list. It is deleted from the list after the first task is executed and the next task becomes the first.

Page 18: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

18

Cooperative Scheduling in the order of Cooperative Scheduling in the order of Ready Tasks using an Ordered List as Ready Tasks using an Ordered List as

per priority precedence per priority precedence The insertions and deletions for forming the

ordered list are made only at the beginning of the cycle for each list.

Page 19: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

19

WorstWorst--case latency case latency

Not Same for every task. Varies from (dti + sti + eti ) p(m)} + tISRto {(dti + sti + eti )p1 + (dti + sti + eti ) p2 +...+ (dti+ sti + eti ) p(m-1) + (dti + sti + eti ) p(m)} + tISR.

tISR is the sum of all execution times for the ISRs For an i-th task, let the event detection time with

when an event is brought into a list be is dti , switching time from one task to another be is stiand task execution time be is eti

i = 1, 2, …, m 1 , m; m is number of ISRs and tasks in the list

Page 20: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

20

Cooperative Priority based scheduling of the ISRs executing in the first layer and Priority based ready tasks at an ordered list executing in the second layer

Page 21: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

21

Program counter assignments at different times on Program counter assignments at different times on the scheduler calls to the ISRs and the corresponding the scheduler calls to the ISRs and the corresponding

taskstasks

Page 22: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

22

Example of ACVMExample of ACVM

First the coins inserted by the user are read, then the chocolate delivers, and then display task displays ‘thank you, visit again’ message.

Each task cooperates with other to finish. The precedence of tasks in the ready list─

reading coins is highest, then of chocolate delivery and display for the ordered list of the ready tasks.

Page 23: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

23

SummarySummary

Page 24: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

24

We learntWe learnt Each task cooperate to let the running task

finish in cooperative scheduling model Cyclic order Cyclic in list of initiated tasks into a ready

list Cyclic in ordered list of initiated tasks into a

ready list and list arranged in order of ISR and task priorities

Page 25: REAL TIME OPERATING SYSTEMS Lesson-16 · PDF fileScheduling of Periodic, sporadic and aperiodic Tasks

2008Chapter-8 L16: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

25

End of Lesson 16 of Chapter 8End of Lesson 16 of Chapter 8