Explore core concepts of interrupts, exceptions, and context switching with this focused quiz. Sharpen your understanding of how CPUs manage processes and handle unexpected events in operating systems and embedded environments.
Which of the following is considered a hardware interrupt in a typical computer system?
Explanation: A hardware interrupt is generated by external devices like keyboards or timers when they need attention from the processor. A keyboard key being pressed signals a hardware event, prompting the CPU to respond. A division by zero error is a software exception, a system call is a programmatic request, and a syntax error is detected at compile time, not at runtime, so these do not qualify as hardware interrupts.
When a program attempts to access memory it does not have permission to, what typically occurs?
Explanation: Accessing unauthorized memory causes an exception (often a segmentation fault or access violation), and the operating system usually intervenes, possibly terminating the offending process. Processors do not simply ignore such violations; doing so would threaten system stability. No hardware interrupt is directed to the graphics card in this scenario, and the program cannot autonomously correct illegal memory access without explicit logic.
Why is context switching essential in a multitasking operating system?
Explanation: Context switching lets the CPU rapidly change from one process to another, giving each process a chance to execute and ensuring fairness in CPU utilization. It does not block hardware interrupts—handling interrupts often triggers a context switch. The purpose is not to enforce single-tasking or to increase processor speed, but rather to enable multitasking capability.
What is the primary role of an exception vector table in a CPU architecture?
Explanation: The exception vector table maps various exception types to their corresponding handling routines, ensuring quick and accurate responses when exceptions occur. Managing user passwords is unrelated, and recording executed instructions is the job of other system components (e.g., tracers or debuggers). Memory allocation for processes does not involve exception vector tables.
Which step is typically performed first by the CPU when a context switch is triggered by an interrupt?
Explanation: Saving register values preserves the current state of the running process, allowing it to resume later without loss of data. Skipping this step would result in corrupted process states. Reinstalling device drivers is unnecessary during a switch, and disabling the interrupt flag might occur as a secondary step for critical section protection, but is not done after the switch.