Mail Archives: djgpp/1999/09/21/19:10:09
On Fri, 17 Sep 1999, XtReMe wrote:
> Then I hook the timer interrupt (irq 0, int 08h). I've written a function
> that saves all registers to the current thread, then it reads all the
> registers from the next thread and returns to where the next thread left
> off.
Bad idea. The DPMI spec explicitly forbids switching tasks and stacks
from within a hardware interrupt handler. You can, of course, work
around this limitation with enough work, but the solution will be
different for each DPMI server: what will work in Windows, won't work
with CWSDPMI, and vice versa.
That's why your program crashes: you are trying to violate the DPMI
spec.
A better idea is to use the timers: set up a timer that generates a
SIGALRM on each timer tick (using the library function `setitimer'),
and then make your scheduler be called from the handler of the SIGALRM
signal. This has a disadvantage that the threading stops when some
thread calls a DOS/BIOS function, but at least it will work.
- Raw text -