[rtems commit] termios: Expand critical section

Sebastian Huber sebh at rtems.org
Wed Jun 12 14:08:10 UTC 2013


Module:    rtems
Branch:    master
Commit:    7338299c962812df21d68b409e7e28a458b4a9d9
Changeset: http://git.rtems.org/rtems/commit/?id=7338299c962812df21d68b409e7e28a458b4a9d9

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jun 10 14:24:52 2013 +0200

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 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index c5024d2..5c48915 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);
   }




More information about the vc mailing list