Polling vs Interrupts SE3910 Dr Josiah Yoder Slide

  • Slides: 33
Download presentation
Polling vs. Interrupts SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material:

Polling vs. Interrupts SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 1

SE-3910 Real-time Systems • Week 4, Class 3 – Quick-Quiz (Ungraded) – Lab 3

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 – 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. 2

Quick Quiz! What is the CPU utilization of this process? • Inputs: – Check

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 3

Quick Quiz! What is the resistance of this resistor? SE-3910 - Dr. Josiah Yoder

Quick Quiz! What is the resistance of this resistor? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 4

Quick Quiz! Which of the following is correct? void foo(struct bar*); … struct bar

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 5

Quick Quiz! Which of the following is correct? void foo(struct bar 2); … struct

Quick Quiz! Which of the following is correct? void foo(struct bar 2); … 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 6

C, Java, C#, … unary operators • • • Increment: ++x, x++ Decrement: −−x,

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 7

What did you learn from the SE Night Talks? What parts of the computer

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 8

Interrupt Definitions • Interrupt – An event in hardware that triggers the processor to

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 9

ISR Handling (1) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material:

ISR Handling (1) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 10

ISR Handling (2) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material:

ISR Handling (2) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 11

ISR Handling (3) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material:

ISR Handling (3) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 12

What is the Status Register? • (TODO: ALU pic here) SE-3910 - Dr. Josiah

What is the Status Register? • (TODO: ALU pic here) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 13

Switch de-bouncing • How can we avoid multiple presses? SE-3910 - Dr. Josiah Yoder

Switch de-bouncing • How can we avoid multiple presses? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 14

Polling 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 15

When to Poll vs. Interrupt? • Polling • Interrupts – Advantages – Disadvantages •

When to Poll vs. Interrupt? • Polling • Interrupts – Advantages – Disadvantages • Lower latency (if 100% CPU) – Disadvantages • High CPU • Low Punctuality • Context switch cost – Advantages • Low CPU • Higher Punctuality SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 16

The Clementine • In 1994, a deep space probe, the Clementine, was launched to

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 17

Why use a watchdog timer? • Embedded systems must be able to cope with

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 18

Why use a watchdog timer? • Embedded systems must be able to cope with

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 19

Why use a watchdog timer? • Embedded systems must be able to cope with

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 20

Why use a watchdog timer? • Embedded systems must be able to cope with

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 21

Why use a watchdog timer? • Embedded systems must be able to cope with

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 22

Why use a watchdog timer? • Embedded systems must be able to cope with

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 23

Why use a watchdog timer? • Embedded systems must be able to cope with

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 24

Why use a watchdog timer? • Embedded systems must be able to cope with

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 25

Why use a watchdog timer? • Embedded systems must be able to cope with

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 26

Why use a watchdog timer? • Embedded systems must be able to cope with

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 27

Why use a watchdog timer? • Embedded systems must be able to cope with

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 28

Why use a watchdog timer? • Embedded systems must be able to cope with

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 29

Why use a watchdog timer? • Embedded systems must be able to cope with

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 30

Why use a watchdog timer? • Embedded systems must be able to cope with

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 31

Watchdog Timer Structure SE 3910 Real Time Systems

Watchdog Timer Structure SE 3910 Real Time Systems

Conditional Compilation • #define DEBUG • #ifdef DEBUG • #endif • #define LEVEL 5]

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 33