summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-23 21:33:26 +0000
committered <ed@FreeBSD.org>2009-06-23 21:33:26 +0000
commite93642ed4fe5256e16ece4f1af6b6a38c0428121 (patch)
treea2b2b7574dd4a6371c71db8d85602780c27c8f1b /sys/kern/tty.c
parent351cb69f95a682aff1949a002284ccc928a5a5e5 (diff)
downloadFreeBSD-src-e93642ed4fe5256e16ece4f1af6b6a38c0428121.zip
FreeBSD-src-e93642ed4fe5256e16ece4f1af6b6a38c0428121.tar.gz
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.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 61c8785..4b2ce14 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -335,6 +335,7 @@ ttydev_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
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 uio *uio, int ioflag)
} 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 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_bgwait);
+ cv_broadcast(&tp->t_dcdwait);
}
done: tty_unlock(tp);
OpenPOWER on IntegriCloud