diff options
author | ed <ed@FreeBSD.org> | 2009-06-23 21:43:02 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-23 21:43:02 +0000 |
commit | 4a4fe9e6fc477de0052b50fda1552f2c8b525dc6 (patch) | |
tree | 58a9553da39bc703dea7843ea737ae95efc11c3b /sys/kern/tty.c | |
parent | f46a6593e2c709033c9bf0974177a80c25b9e1c3 (diff) | |
download | FreeBSD-src-4a4fe9e6fc477de0052b50fda1552f2c8b525dc6.zip FreeBSD-src-4a4fe9e6fc477de0052b50fda1552f2c8b525dc6.tar.gz |
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.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r-- | sys/kern/tty.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 4b2ce14..f98a70f 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -456,7 +456,7 @@ ttydev_write(struct cdev *dev, struct uio *uio, int ioflag) } 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 uio *uio, int ioflag) 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, void *sc, struct mtx *mutex) 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); |