cons: Clamp the amount written to the console Large writes to the console take a long time. Serial writes of about a page take O(100ms). Our kernel is currently non-preemptive, which is based on a model of syscalls not taking too long. Limiting the write sizes to 80 (the width of an ancient console, which Ron will love) cuts the syscall time down to a few ms, which is within the quantum of a process. Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/drivers/dev/cons.c b/kern/drivers/dev/cons.c index b2639da..90d9890 100644 --- a/kern/drivers/dev/cons.c +++ b/kern/drivers/dev/cons.c
@@ -1226,8 +1226,10 @@ * keyboard would try to print it (which it can't do yet). The hack * is even dirtier in that we only detect it if it is the first * char, and we ignore everything else. \033 is 0x1b. */ - if (((char*)va)[0] != '\033') + if (((char*)va)[0] != '\033') { + n = MIN(n, 80); cputbuf(va, n); + } poperror(); px_unlock(); return n;