150 likes | 248 Views
Tiny OS Optimistic Lightweight Interrupt Handler. Simon Yau (smyau@cs.berkeley.edu) Alan Shieh (ashieh@hkn.eecs.berkeley.edu). Tiny OS Overview. Small footprint system Used in small, low-power, embedded devices (e.g., temperature sensors) Event-based programming model. Tiny OS Primer.
E N D
Tiny OS Optimistic Lightweight Interrupt Handler Simon Yau (smyau@cs.berkeley.edu) Alan Shieh (ashieh@hkn.eecs.berkeley.edu)
Tiny OS Overview • Small footprint system • Used in small, low-power, embedded devices (e.g., temperature sensors) • Event-based programming model
Tiny OS Primer • Program consist of state machines • All threads run to completion, unless preempted by hardware events • Event filtering Radio Tran- ceiver Radio Bit Radio Byte Packet Object Active Mess- age Applic- ation
Interrupt Handling in Tiny OS • Context switch during interrupts are most expensive primitive • Interrupt lost is power lost
A Bag of tricks: • Software simulated register window • Lightweight Interrupt handler • Optimistic (Lazy) interrrupt handler
Software Register Window • Register windows useful for low-overhead interrupt handling • Providing this support in hardware may not be cost-effective • Additional area can be used for other I/O optimizations
Software Register Window (implementation) • Two versions of gcc • User-mode and Interrupt-mode gcc • Each allowed to use approximately half of register file • Calling conventions restricted • Post-compilation function rename
Software Register Window Shared registers User registers Interrupt registers
Lightweight Interrupt Handler • Software Simulated register windows means less registers to work with => more register spills • Want a handler that is Lightweight • Consumes less register (reduce register spills) • Lower execution time (reduce lost interrupts)
Lightweight IH (implementation) • The IH does not fire off an event, but rather posts a thread that does. • We can vary the amount of filtering where this is done.
Lazy Interrupt Handler • Most of the time the CPU is in sleep mode (I.e., has no thread running). • In those cases, saving register is unnecessary. • Set aside a register for sleep mode, and check it during interrupts.
Evaluation environment • Simulated CPU, with Radio, LED, and Photo sensor. • Benchmarks • Single processor simulation • Network simulation • Measure: • Number of cycles in sleep / active mode • Energy consumption • Number of cycles with interrupts disabled • Number of lost interrupts
Evaluation • Register window • Radio interrupt is now 113 cycles (down from 165) • But improvement is unstable because asymmetry of register set increases register pressure
Evaluation (cont) • Lightweight Handler • Reduces execution time of Timer Interrupt handler by 57%; Radio Interrupt handler by 33%. But added thread posting/scheduling overhead for event handler. • Bad for radio interrupt due to real time constrains and the overhead. • Benchmark performance…
Evaluation (cont) • Lazy Interrupt handler • Reduces a typical radio interrupt from 165 cycles to 114 cycles • On the bench mark…