Professional Documents
Culture Documents
Real Time Task Embedded System
Real Time Task Embedded System
Real Time Task Embedded System
Real-time Task
Definition
2
Process
is a sequence of instructions in the absence of other
activities
is continuously executed by the processor until completion.
Start time
ai si fi t
Finishing time
Definition
3
dispatching Termination
activation
READY RUNNING
Preemption
Ready Queue
6
classified as:
Periodic
• Periodic tasks repeats itself after a certain fixed time
interval
Sporadic
• Sporadic tasks recurs at random instant
Aperiodic
• The same as sporadic except that the minimum
separation b/n two instants can be 0.
Activation modes of RT tasks
11
Scheduling Polices
Scheduling Polices
13
Clock-driven
• Scheduling points defined by interrupts for a periodic timer.
Event-driven
• Scheduling points defined by interrupts on task
completion & generation of events.
Task Scheduling On Uni-processor
15
#1 #2
Clock- Even
Driven Driven
Clock-driven scheduling
16
static or dynamic.
Static Event-Driven Schedulers
25
Algorithm of EDF
• Each time a new ready task arrives:
• It is inserted in to a queue of ready tasks,
sorted by their deadlines.
• If a newly arrived task is inserted at the head
of the ready queue, a task which is under
execution will be pre-empted.
Cont…d
29
T1
T2
T3
0 2 4 6 8 10 12 14 16 18 20 22 24
Accumulated Utilization
31
n
ei
Accumulated Utilization:
i 1 pi
laxity
Laxity = Absolute deadline – the time of
T1
T2
T3
0 2 4 6 8 10 12 14 16 18 20 22 24
l(T1)=33-4-6=23 l(T1)=33-5-6=22 l(T1)=33-15-6=12
l(T2)=28-4-3=21 l(T2)=28-5-2=21 l(T2)=28-15-2=11
l(T3)=29-5-10=14
Rate monotonic Scheduling (RMS)
39
Policy of RMS
• The priority of a task is a monotically decreasing
function of its period.
The higher the frequency (or lower the period) of a
Priority
Frequency
Cases of failing RMA scheduling
42
T1
T2
0 2 4 6 8 10 12 14 16 18 20 t
RMA Schedulability(utilization
bound)
43
than one.
n
ei
i 1 pi
ui 1
1971)
u i n21n
1
using RMA
T1: e1 = 1, p1 = 4, d1 = 4
T2: e2 = 2, p2 = 6, d2 = 6
T3: e3 = 3, p3 = 20, d3 = 20
Solution
46
3
ei 1 1 3 11
i 1 pi
ui 1
4 3 20 15
n2 1n
13
1 3 2 1 0.778
11
ui 15 0.733 0.778
Therefore, the task set is schedulable under RMS.
Completion Time Theorem
(Liu & Lehoczky)
47
set:
• Consider zero phasing of all tasks if not given.
• Draw up the schedules till the first deadline of
each task
• Observe if each task is schedulable
Completion Time Theorem: Basic
premise
48
T1 = 10, 30, Ф = 0
T1 is in phase with T2 T2 = 60, 120, Ф = 0
T1 T2 T1 T2 T1 T2
10 30 40 60 70 90
T1 = 10, 30, Ф = 20
T1 has 20ms phase lag with T2 T2 = 60, 120, Ф = 0
T2 T1 T2 T1 T2
20 30 50 60 80
Completion Time Theorem
(Liu & Lehoczky)
50
i 1
p
e i e p
i j 1 p j j i
where pi is the period of Ti and
p1 ≤ p2 ≤ p3 . . . ≤ pn
Example51
using RMA
using RMA
execution?
Cases:
• When it performs input/output operations
• When it is waiting for some event to occur
Cont…d
60
scheduling point.
• The OS removes the self-suspended task from the
queue and places it in the blocked queue.
• The OS then dispatches the next eligible task.
Cont…d
61
i 1
p
e bt i e p
i i
p j
j
i
j 1
i 1
bti bi min e j , b j
j 1
schedulable
Hence, it’s feasibly schedulable under RMA.
Interfacing LM35, LCD & Fan with PIC16F877A
65
// Lcd pinout settings trisa.b1=1;//for temperature sensor
sbit LCD_RS at Rc5_bit; trisd.b1=0;//for Fan
sbit LCD_EN at Rc4_bit; while(1) {
sbit LCD_D7 at Rc3_bit; x=adc_read(1);
sbit LCD_D6 at Rc2_bit; temp=x*0.488;
sbit LCD_D5 at Rc1_bit; if(temp>=40){
sbit LCD_D4 at Rc0_bit; portd.b1=1;
// Pin direction }
sbit LCD_RS_Direction at TRISc5_bit; else {
sbit LCD_EN_Direction at TRISc4_bit; portd.b1=0;
sbit LCD_D7_Direction at TRISc3_bit; }
sbit LCD_D6_Direction at TRISc2_bit; inttostr(temp,disp);/* converting data to string
sbit LCD_D5_Direction at TRISc1_bit; b/c LCD displays strings/chars */
sbit LCD_D4_Direction at TRISc0_bit;
int i; lcd_cmd(_lcd_clear);
double x,temp; lcd_out(1,1,"The current Temp";
char disp[3]; lcd_out(2,1,"=");
void main() { lcd_out(2,7,disp);
Lcd_Init(); delay_ms(1000);
adc_init(); }}