From owner-svn-src-head@FreeBSD.ORG Tue Jun 23 21:43:03 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 712A0106564A; Tue, 23 Jun 2009 21:43:03 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4506C8FC12; Tue, 23 Jun 2009 21:43:03 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5NLh3OE091049; Tue, 23 Jun 2009 21:43:03 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5NLh3FY091046; Tue, 23 Jun 2009 21:43:03 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906232143.n5NLh3FY091046@svn.freebsd.org> From: Ed Schouten Date: Tue, 23 Jun 2009 21:43:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194771 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jun 2009 21:43:03 -0000 Author: ed Date: Tue Jun 23 21:43:02 2009 New Revision: 194771 URL: http://svn.freebsd.org/changeset/base/194771 Log: Improve my last commit: use a separate condvar to serialize. The advantage of using a separate condvar is that we can just use cv_signal(9) instead of cv_broadcast(9). It makes no sense to wake up multiple threads. It also makes the TTY code easier to understand. t_dcdwait sounds totally unrelated. Modified: head/sys/kern/tty.c head/sys/sys/tty.h Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Tue Jun 23 21:37:12 2009 (r194770) +++ head/sys/kern/tty.c Tue Jun 23 21:43:02 2009 (r194771) @@ -456,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_dcdwait); + error = tty_wait(tp, &tp->t_outserwait); if (error) goto done; } @@ -464,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_dcdwait); + cv_signal(&tp->t_outserwait); } done: tty_unlock(tp); @@ -916,6 +916,7 @@ tty_alloc_mutex(struct ttydevsw *tsw, vo cv_init(&tp->t_inwait, "ttyin"); cv_init(&tp->t_outwait, "ttyout"); + cv_init(&tp->t_outserwait, "ttyosr"); cv_init(&tp->t_bgwait, "ttybg"); cv_init(&tp->t_dcdwait, "ttydcd"); @@ -959,6 +960,7 @@ tty_dealloc(void *arg) cv_destroy(&tp->t_outwait); cv_destroy(&tp->t_bgwait); cv_destroy(&tp->t_dcdwait); + cv_destroy(&tp->t_outserwait); if (tp->t_mtx == &tp->t_mtxobj) mtx_destroy(&tp->t_mtxobj); Modified: head/sys/sys/tty.h ============================================================================== --- head/sys/sys/tty.h Tue Jun 23 21:37:12 2009 (r194770) +++ head/sys/sys/tty.h Tue Jun 23 21:43:02 2009 (r194771) @@ -97,6 +97,7 @@ struct tty { /* Sleeping mechanisms. */ struct cv t_inwait; /* (t) Input wait queue. */ struct cv t_outwait; /* (t) Output wait queue. */ + struct cv t_outserwait; /* (t) Serial output wait queue. */ struct cv t_bgwait; /* (t) Background wait queue. */ struct cv t_dcdwait; /* (t) Carrier Detect wait queue. */