[PATCH 5/9] termios: Expand critical section
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Jun 10 13:11:53 UTC 2013
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 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index 39b4d30..d459843 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -1365,16 +1365,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;
@@ -1389,10 +1389,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 ) {
@@ -1408,10 +1406,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;
@@ -1441,10 +1437,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 {
/*
@@ -1467,6 +1461,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);
}
--
1.7.7
More information about the devel
mailing list