Handling Exceptions · Writing an OS in Rust
CRANK

Mar 9, 2017In this post, we start exploring CPU exceptions. Exceptions occur in various erroneous situations, for example when accessing an invalid memory address or when dividing by zero. To catch them, we have to set up an interrupt descriptor table that provides handler functions. At the end of this post, our kernel will be able to catch breakpoint exceptions and to resume normal execution afterwards.As always, the complete source code is available on Github. Please file issues for any problems, questions, or improvement suggestions. There is also a comment section at the end of this page.ExceptionsAn exception signals that something is wrong with the current instruction. For example, the CPU issues an exception if the current instruction tries to divide by 0. When an exception occurs, the CPU interrupts its current work and immediately calls a specific exception handler function, depending on the exception type.We’ve already seen several types of exceptions in our kernel:Invalid …

os.phil-opp.com
Related Topics: GitHub