10th April, 2023
What it means when a CPU resets itself during a fatal exception.
What is a Fatal Exception
A fatal exception is an exception that the CPU can’t handle which causes the CPU to reset. I have also written about exceptions here.
A Double Fault Exception
When an exception happens the processor is signaled to handle it. Within the time that the processor tries to handle the exception, If another exception happens, it is called a double fault exception. And a double fault exception is raised by the processor.
If you read the link above you will realize that the way the processor handles exceptions is to call the function that is mapped to the exception raised in the IDT.
What happens if there is no handler? A Triple Fault exception occurs. At this point the processor has had enough. It has no way of handling a Triple Fault so it resets itself. Now that is what we term a fatal exception. An exception that kills. Ha!
How the processor does a reset
When a reset happens the processor reads and executes instructions from memory. That is it. You want more? Okay.
Memory here refers to both RAM and ROM. RAM is the processors workplace. It loads instructions from disk into the RAM and executes them sequentially providing the user with desired outcome of the program.
ROM is the non-volatile part of the memory that the processor reads from first when the computer starts. It is hard coded with instructions for Power-On Self-Test(POST). It contains firmware, BIOS which usually tells the processor where to load the operating system from.
Reset Circuitry
The board has a reset circuitry that is used for resetting the Computer. When a Triple Fault occurs the reset circuitry causes high voltage to pass through the reset pin which is usually set at low voltage. Maintaining the high voltage to the reset pin for some clock cycles causes the processor to reset some major registers.
After resetting the registers, the processor uses the CS and IP register to identify the memory address to load and execute. This address usually points to the BIOS.
Reset Vector.
Aside from using the CS and IP like we saw above some computers hard code the location of the BIOS into an address in the ROM called the Reset Vector. On reset, the processor therefore knows exactly where to load the first instruction to execute.