Interrupts Flashcards

1
Q

What is the brief definition of an interrupt?

A

A routine that temporarily redirects program flow to execute an important function.

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

What may trigger an interrupt?

A

A hardware signal (switch), a counter reaching a threshold, a program instruction, or an error

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

What is the process of an interrupt?

A

Store program counter on the stack
Execute an interrupt acknowledge cycle
Branches to where interrupt service routine is located

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

How does an ISR deal with parameters and variables?

A

It cannot have any parameters and cannot return any values.
Global variables have to be used to pass variables between ISR and main program.
Shared variables declared with volatile qualifier.

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

How does an ISR deal with 2 devices that may trigger an interrupt at unpredictable times?

A

Polling:
Processor reads each device/port at regular time intervals.
Each device is allocated a certain time slice.

Interrupts:
Triggered by an event
Only occurs when required
Efficient but less predictable

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

What is the main problem with ISRs, and how is it overcome?

A

A global variable changed during an ISR may have a copy stored in a register not associated with then ISR, this copy may hold the old value of the variable as the main program doesn’t know what the ISR has done.

Can be fixed by declaring the variable as volatile, tells program not to trust temp. copies of variable

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