forked from Imagelibrary/rtems
console: Be fair in simple console read
Wait for one tick in case no character is available after a call to getchark(). Otherwise the system is constantly busy within an input loop (for example in the RTEMS shell). The polled Termios driver uses the same approach.
This commit is contained in:
@@ -33,9 +33,14 @@ ssize_t _Console_simple_Read(
|
||||
for ( i = 0; i < n; ++i ) {
|
||||
int c;
|
||||
|
||||
do {
|
||||
while ( true ) {
|
||||
c = getchark();
|
||||
} while (c == -1);
|
||||
if ( c != -1 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
(void) rtems_task_wake_after( 1 );
|
||||
}
|
||||
|
||||
buf[ i ] = (char) c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user