Date: Tue, 19 Oct 1999 17:23:47 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Paolo Gava cc: djgpp AT delorie DOT com Subject: Re: What I have to lock? In-Reply-To: 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 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.