Note that there are some explanatory texts on larger screens.

plurals
  1. PO(Writing kernel) How do I modify the interrupt descriptor table?
    text
    copied!<p>I am writing a small kernel just to poke around the low level stuff a bit. Right now, it boots in Virtual Box and I can display text to the screen, allocate some memory, and other really basic things. It's written in C++ and a little asm.</p> <p>One of the things I wanted to explore was the mechanism behind multi-tasking. As I understand it, it goes something like this:</p> <ol> <li>The kernel initializes the Interrupt Descriptor Table so that an interrupt is issued periodically (e.g. a millisecond) and calls a routine defined in the kernel.</li> <li>When the routine is called, it can decide to set the code/data segments and stack pointer to those of another program's context, a "context-switch."</li> </ol> <p>So, it seemed simple in concept, but I knew the details were going to be a lot hairier. I've found a few things on line, but the terminology varies a lot, and the examples seem to be from contexts I don't have (like from within the Linux kernel).</p> <p>However, the way to set the descriptor tables seems to be like this:</p> <ol> <li>Send some data to the PIC (<code>outb</code> and what-not) to initialize it.</li> <li>Prepare an interrupt table in memory, with function pointers to the routines you want, being careful that the functions are capable of being signal handlers.</li> <li>Load the table with <code>lidt</code>.</li> </ol> <p>However, I can't find much on specifically doing these things, or whether this is even correct. Does anyone have resources for a bewildered kernel writer?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload