From: "Alex Oleynikov" Newsgroups: comp.os.msdos.djgpp References: <7263-Thu22Aug2002105626+0300-eliz AT is DOT elta DOT co DOT il> Subject: Re: Problem with tight kbhit() loop Lines: 38 X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <%z599.106$Or1.19232@news2.east.cox.net> Date: Thu, 22 Aug 2002 13:22:03 GMT NNTP-Posting-Host: 68.15.54.9 X-Complaints-To: abuse AT cox DOT net X-Trace: news2.east.cox.net 1030022523 68.15.54.9 (Thu, 22 Aug 2002 09:22:03 EDT) NNTP-Posting-Date: Thu, 22 Aug 2002 09:22:03 EDT Organization: Cox Communications To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" wrote in message news:7263-Thu22Aug2002105626+0300-eliz AT is DOT elta DOT co DOT il... > > 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? No, this is plain DOS. > 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. Yepp, you are right - this takes care of the problem. Thanks for your help. Alex