Professional Documents
Culture Documents
EE-522: Lecture-6
Event-Driven Schedulers-II
Quick Review of GPIOs and Interrupts
© Adeel Pasha, LUMS, Spring 2018
T1 T3
T1 T2 T3 (100 T3 T2 (180
(0-20) (20-50) (50-100) - (120-150) (150-180) -
120) 190)
20 50
di
i −1
What if di < pi ? ei + × ek ≤ di
k =1 pk
Utilization
0.85
0.8
0.75
0.69 0.7
1
0.65
1 2 4 8 16 32 64 128 256 102420484096
Number of Tasks
RMA Practicalities
Transient Overload:
Since RMA is priority-driven preemptive scheduler
Better than non-preemptive EDF in transient overload
Static: low run-time overhead
What happens if multiple tasks have same rate?
Worst-case context switching overhead = 2c
Where c = context switching time
Same as FG-BG scheduling
ek becomes ek+2c
where ek is WCET of higher priority task Tk
7 EE-522: Embedded Systems 2/8/2018
© Adeel Pasha, LUMS, Spring 2018
RMA Practicalities
Critical Tasks with longer periods?
Period transformation
Split a longer task Ti into m sub-tasks: {Ti1, Ti2, …Tim}
Tim = (ei/m, pi/m, di/m)
Fake higher value of U
Total ui due to split-task Ti = m × (ei/m)/(pi/m) = m × ei/pi
Static: Cannot handle sporadic/aperiodic tasks
Solution: Server-based techniques
Will be discussed later…
RMA Practicalities
Limited Priority Levels?
More no. of tasks (N) … Less no. of priority levels (n)
Windows-NT-based OS
Normal Thread Count: few100s at least
Max no. of priority levels: 32
Make tasks share priority levels
Uniform
Arithmetic
Geometric
Logarithmic
9 EE-522: Embedded Systems 2/8/2018
© Adeel Pasha, LUMS, Spring 2017
Status
Register
Device
CPU Mechanism
Data
Register
I/O Primitives
Two ways interact with an I/O device
I/O instructions (Programmed I/O)
Special insts are used (like input or output)
Memory-mapped I/Os
I/O devices are mapped in the same address space as
code/data memory
LD/SD can be used to access I/O’s registers
DEV1 EQU 0x5500
LDR R1, DEV1 ; DEV1 address is loaded into R1
LDR R0, [R1] ; Register indirect mode, read DEV1 into R0
LDR R2, #8 ; Setup a value to write
STR R2, [R1] ; 8 is stored into the device register
12 EE-522: Embedded Systems 2/8/2018
© Adeel Pasha, LUMS, Spring 2018
Read status
of the I/O I/O CPU
Not
Ready
Check Error
Status
Ready
Read data
from the I/O I/O CPU
and store
No
Done
Yes
15 EE-522: Embedded Systems 2/8/2018
© Adeel Pasha, LUMS, Spring 2018
Interrupts
Why Interrupts?
Busy-Wait I/Os are extremely inefficient
Restores the
PC back I/O device needs
CPU and signals it
Makes PC point to
the start of interrupt
service routine (ISR)
void output_handler(){
}
main(){
while(TRUE){
if(gotChar){
poke(OUT_DEV_DATA, temp);
poke(OUT_DEV_STATUS, 1);
while (peek(OUT_DEV_STATUS) != 0);
gotChar = FALSE;
}
… … … … // something else
}
}
20 // Still inefficient implementation! (Why?)
EE-522: Embedded Systems 2/8/2018
© Adeel Pasha, LUMS, Spring 2018
a b c d e f g h
Interrupts
Pros
Efficient in terms of performance
Cons
Debugging an interrupt handler (driver) is a nightmare
It’s not free, there is an overhead
Interrupt is like calling a sub-routine, there is context-switch