Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jun 2009 21:33:26 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194769 - head/sys/kern
Message-ID:  <200906232133.n5NLXQXf090765@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Tue Jun 23 21:33:26 2009
New Revision: 194769
URL: http://svn.freebsd.org/changeset/base/194769

Log:
  Use dcdwait to block threads to serialize writes.
  
  I suspect the usage of bgwait causes a lot of spurious wakeups when
  threads are blocked in the background, because they will be woken up
  each time a write() call is performed.
  
  Also wakeup dcdwait when the TTY is abandoned.

Modified:
  head/sys/kern/tty.c

Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c	Tue Jun 23 21:24:21 2009	(r194768)
+++ head/sys/kern/tty.c	Tue Jun 23 21:33:26 2009	(r194769)
@@ -335,6 +335,7 @@ ttydev_close(struct cdev *dev, int fflag
 	tp->t_revokecnt++;
 	tty_wakeup(tp, FREAD|FWRITE);
 	cv_broadcast(&tp->t_bgwait);
+	cv_broadcast(&tp->t_dcdwait);
 
 	ttydev_leave(tp);
 
@@ -455,7 +456,7 @@ ttydev_write(struct cdev *dev, struct ui
 	} else {
 		/* Serialize write() calls. */
 		while (tp->t_flags & TF_BUSY_OUT) {
-			error = tty_wait(tp, &tp->t_bgwait);
+			error = tty_wait(tp, &tp->t_dcdwait);
 			if (error)
 				goto done;
 		}
@@ -463,7 +464,7 @@ ttydev_write(struct cdev *dev, struct ui
  		tp->t_flags |= TF_BUSY_OUT;
 		error = ttydisc_write(tp, uio, ioflag);
  		tp->t_flags &= ~TF_BUSY_OUT;
-		cv_broadcast(&tp->t_bgwait);
+		cv_broadcast(&tp->t_dcdwait);
 	}
 
 done:	tty_unlock(tp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906232133.n5NLXQXf090765>