Date: Thu, 22 Aug 2002 10:56:27 +0300 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: "Alex Oleynikov" Message-Id: <7263-Thu22Aug2002105626+0300-eliz@is.elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: djgpp AT delorie DOT com In-reply-to: (alex@compuweigh.com) Subject: Re: Problem with tight kbhit() loop References: Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "Alex Oleynikov" > Newsgroups: comp.os.msdos.djgpp > > I have a question about using kbhit() function in a tight loop like the one > below: > ... > while( !kbhit() ); > > ch = getch(); > ... > > If I just run the program that contains this code everything works fine. > Now, if I run this program under the RHIDE's debugger and have some > breakpoints prior to the code listed above, then this loop never quits and > computer locks up completely (only cold re-boot helps to restart it) and > sometimes even my CMOS settings are get screwed up, so BIOS loads their > default values at start-up making me go nuts restoring them :o). Is this on plain DOS or on Windows? If the former, I think it's a known side-effect of the way CWDPMI implements the DPMI Interrupt 31 handler: after certain operations interrupts are left in disabled state. Try inserting __asm__("sti") inside the loop, and I think the problem will go away.