Interrupts Flashcards

1
Q

Who generates External/Asynchronous interrupts?

A

Triggered by devices external to the core’s compute circuitry
• “Asynchronous” because they can occur at any time
• (“between CPU operations”)

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

Who generates Internal/synchronous interrupts?

A

Triggered by the core’s compute circuitry (CPU instructions)
– Well, actually, it’s the software that runs on the core…
– Which is why such interrupts are also sometimes called
» “Software interrupts”
• (“while a CPU operation occurs”)

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

How interrupts handled in x86/linux?

A

Each interrupt is associated with a

– Number (called “interrupt vector”)
• There are 256 interrupt vectors, numbered 0…255

– Handling routine (called “interrupt handler”)

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

When the interrupt handler array is set up?

A

Array content is initially set by BIOS
• (For example, to be able to use keyboard before OS is up)
– Later, at boot time, array is reinitiated by OS with its own routines

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

What’s the routine for interrupt handling?

A

The interrupt handler
– Save state of currently running process P
– Execute handler
– Return to user mode, resuming either P or another process

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

What are the two interrupt handling contexts? (synchronous and asynchronous )

A

If asynchronous interrupts, kernel is said to be in “interrupt context”
• It doesn’t directly serve the process that has just been stopped

– If synchronous, kernel is in “process context”
• It needs to provide some service to the process that invoked it
(whether explicitly or implicitly)

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

Are interrupts a schedulable entity?

A

No. interrupts are handled at the moment they are fired, even if what’s currently running is “more important”.

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

What happens to masked interrupts?

A

If interrupt vector K should fire but is masked

x86 HW remembers at most 2 instances of K (the rest get lost, if exist)

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

Handling an interrupt might take a long time
But we want to allow OS to decide if it has more important stuff to do.
What can we do?

A

Solution: split the handler into two:
– Fast/Hard/First‐Level Interrupt handler (FLIH)
• What we must do when receiving an interrupt, and nothing else
• Not interruptible => as small and as quick as possible

– Slow/Soft/Second‐Level interrupt handler(SLIH)
• All the rest (lower priority)
• Interruptible; will be executed later by some kernel thread

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

Give an example of top half and bottom half splitting of an interrupt.

A

When receiving a packet from the network.

Possible top half
(not schedulable, occurs immediately)
• Put a pointer to the received packet in a queue for later processing
• Give the NIC (network card) a new free memory buffer, such that it will have room
to save subsequent incoming packets

Possible bottom half
(will happen later when the scheduler decides)
• Hand packet to network stack
• Copy the content of the packet to the memory space of the
corresponding user application
• Notify the user app that a new packet has arrived

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

Resume an interrupted process - where?

A

If asynchronous interrupt (external) or system call (synchronous=internal, explicit)
then in the next process instruction, Right after the last instruction that was executed.

If exception (synchronous=internal, implicit)
– Resume in the same instruction that the HW failed to execute
- and send a signal (in case we e.g. divided by 0, no sense in executing the same command).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Interrupt handling in multicores – where?

A

Internal=synchronous interrupts (system call, divide by 0, …)
– Each core handles on its own

External=async interrupts (generated by external devices)
– Can do static partition of interrupts between cores
• E.g., all interrupts go to core 0
• Or, all interrupts in range x–y go to core j
– Can do dynamic partition of interrupts between cores
• E.g., round robin
• Or, send interrupt to least loaded core

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

What’s polling?

A

Polling is an alternative to interrupt-based processing
– OS turns off interrupts and instead polls the NIC every once in a while
– Effective when OS is mostly busy handling the packets
(used when OS is overwhelmed by interrupts).

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

What are the cons of polling?

A
  1. Polling too frequently might waste CPU cycles if not enough packets
  2. Polling too infrequently increases latency & may result in packet loss
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s Interrupt coalescing?

A

When the HW joins several interrupts of the same type in order to not overwhelm the OS.
Or by SW if it detects an interrupt storm.

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