mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-20 14:33:15 +00:00
[console] Call cpu_nap() only if there is no input waiting
Avoid calling cpu_nap() until after we have determined that there is no input ready to read. This avoids delaying for one timer interrupt (~50ms) in the case of if ( iskey() ) char = getkey() which happens to be present in monojob.c, which is where we spend most of our time looping (e.g. during any download). This should eliminate the irritating tendency of gPXE to lose keypresses. Discovered on a Dell system where the serial port seems to send in a constant stream of 0xff characters; this wouldn't be a problem in itself except that each one triggers the 50ms delay (as mentioned above), which really kills performance.
This commit is contained in:
parent
5d36ec6721
commit
50810955e9
@ -88,9 +88,15 @@ static struct console_driver * has_input ( void ) {
|
||||
*/
|
||||
int getchar ( void ) {
|
||||
struct console_driver *console;
|
||||
int character = 256;
|
||||
int character;
|
||||
|
||||
while ( 1 ) {
|
||||
console = has_input();
|
||||
if ( console && console->getchar ) {
|
||||
character = console->getchar ();
|
||||
break;
|
||||
}
|
||||
|
||||
while ( character == 256 ) {
|
||||
/* Doze for a while (until the next interrupt). This works
|
||||
* fine, because the keyboard is interrupt-driven, and the
|
||||
* timer interrupt (approx. every 50msec) takes care of the
|
||||
@ -105,10 +111,6 @@ int getchar ( void ) {
|
||||
* input.
|
||||
*/
|
||||
step();
|
||||
|
||||
console = has_input();
|
||||
if ( console && console->getchar )
|
||||
character = console->getchar ();
|
||||
}
|
||||
|
||||
/* CR -> LF translation */
|
||||
|
Loading…
x
Reference in New Issue
Block a user