Processor Design : Exception Handling

Exception handling is the process of responding to exceptions when a computer program runs. An exception occurs when an unexpected event happens that requires special processing. Exceptions, are situations where the processor needs to stop executing the current code because of an error. In these cases, the processor typically begins running an exception handling routine to resolve the error, and then returns to the normal program flow. For instance, if the ALU attempts to divide by zero, or if an addition causes overflow, an exception might be triggered. The processor needs to stop operation and fix the error before the program can be resumed. Some common examples of exceptions are arithmetic overflow or underflow, division by zero, or attempting to access a memory location that does not exist.

Exception handling comprises the acknowledgement and servicing of an exceptional condition. The below table shows a few of the possible causes of exceptions

Type Source Cause
Interrupt External Hardware An external signal that requests specific action to be taken by the processor- examples are timer, IO, system fault, and power-fail.
Trap Software An operation that requires special processing to execute - examples include illegal or unimplemented operation, privilege violation, and system call.
Execution Problem Internal Hardware A problem found during operation execution that requires corrective action before the operation can complete - examples include virtual memory system fault, speculative branch misprediction, arithmetic overflow or underflow, and divide-by-zero.

Exception handling attempts to gracefully handle these situations so that a program does not crash. Exception handling can be performed at both the software and hardware levels.


Next Topic :

No comments:

Post a Comment