From: Alan Cox Date: Sat, 19 Jan 2019 21:38:54 +0000 (+0000) Subject: tty: Fix deadlock in tty output X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d4e2f098fa4160a64e43f9d5efff956481b710a6;p=FUZIX.git tty: Fix deadlock in tty output If you had a dumb tty port (or driver) and your write blocked until pre-emption then we'd sleep expecting a tty wake event even though the tty doesn't provide one. Instead if we got told 'soon' we yield when asked to pre-empt. --- diff --git a/Kernel/tty.c b/Kernel/tty.c index 6a90fdbd..37405a6b 100644 --- a/Kernel/tty.c +++ b/Kernel/tty.c @@ -547,10 +547,14 @@ uint8_t tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flag) udata.u_error = EAGAIN; return 1; } - irq = di(); - tty_sleeping(minor); - psleep(&ttydata[minor]); - irqrestore(irq); + if (t != TTY_READY_SOON) { + irq = di(); + tty_sleeping(minor); + psleep(&ttydata[minor]); + irqrestore(irq); + } else + /* Yield */ + switchout(); } } }