370 likes | 626 Views
Polling vs. Interrupts. SE-3910 Real-time Systems. Week 4, Class 3 Quick-Quiz (Ungraded) Lab 3 due today!, Week 4 (turn-in TBA!) Lab 4 turn-in up - due Tuesday, Week 5 Select when to use Polling or Interrupts Describe the interrupt handling process
E N D
Polling vs. Interrupts SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
SE-3910Real-time Systems • Week 4, Class 3 • Quick-Quiz (Ungraded) • Lab 3 due today!, Week 4 (turn-in TBA!) • Lab 4 turn-in up - due Tuesday, Week 5 • Select when to use Polling or Interrupts • Describe the interrupt handling process • Use conditional compilation to remove code from compiling SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling, Some from Dr. Hornick, etc.
Quick Quiz! What is the CPU utilization of this process? • Inputs: • Check every 5 seconds if we are there. • Run time if not there: 0.25 seconds • Run time if there: 5 seconds • Parent CPU Utilization: • Time remaining for Driving: SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Quick Quiz! What is the resistanceof this resistor? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Quick Quiz! Which of the following is correct? void foo(struct bar*); … struct bar b; And then…. • foo(&b) • foo(*b) • foo(b&) • foo(b*) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Quick Quiz! Which of the following is correct? void foo(struct bar2); … struct bar *b; And then…. • foo((struct bar*) b*) • foo((bar*) *b) • foo((bar*) b&) • foo((struct bar*) &b) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
C, Java, C#, … unary operators • Increment: ++x, x++ • Decrement: −−x, x−− • Address: &x • Indirection: *x • Positive: +x • Negative: −x • One's complement: ~x • Logical negation: !x • Sizeof: sizeof x, sizeof(type-name) • Cast: (type-name) cast-expression Wiki: Unary_operation
What did you learn from the SE Night Talks? What parts of the computer can run too slow so we miss a deadline? • Switch bouncing • Polling • Memory fetching (cache) • I/O (Network, File) • Garbage collectors • Passing stucts by value • CPU • Too many flops • Sorting • Threading overhead • Interrupt overhead SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Interrupt Definitions • Interrupt • An event in hardware that triggers the processor to jump from its current program counter to a specific point in the code. • Interrupt Service Routine (ISR) • The function that is called or the particular assembly code that is executed when the interrupt happens is called the Interrupt Service Routine (ISR). • Interrupt flag (IFG) • this is the bit that is set that triggers the interrupt, leaving the interrupt resets this flag to the normal state. • Interrupt Enable • Control bit that tells the processor that a particular interrupt should or should not be ignored. • Interrupt Vector Table • A table in memory which maps ISRs to interrupts. SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
ISR Handling (1) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
ISR Handling (2) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
ISR Handling (3) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
What is the Status Register? • (TODO: ALU pic here) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Switch de-bouncing • How can we avoid multiple presses? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
Polling SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
When to Poll vs. Interrupt? • Polling • Advantages • Lower latency (if 100% CPU) • Disadvantages • High CPU • Low Punctuality • Interrupts • Disadvantages • Context switch cost • Advantages • Low CPU • Higher Punctuality SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
The Clementine In 1994, a deep space probe, the Clementine, was launched to make observations of the moon and a large asteroid (1620 Geographos). After months of operation, a software exception caused a control thruster to fire for 11 minutes, which depleted most of the remaining fuel and caused the probe to rotate at 80 RPM. Control was eventually regained, but it was too late to successfully complete the mission. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Why use a watchdog timer? • Embedded systems must be able to cope with both hardware and software anomalies to be truly robust. • In many cases, embedded devices operate in total isolation and are not accessible to an operator. • Manually resetting a device in this scenario when its software “hangs” is not possible. • In extreme cases, this can result in damaged hardware or loss of life and incur significant cost impact. Watchdog Timers
Watchdog Timer Structure SE3910 Real Time Systems
Conditional Compilation • #define DEBUG • #ifdef DEBUG • #endif • #define LEVEL 5] • #if LEVEL > 0 • #endif SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling