From d4e2f098fa4160a64e43f9d5efff956481b710a6 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 19 Jan 2019 21:38:54 +0000 Subject: [PATCH] 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. --- Kernel/tty.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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(); } } } -- 2.34.1