Newsgroups: comp.os.msdos.djgpp From: starx AT pacbell DOT net (StarWeaver) Subject: Re: What I have to lock? References: X-Newsreader: News Xpress 2.01 Lines: 46 Message-ID: Date: Mon, 08 Nov 1999 07:39:09 GMT NNTP-Posting-Host: 63.192.42.251 X-Complaints-To: abuse AT pacbell DOT net X-Trace: typhoon-sf.snfc21.pbi.net 942046510 63.192.42.251 (Sun, 07 Nov 1999 23:35:10 PST) NNTP-Posting-Date: Sun, 07 Nov 1999 23:35:10 PST Organization: SBC Internet Services To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Earlier, djgpp AT delorie DOT com wrote: > >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. Sure you can. Right click 'My Computer' -> Properties (or control panel -> system), -> performance tab -> virtual memory -> let me specify ... -> disable. Not that you would want to. _Bad_ things will happen to your performance. I belive i accidentally ended up with it set this way once, and the effect was somewhat simmalar as the diffrence between running Quake right now on this p2 voodoo 3, and playing it on an eight meg pure dos 486 without smartdrive--times 500. Hope that clears some things up... -StarWeaver Blue