Information Technology Reference
In-Depth Information
Exceptions. A processor exception is any unexpected condition caused
Definition: exception
by user program behavior. On an exception, the hardware will stop the
currently executing process and start running the kernel at a specially des-
ignated exception handler. As we mentioned earlier, a processor exception
will be triggered whenever a process attempts to perform a privileged in-
struction or accesses memory outside of its own memory region. Other
exceptions occur when a process divides an integer by zero, accesses a
word of memory with a non-aligned address, attempts to write to read-
only memory, and so forth. In these cases, the operating system simply
halts the process and returns an error code to the user.
Exceptions can also be triggered by a number of other, more benign,
program events. For example, to set a breakpoint in a program, the kernel
replaces the machine instruction in memory with a special instruction
that invokes an exception. When the program reaches that point in its
execution, the hardware switches into the kernel. The kernel restores the
old instruction and transfers control to the debugger. The debugger can
then examine the program's variables, set a new breakpoint, and resume
the program at the instruction causing the exception.
Interrupts.
An interrupt is an asynchronous signal to the processor
Denition: interrupt
that some external event has occurred that may require its attention. An
interrupt operates much as an exception does: the processor stops the
currently executing process and starts running in the kernel at a specially
designated interrupt handler. Each different type of interrupt requires
its own handler. For timer interrupts, the handler checks if the current
process is being responsive to user input, to detect if the process has gone
into an infinite loop. The timer handler can also periodically switch the
processor to run a different process, to ensure each process gets a turn. If
there is no other work to do, the timer handler resumes execution at the
interrupted instruction, transparently to the user process.
In addition to timer events, interrupts are also used to inform the kernel of
the completion of input/output requests. For example, the mouse device
hardware will trigger an interrupt every time the user moves or clicks on
the mouse. The kernel in turn will notify the appropriate user process
| the one the user was mousing across. Virtually every input/output
device | the Ethernet, WiFi, hard disk, thumb drive, keyboard, mouse
| generates an interrupt whenever some input arrives for the processor
and whenever a request completes.
An alternative to interrupts is polling :
the kernel could loop, checking
Denition: polling
each input/output device to see if an event has occurred which required
handling. Needless to say, if the kernel is polling, it is not available to run
user-level code.
Interprocessor interrupts are another source of interrupts. On a multipro-
cessor, a processor can cause an interrupt to occur on any of the other
processors. The kernel uses these interrupts to coordinate actions across
Search WWH ::




Custom Search