Fault-Tolerant Real-time Scheduling using MicroC:OS-II

21
Project Report for EE8205 Fault-Tolerant Real-time Scheduling using MicroC:OS-II Huy Pham, Moya Dai April 7 th , 2005 Ryerson University Ryerson University

Transcript of Fault-Tolerant Real-time Scheduling using MicroC:OS-II

Page 1: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

Project Report for EE8205

Fault-Tolerant Real-time Scheduling using MicroC:OS-II

Huy Pham, Moya Dai

April 7th, 2005

Ryerson UniversityRyerson University

Page 2: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

2

EE8205 ProjectEE8205 Project

ContentsContents1. Realtime System Description

2. Basic Algorithms Used in the Project

3. Our Implementation

4. Demonstration

Page 3: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

3

EE8205 ProjectEE8205 Project

RealtimeRealtime System DescriptionSystem Description

Hard realHard real--time system:time system:

Deadline must not be missed.

Periodic Tasks: Periodic Tasks:

Deadline is the end of each period.

Fixed PriorityFixed Priority--Driven Scheme:Driven Scheme:

Task priority is determined at the beginning.

Fault may occur:Fault may occur:

System fault tolerance required.

Page 4: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

4

EE8205 ProjectEE8205 Project

Basic AlgorithmsBasic Algorithms

Used in the ProjectUsed in the Project

Page 5: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

5

EE8205 ProjectEE8205 Project

Two versions proposedTwo versions proposed

FaultFault--tolerance by Redundancy.tolerance by Redundancy.Each task has two versions: Primary and Alternate.Each task has two versions: Primary and Alternate.

Primary:Primary:Contains full function, produces good quality results. Contains full function, produces good quality results. Prone to failure for higher level of complexity and resource usaProne to failure for higher level of complexity and resource usagege.

Alternate:Alternate:Only the minimum required functions included, less precise but Only the minimum required functions included, less precise but acceptable results. acceptable results. Simpler, requiring less resource, correctness is fully tested.Simpler, requiring less resource, correctness is fully tested.

Objective:Objective:1.1. Guarantee either the primary or the alternate version of each taGuarantee either the primary or the alternate version of each task to be sk to be

correctly completed before the corresponding deadline.correctly completed before the corresponding deadline.2.2. Try to complete as many primaries as possible.Try to complete as many primaries as possible.

Page 6: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

6

EE8205 ProjectEE8205 Project

Last Chance StrategyLast Chance Strategy• Each alternate is chosen to start at the latest possible time.

• The primaries are dynamically scheduled during the remaining intervals before their alternates.

• The alternates can preempt a primary when a time interval reserved for the alternates is reached.

• Whenever a primary is completed successfully, the scheduler remove its corresponding alternate and dynamically allocate the time intervals to other jobs.

• For those alternates affected, the reserved time intervals are reconstructed.

Page 7: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

7

EE8205 ProjectEE8205 Project

The shorter the period the higher the priority Optimal for fixed priority-driven scheduling schemes.Primary tasks are assigned priorities according to the RM rule.An offline scheduler reserves time intervals for the alternates according to back-RM algorithm.

The Rate Monotonic AlgorithmThe Rate Monotonic Algorithm

�����������

�����������

�����������

�����������

A21

A11

�����������

�����������

A21

�����������

�����������A12 �����������

�����������A13 ����������

����������A14 ����������

����������A15 �����������

�����������A16

���������������������

���������������������

A22 ���������������������

���������������������

A23 ���������������������

���������������������

A24 ���������������������

���������������������

A25

���������������������

Task2(6,2,2)

���������������������

Task1(5,2,1)

0 5 10 2015 25 30

�����������

�����������

A11

A21

�����������

�����������A12

�����������

�����������A13

����������

����������A14

����������

����������A15

�����������

�����������A16���������������������

���������������������A22

���������������������

���������������������A23

���������������������

���������������������A24

���������������������

���������������������A25

0 5 10 2015 25 30

P11 P21

���������������������

���������������������

P12 P22

P11succ

P21fail

P12fail

P22abort

Page 8: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

8

EE8205 ProjectEE8205 Project

The Checking Available Time AlgorithmThe Checking Available Time AlgorithmProblem:Problem:

Subsequent jobs may be affected by the early job failures.

��������������������� ��������������������A11���������������������

���������������������

P12

���������������������

���������������������A12 A13���������������������

���������������������

�������������������������������

�������������������������������A21

A22

���������������������

���������������������A22 �����������

�����������A22

0 5 10 2015 25 30

P11 P21 �������������������������������

�������������������������������

P12A11

P11fail

P13succ

P12abort

P21abort

�������������������� Task2(14,4,3)��������������������� Task1(9,5,2)

���������������������

���������������������

�������������������������������

�������������������������������

A21 ���������������������

���������������������

A12

P22abort

Solution:Solution:Before selecting a primary to execute, check if there are enoughunallocated units of time for its completion. If not, the primary will not be activated, thus eliminate the wasteful execution for primaries as much as possible.

Page 9: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

9

EE8205 ProjectEE8205 Project

The Eliminating Idle Time AlgorithmThe Eliminating Idle Time Algorithm

������������

������������A12 ������������

������������A13 ������������

������������A14 ������������

������������A15 ������������

������������A16�����������������������

�����������������������A22 �����������������������

�����������������������A23 �����������������������

�����������������������A24 ����������������������

����������������������A25

0 5 10 2015 25 30

P11 P21 P12 P22

P11succ

P21succ

P12succ

P22fail

������������

������������

������������

������������A21 A11������������������������A21

�����������������������

�����������������������A22

CPU Idle

CPU Idle

P13

������������

������������

������������

������������ Task1(5,2,1) Task2(6,2,2)

Solution:Solution:Two modes for each alternate:Prenotification and Postnotification

Postnotification mode: Starts at its notification time, and has higher priority than any primary.

Prenotification mode:An alternate is chosen to execute before its notification time only when the processor is about to be idle. It has lower priority than all primaries.

Problem:Problem: The processor will become idle, wasting cycles.

Page 10: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

10

EE8205 ProjectEE8205 Project

Improved Algorithm (3 versions)Improved Algorithm (3 versions)

For frequently or permanent failure (continuous failures more than N times), replace the task with a backup version.

The backup version is never used when the primary is in its good performance or the failure time is less than N times.

Page 11: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

11

EE8205 ProjectEE8205 Project

Our ImplementationOur Implementation

Page 12: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

12

EE8205 ProjectEE8205 Project

MicroCMicroC OSOS--IIII•Open source

•Well documented and widely supported

•Small

•Simple interface

•Preemptive:

Each task must have a unique priority

Total of 64 priority levels, 0 is the highest, 63 is the lowest

Page 13: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

13

EE8205 ProjectEE8205 Project

Scheduling with MicroC OS-II

Page 14: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

14

EE8205 ProjectEE8205 Project

Scheduling with MicroC OS-II

Our Proposal:

Scheduler as a Task

Page 15: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

15

EE8205 ProjectEE8205 Project

An Example Scheduling ProblemAn Example Scheduling Problem

Priority Assignment

Control 0A1 1A2 2P1 3P2 4

Two Tasks:T1(5, 2, 1)T2(6, 2, 2)

����������������������� �����������������������

�����������

�����������

������������

������������A21

A11

�����������

�����������A21

������������

������������

A12 ������������

������������

A13 ������������

������������

A14 ������������

������������

A15 ������������

������������

A16

����������������������

����������������������A22 �����������������������

�����������������������A23 �����������������������

�����������������������A24 �����������������������

�����������������������A25

�����������������������

Task2(6,2,2)

�����������������������

Task1(5,2,1)

0 5 10 2015 25 30

Page 16: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

16

EE8205 ProjectEE8205 Project

Alternate Alternate // Alternate1// // Poll the clock and print out an ID string// every half a second, then move ourselves out of the// READY queue when time is up//static void Alternate1 (void *pdata){

while(running_time < duration){

Poll the clock and print out an ID stringevery half a second

}

MoveToDormant()

}

Page 17: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

17

EE8205 ProjectEE8205 Project

PrimaryPrimarystatic void Primary1 (void *pdata){

x = random()if ( x < FAILRATE ){

// Run overtimewhile(1){

Poll the clock and print out an ID stringevery half a second

}}else{

// Run for our durationwhile(running_time < duration){

Poll the clock and print out an ID stringevery half a second

}

// Set a global var to indicate success, and quitP1Succeeded = 1MoveToDormant()

}}

Page 18: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

18

EE8205 ProjectEE8205 Project

ControlControl// Control// // Fault-tolerant Real-time Scheduling by moving tasks // in and out of the READY queue appropriately.//static void Control (void *pdata){

// Build and initialize data structuresInitData()

// Schedulingwhile (1){

SheduleTasks()

}

}

����������

����������

����������

����������

A21

A11����������

����������A21

����������

����������A12 ���������

���������A13 ����������

����������A14 ����������

����������A15 ���������

���������A16

�������������������

�������������������

A22 �������������������

�������������������

A23 �������������������

�������������������

A24 ������������������

������������������

A25

�������������������

������������������� Task2(6,2,2)

�������������������

������������������� Task1(5,2,1)

0 5 10 2015 25 30

Page 19: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

19

EE8205 ProjectEE8205 Project

DemonstrationDemonstration

Page 20: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

20

EE8205 ProjectEE8205 Project

EnhancementsEnhancements

Three Enhancements

Eliminating Idle Time

Taking into account variable task execution time

Keep track of the number of times a primary has failed, and stop scheduling it after a certain threshold.

Page 21: Fault-Tolerant Real-time Scheduling using MicroC:OS-II

21

EE8205 ProjectEE8205 Project

The The EEnd.nd.

Thank you!Thank you!