summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-10 14:24:52 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-12 16:11:25 +0200
commit7338299c962812df21d68b409e7e28a458b4a9d9 (patch)
tree05b52518710b8e26b31cf67a1db6b7dde2455361
parenttermios: Move wake up writer task action (diff)
downloadrtems-7338299c962812df21d68b409e7e28a458b4a9d9.tar.bz2
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.
-rw-r--r--cpukit/libcsupport/src/termios.c12
1 files 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);
}