Every resource I read about DPMI and interrupts says that all memory (code/data/stack) that might be used in an interrupt handler should be locked (aka pinned), to make sure it won't be paged out. The idea behind this is that when a page fault occurs in an interrupt handler, you'll get a double fault, and your program will crash.
But is that really so? I imagine a double fault could occur right at the moment when the interrupt occurs, and the CPU tries to jump to your interrupt handler, but the code happens to be paged out. Once your ISR code is already running, I don't see how a page fault could cause disaster. What's so different between the interrupt context and normal program context?
As a quick test, I wrote a simple timer ISR that allocates some memory with char* ptr = new char[1024*1024]
, and then immediately discards the pointer. Running under CWSDPMI with paging enabled, this does crash after a while, but only because new
throws a std::bad_alloc
exception. No double faults, as far as I can tell.
Maybe if the interrupt occurs while doing disk I/O (in the middle of int 21), and the page fault handler calls int 21 again, that might cause trouble. But then that doesn't have anything to do with double faults. And then I don't think a protected mode interrupt handler could be called during int 21, anyway.
Is locked memory really that important?