Chenyang Lu CSE 467S 1
HW1 Graded
- Ready in your pendaflexes
- If you forget to include his name, e-mail Brandon.
- Average: 92
- Good job overall!
- Unit of energy
- Watt vs. Joule
- micro Joule vs. milli Joule
- Pop loop end address and counter from stacks
when loop counter reaches 0
- Indicate top of stack
Chenyang Lu CSE 467S 2
Race Conditions
Chenyang Lu CSE 467S 3
TinyOS Two-level Scheduling
- Tasks do intensive computations
- Unpreemptable FIFO scheduling
- Bounded number of pending tasks
- Events handle interrupts
- Interrupts trigger lowest level events
- Events can signal events, call commands, or post tasks
- Two priorities
- Interrupt
- Tasks
Hardware Interrupts events commands FIFO Tasks POST Preempt Time commands Chenyang Lu CSE 467S 4
module SurgeM { ... } implementation { bool busy; uint16_t sensorReading; event result_t Timer.fired() { if (!busy) busy = TRUE; call ADC.getData(); } return SUCCESS; }
Example 1: Race Condition
Asynchronous Code
Chenyang Lu CSE 467S 5
Example 2: Race Condition
In a command handler reachable from an interrupt: /* Contains a race: */ if (state == IDLE) { state = SENDING; count++; // send a packet }
Chenyang Lu CSE 467S 6
Causes of race conditions
- Different event/command handlers and
tasks access shared variables
- Preemption at a “wrong” time