cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/13/04:23:02

Date: Mon, 13 Jul 1998 11:21:33 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Mariano Alvarez Fernández <malfer AT teleline DOT es>
cc: djgpp AT delorie DOT com
Subject: Re: About DJGPP v2.02
In-Reply-To: <35A931E7.6369@teleline.es>
Message-ID: <Pine.SUN.3.91.980713112106.323O-100000@is>
MIME-Version: 1.0

On Mon, 13 Jul 1998, Mariano Alvarez Fernández wrote:

> > Seems you are calling `int86' a lot.  What do you use it for?
> 
> I use basically it to handle low-level keyboard input:
> 
> #define _NAIVE_DOS_REGS
> 
> int lee_tecla( void )
> {
>   union REGS regs;
> 
>   regs.h.ah = 0x01;
>   int86( 0x16,&regs,&regs );
>   if( (regs.x.flags & 0x0040) != 0 ) return 0;
>   regs.h.ah = 0x00;
>   int86( 0x16,&regs,&regs );
>   return regs.x.ax;
> }

This seems like a keyboard polling loop.  Is it?

If it is, then it is quite normal for interactive programs to spend a
large portion of their running time in the keyboard loop.  To get
meaningful results about where such programs spend the rest of their
time, you need to run the profiled program in a way that doesn't let
it peek at the keyboard too much, like if you force it to do some long
computation.

Btw, while we are at it, several comments about this loop:

  1) It is better to use functions 0x11 and 0x10 instead of 1 and 0,
     respectively, since the former functions support the extended
     101-key keyboards.  (The old 84-key keyboards are almost extinct
     by now, and if you want to support them as well, there's a
     function to test for that.)  With functions 0x11 and 0x10 you can
     support keys like F11, the new editing keys, and some Ctrl- and
     Alt- key combinations which aren't supported by the old functions.

  2) For your program to be a ``good Windows citizen'', it should call
     __dpmi_yield library function if the keyboard buffer is empty, to
     yield the rest of its time slice.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019