From 7338299c962812df21d68b409e7e28a458b4a9d9 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 10 Jun 2013 14:24:52 +0200 Subject: termios: Expand critical section Use interrupt disable/enable to protect the complete refill state change. This avoids race conditions for the task driven configuration and a later SMP support. --- cpukit/libcsupport/src/termios.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c index c5024d27cf..5c489152ee 100644 --- a/cpukit/libcsupport/src/termios.c +++ b/cpukit/libcsupport/src/termios.c @@ -1293,16 +1293,16 @@ rtems_termios_refill_transmitter (struct rtems_termios_tty *tty) rtems_interrupt_level level; int len; + rtems_interrupt_disable(level); + /* check for XOF/XON to send */ if ((tty->flow_ctrl & (FL_MDXOF | FL_IREQXOF | FL_ISNTXOF)) == (FL_MDXOF | FL_IREQXOF)) { /* XOFF should be sent now... */ (*tty->device.write)(tty->minor, (void *)&(tty->termios.c_cc[VSTOP]), 1); - rtems_interrupt_disable(level); tty->t_dqlen--; tty->flow_ctrl |= FL_ISNTXOF; - rtems_interrupt_enable(level); nToSend = 1; @@ -1317,10 +1317,8 @@ rtems_termios_refill_transmitter (struct rtems_termios_tty *tty) */ (*tty->device.write)(tty->minor, (void *)&(tty->termios.c_cc[VSTART]), 1); - rtems_interrupt_disable(level); tty->t_dqlen--; tty->flow_ctrl &= ~FL_ISNTXOF; - rtems_interrupt_enable(level); nToSend = 1; } else if ( tty->rawOutBuf.Head == tty->rawOutBuf.Tail ) { @@ -1336,10 +1334,8 @@ rtems_termios_refill_transmitter (struct rtems_termios_tty *tty) nToSend = 0; } else { - rtems_interrupt_disable(level); len = tty->t_dqlen; tty->t_dqlen = 0; - rtems_interrupt_enable(level); newTail = (tty->rawOutBuf.Tail + len) % tty->rawOutBuf.Size; tty->rawOutBuf.Tail = newTail; @@ -1369,10 +1365,8 @@ rtems_termios_refill_transmitter (struct rtems_termios_tty *tty) == (FL_MDXON | FL_ORCVXOF)) { /* Buffer not empty, but output stops due to XOFF */ /* set flag, that output has been stopped */ - rtems_interrupt_disable(level); tty->flow_ctrl |= FL_OSTOP; tty->rawOutBufState = rob_busy; /*apm*/ - rtems_interrupt_enable(level); nToSend = 0; } else { /* @@ -1395,6 +1389,8 @@ rtems_termios_refill_transmitter (struct rtems_termios_tty *tty) tty->rawOutBuf.Tail = newTail; /*apm*/ } + rtems_interrupt_enable(level); + if (wakeUpWriterTask) { rtems_semaphore_release (tty->rawOutBuf.Semaphore); } -- cgit v1.2.3