Date: Tue, 21 Sep 1999 15:11:34 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: XtReMe cc: djgpp AT delorie DOT com Subject: Re: a VERY difficult problem In-Reply-To: <937519527.589.0.pluto.d4ee0fa5@news.demon.nl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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.