delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/19/14:50:53

Date: Tue, 19 Oct 1999 17:23:47 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Paolo Gava <pgava AT etrone DOT com DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: What I have to lock?
In-Reply-To: <fyYO3.156$ke1.4458@nsw.nnrp.telstra.net>
Message-ID: <Pine.SUN.3.91.991019171800.14637D-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 Tue, 19 Oct 1999, Paolo Gava wrote:

> I wrote a multi-thread application (under windows98 and djgpp V2.02) in
> which, with a timer, every 10ms I do a context switch and wake up an other
> thread (if there is one).

Are you doing this from a hardware interrupt handler that hooks the 
timer tick?  If so, you are in for a bumpy ride: the DPMI spec explicitly
forbids to switch stacks in a hardware interrupt handler.

Does your program work?  I'd expect it to crash.

> My question is: do I have to lock stack and all the code that the thread
> call? (This means lock everything) or I can do something better?

You must lock everything.  At least under CWSDPMI, your program will 
crash immediately unless you lock everything.  I believe it will also 
crash in Windows, although maybe not so fast.

But again, I think this approach to multi-tasking is almost impossible in 
the DPMI environment.

An alternative is to use the setitimer library function and make the 
handler for the signal SIGALRM be your scheduler.  This has some 
disadvantages, but at least you will be playing by the DPMI rules, not 
against them.

> If I have to lock everything, I have to consider the possibility to disable
> virtual memory to make sure my program doesn't page, how bad is it?

You cannot disable virtual memory under Windows.

- Raw text -


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