P2L4 Thread Design Considerations - Signals and Interrupts Flashcards
What is an interrupt?
- Interrupts are events to the CPU.
- Interrupts are generated externally by components other than the CPU.
Give 3 examples of components that can interrupt a CPU
- I/O devices
- Timers
- Other CPUs
What is a signal?
Signals are events that are:
- Triggered by the CPU
or
- by software running on the CPU
Which particular interrupts can occur on a given physical platform depends on:
- the ___________ of that platform
- the ___________________ the platform comes with
- the _________________of the platform itself.
- the configuration of that platform
- the types of devices the platform comes with
- the hardware architecture of the platform itself.
Do interrupts appear asynchronously or synchronously?
always asynchronously
Two identical hardware platforms, running different operating systems will have:
- Same or different interrupts?
- Same or different signals?
Same interrupts
Different signals
State 3 properties of signals that differ from interrupts
- notification from the CPU itself or from software running on the CPU
- which interrupts can occur depends on the operating system
- may be asynchonous or synchronous
State 3 properties of interrupts that are not shared with signals
- notification from outside the CPU, to the CPU
- which interrupts can occur on platform, depends on the physical platform (configuration, types of devices, hardware architecture)
- asynchonous
List 3 similarities between interrupts and signals.
But for each similarity note the variation between interrupt and signal.
- unique identifier
- interrupt —> defined by hardware
- signal —> defined by OS
- can be masked (to enable/disable)
- interrupt —> mask per-CPU
- signal —> mask per process
-
handler
- interrupt —> handler specified for whole system
- signal —> handler specified per process
Give a toy shop visual metaphor for signals and interrupts.
- An interrupt is like ….
- A signal is like ….
- Discuss 3 ways of categorizing signals and interrupts
- ________________
- ________________
- 3.__________________
- An interrupt is like … a snowstorm
- A signal is like …. a low battery warning
- Discuss 3 ways of categorizing signals and interrupts
- handle in specific ways, e.g. safety protocols, rules..
- Can be ignored (masking …)
- 3.expected/unexpected - synchronous/asynchronous
Explain how an interrupt works
- Device interrupts the CPU via the wires that connect it.
- It sends a unique message, i.e. INT-N.
- The hardware defined message is then looked up in a table
- Corresponding handler is called. (OS defined!!)
- The program counter is moved to that address of the handler code
- Handler routine is then executed.
- All of this happens within the context of the thread that is interrupted.
Interrupt handling always occurs outside of the thread context. True or false?
False
The interrupt interrupts the execution of the thread that was executing on top of the CPU
… The CPU looks up the interrupt number in a table, and executes the handler routine that the interrupt maps to …
All of this happens within the context of the thread that is interrupted.
What is SIGSEGV? It’s a signal that ….
Describe how it is handled as an example of signal handling
SIGSEGV - process tries to access memory that has not been allocated
Steps of signal handling:
- Signals originate from the CPU.
- For each process, the OS maintains a mapping
- Keys in map correspond to the signal number (SIGSEGV is signal 11, for example).
- Values in map point to the starting address of handling routines.
- When a signal is generated, the program counter is adjusted to point to the handling routine for that signal for that process.
Give 3 examples of default actions the OS has for handling signals
The process may specify how a signal can handled, or the operating system default may be used. Some default signal responses include:
- Terminate
- Ignore
- Terminate and Core Dump (like SIGSEGV)
- Stop
- Continue (from stopped)
Give 2 examples of asynchronous signals and explain when they are sent.
- SIGKILL(kill) - from the point of view of targeted process, the kill comes asynchronously out of the blue!
- SIGALARM - timer timeout