Title: Hongzhi Li
1Schedulability on VxWorks
- Hongzhi Li
- Dept. of Computing Info. Science
- Queens University
2Outline
- Schedulability
- Priority Inversion
- Deadlock
- My Project on VxWorks
- Conclusion
3Schedulability
- Whether tasks meet their deadlines
- Methods to determine schedulability
- Utilization Bound Theorem (Simple Tasks RMA)
- C1/T1 CN/TN lt U(N)
- Response Time Analysis
- Ri Ci Ii lt Deadline
- Lethal threatens
- Priority Inversion
- Deadlock
- Transient Blocking ...
4Priority Inversion
Priority LOW MEDIUM
HIGH
waiting...
Lock
Res
Unlock
Time
Medium Prio running !
5Simple Priority Inheritance
- Kill Priority Inversion
- The priority of a task gaining access to a shared
resource dynamically inherits the priority of the
highest priority task sharing the resource. - Response Time Analysis
- Ri Ci Bi Ii lt Deadline
- Bi S usage(k,I)CS(k)
6Simple Priority Inheritance
Priority LOW MEDIUM
HIGH
waiting...
Lock
Res
X
Change to HIGH!
Time
7DeadLock
All Dead!
8Immediate Ceiling Priority Protocol
- Kill Deadlock, Transient Blocking, Priority
Inversion ... - Each task has a static priority
- Each resource has a static ceiling value maximum
prio of tasks that use it - Each task also has a dynamic priority, equal to
the maximum of its own static prio and the
ceiling values of any resources it has locked. - Bi max usage(k,i)CS(k)
9Immediate Ceiling Priority Protocol
Priority LOW
HIGH
Ceiling HIGH
Lock
X
S1
Dynamic HIGH
All Alive!
Lock
Lock
S2
Time
10Project Overview
- Similar to Lab 4 (Schedulability on mC/OS-II)
- We are all familiar with
- We know its schedulability Priority Inversion
- But
- on VxWorks
- which RTOS is better? 17,000 or 0
- deadlock
11Project Overview
12VxWorks Code
- Create a Task
- taskSpawn ("tctrlSW", PRIO, 0, STACK_SIZE,
- (FUNCPTR) controlSoftware,0,0,0,0,0,0,0,0,0,
0) - Create a Mutual-Exclusion Semaphore
- inverSemId semMCreate
- (SEM_Q_PRIORITY SEM_INVERSION_SAFE)
- Measure the execution time of a task
- timexN((FUNCPTR) controlSoftware, NULL,NULL,
- NULL,NULL,NULL,NULL,NULL,NULL)
- Check the timing sequence of the whole system
- WindView
13VxWorks Code -- Priority Inversion
void controlSoftware(void) //HIGH priority
FOREVER semTake(inverSemId,
WAIT_FOREVER) for (long i0 i lt
LONG_TIME i) //wait for a while
semGive(inverSemId) void accounting(void)
//LOW priority FOREVER
semTake(inverSemId, WAIT_FOREVER)
for (long i0 i lt 6 LONG_TIME i)
semGive(inverSemId)
inverSemId
Trick HIGH/LOW compete for the same semaphore
MEDIUM runs frequently
14WindView -- Priority Inversion
Semaphore
Get
Release
Get
Pend
Priority Inversion
15Simple Priority Inheritance
CodesemId semMCreate (SEM_Q_PRIORITY
SEM_INVERSION_SAFE)
Priority Inheritance
Semaphore Take Pend Give Give
16VxWorks Code -- Deadlock
void productionLine(void) ..//HIGH
semTake(dlock1SemId, WAIT_FOREVER)
semTake(dlock2SemId,100) //wait 0.5s for
(long i0 i lt 4 LONG_TIME i)
semGive(dlock1SemId) semGive(dlock2SemId)
void workStation(void) //LOW
semTake(dlock2SemId, WAIT_FOREVER) for
(long i0ilt 9LONG_TIME i) //wait
semTake(dlock1SemId,100) for (long i0 i lt 2
LONG_TIME i) semGive(dlock2SemId)
semGive(dlock1SemId)
Sem1
Sem2
17WindView -- Deadlock
Sem 1 Get Give
Get Pend Sem 2 Get
Give Get Pend
DeadLock
18Immediate Ceiling Priority Protocol
void workStation(void) taskPrioritySet(tidWs
,MID1) / ICPP dynamic prio /
semTake(dlock2SemId, WAIT_FOREVER) ...
semTake(dlock1SemId, WAIT_FOREVER) ...
taskPrioritySet(tidWs,MID2) / ICPP dynamic prio
reset to original /
Priority Switch
19Conclusion
VxWorks More powful and flexible
Lots of library to select Several
tools (windView) to use ICPP Can solve
priority inversion, deadlock, etc But
need to know ceiling value before runing
20?