delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/21/19:10:09

Date: Tue, 21 Sep 1999 15:11:34 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: XtReMe <xtreme AT x-project DOT demon DOT nl>
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: <Pine.SUN.3.91.990921151022.19568L-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019