summaryrefslogtreecommitdiff
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-16 14:35:12 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-18 07:23:29 +0200
commitc980eaff1d10cb169ba22ce00e75dae318df21f1 (patch)
treec7ccb44a122fff63f833c49a8ce4c49b601847f5 /cpukit
parent143c8d0d948b31f7c4b40e3d7eb7ebe0b80b4915 (diff)
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.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libcsupport/src/consolesimpleread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/consolesimpleread.c b/cpukit/libcsupport/src/consolesimpleread.c
index a796e4380f..737b441d99 100644
--- a/cpukit/libcsupport/src/consolesimpleread.c
+++ b/cpukit/libcsupport/src/consolesimpleread.c
@@ -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;
}