interrupts Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is an interrupt

A

An interrupt is a signal to the processor that requires immediate attention

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is polling

A
  • a way to signal the CPU
  • the cpu checks with each device whether it needs attention
  • this is inefficient, if a device did not need attention, there was no point checking it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

when are interrupts serviced

A

after code is executed/before another instruction is fetched

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

problems with the interrrupt service routine and how its fixed

A
  • Interrupt occurs, forcing the CPU to stop executing the current program.
  • The Program Counter (PC) holds the address of the next instruction in the original program.
  • If the interrupt causes the CPU to jump to the ISR without saving the PC:
    - The CPU loses track of where to return after the ISR.
    - This disrupts the original program’s flow, causing errors or crashes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to fix the interrupt service routine problem using a stack

A

Solution Using a Stack:
Interrupt occurs:

Before the ISR is executed, the CPU pushes (saves) the current PC (and other important registers) onto the stack.
ISR execution:

The CPU changes the PC to point to the ISR’s starting address.
The ISR is executed to handle the interrupt.
After ISR completes:

The CPU pops (restores) the PC and other saved data from the stack.
Resume normal execution:

The original PC value is restored, allowing the CPU to continue the interrupted program at the correct point.
The program resumes seamlessly as if no interrupt occurred.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

types of interrupts/ when do they happen

A
  • hardware
  • software
  • if an illegal instruction is encountered
  • arithmetic overflow
  • if buffers nearly empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why must the CPU save the volatile environment when an interrupt occurs?

A
  • To preserve the current state of the program, so it can resume from where it left off after handling the interrupt.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is included in the volatile environment?

A

The program counter (PC), registers, and status flags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What would happen if the CPU didn’t save the volatile environment before servicing an interrupt?

A
  • The CPU would lose track of where it was in the program, leading to errors or data corruption.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a maskable interrupt?

A

An interrupt that can be disabled or delayed by the CPU.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a non-maskable interrupt (NMI)?

A

A high-priority interrupt that cannot be disabled and must be handled immediately.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give an example of a hardware interrupt.

A

Give an example of a hardware interrupt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do software interrupts differ from hardware interrupts?

A
  • Software interrupts are triggered by programs (e.g., errors or system calls), while hardware interrupts come from external devices.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does the CPU decide which ISR to run?

A

The CPU uses an interrupt vector table, which maps each interrupt to its corresponding ISR.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does the CPU know where to return after handling an interrupt?

A
  • The CPU saves the program counter (PC) and other important states before executing the ISR, then restores them afterward.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A