Ver código fonte

[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.
tags/v0.9.4
Michael Brown 16 anos atrás
pai
commit
50810955e9
1 arquivos alterados com 8 adições e 6 exclusões
  1. 8
    6
      src/core/console.c

+ 8
- 6
src/core/console.c Ver arquivo

@@ -88,9 +88,15 @@ static struct console_driver * has_input ( void ) {
88 88
  */
89 89
 int getchar ( void ) {
90 90
 	struct console_driver *console;
91
-	int character = 256;
91
+	int character;
92
+
93
+	while ( 1 ) {
94
+		console = has_input();
95
+		if ( console && console->getchar ) {
96
+			character = console->getchar ();
97
+			break;
98
+		}
92 99
 
93
-	while ( character == 256 ) {
94 100
 		/* Doze for a while (until the next interrupt).  This works
95 101
 		 * fine, because the keyboard is interrupt-driven, and the
96 102
 		 * timer interrupt (approx. every 50msec) takes care of the
@@ -105,10 +111,6 @@ int getchar ( void ) {
105 111
 		 * input.
106 112
 		 */
107 113
 		step();
108
-		
109
-		console = has_input();
110
-		if ( console && console->getchar )
111
-			character = console->getchar ();
112 114
 	}
113 115
 
114 116
 	/* CR -> LF translation */

Carregando…
Cancelar
Salvar