Mail Archives: djgpp/2007/08/17/10:39:43
On 16 Aug 2007 at 0:35, Alexei A. Frounze wrote:
> On Aug 15, 3:06 pm, "Gerrit van Niekerk" <gerri DOT DOT DOT AT gpvno DOT co DOT za> wrote:
> > I have a DJGPP program executing a fairly long loop containing kbhit() to
> > check for keyboard input. When executing normally, it works fine, but as
> > soon as the program is invoked using GDB (version 6.1.1), the kbhit() never
> > returns anything but 0 when using CWSDPMI under ROM-DOS. This is the
> > case even if just running the program without setting any breakpoints or
> > watchpoints.
> >
> > GDB works fine in a DOS-BOX in WinXP.
> >
> > I have tried both DJGPP 2.03 and 2.04 with the same result.
> >
> > Any help will be appreciated.
>
> I'm not sure if it's related, but calling kbhit() in a loop may make
> the OS (Windows NT/2000/XP/etc) think the program isn't doing anything
> but just waiting for the keyboard input. As the consequence, the OS
> may give the app significantly less time to run or give none at all
> (that is, pause it) until a key is actually pressed. In one app I had
> to hook up the keyboard interrupt and instead of repeatedly calling
> kbhit() poll a global variable that my keyboard ISR would set (and the
> poller atomically reset when done handling).
>
> As for the debugger, I don't know for sure, but it may get in the way
> with its own keyboard stuff.
>
It is only when running GDB on ROM-DOS that it is a problem. Works fine in a
DOS-BOX under WinXP and always when not running GDB.
Anyway, I solved the problem by using __dpmi_int(0x16,&r) instead of kbhit()
and getch(). Works fine now with GDB.
--
Gerrit van Niekerk
GP van Niekerk Ondernemings BK
Roosstraat 211, Meyerspark, 0184, South Africa
Tel: +27(12)8036501 Fax SA: 0866 413 555
Cell: +27(73)6891370
Fax Int'l: +1(206)2034139
Email: gerritvn AT gpvno DOT co DOT za
Web: http://www.gpvno.co.za
- Raw text -