PERFORCE change 146870 for review
Ed Schouten
ed at FreeBSD.org
Thu Aug 7 21:28:08 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146870
Change 146870 by ed at ed_dull on 2008/08/07 21:27:50
Now that our condvar(9) supports Giant as its interlock, remove
the evil hacks I had to make to the TTY code. We can now live
without them.
Affected files ...
.. //depot/projects/mpsafetty/sys/kern/tty.c#17 edit
Differences ...
==== //depot/projects/mpsafetty/sys/kern/tty.c#17 (text+ko) ====
@@ -880,8 +880,12 @@
STAILQ_INIT(&tp->t_outq.to_list);
/* Allow drivers to use a custom mutex to lock the TTY */
- mtx_init(&tp->t_mtxobj, "tty lock", NULL, MTX_DEF);
- tp->t_mtx = mutex != NULL ? mutex : &tp->t_mtxobj;
+ if (mutex != NULL) {
+ tp->t_mtx = mutex;
+ } else {
+ tp->t_mtx = &tp->t_mtxobj;
+ mtx_init(&tp->t_mtxobj, "tty lock", NULL, MTX_DEF);
+ }
knlist_init(&tp->t_inpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
knlist_init(&tp->t_outpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
@@ -912,7 +916,8 @@
cv_destroy(&tp->t_bgwait);
cv_destroy(&tp->t_dcdwait);
- mtx_destroy(&tp->t_mtxobj);
+ if (tp->t_mtx == &tp->t_mtxobj)
+ mtx_destroy(&tp->t_mtxobj);
ttydevsw_free(tp);
free(tp, M_TTY);
}
@@ -1189,18 +1194,7 @@
#endif
tty_lock_assert(tp, MA_OWNED);
- if (tp->t_mtx == &Giant) {
- /*
- * XXX: condvar(9) doesn't allow Giant to be passed as
- * its mutex. Because we don't use the per-TTY mutex
- * here, temporarily abuse it to make condvar(9) work.
- */
- mtx_lock(&tp->t_mtxobj);
- error = cv_wait_sig(cv, &tp->t_mtxobj);
- mtx_unlock(&tp->t_mtxobj);
- } else {
- error = cv_wait_sig(cv, tp->t_mtx);
- }
+ error = cv_wait_sig(cv, tp->t_mtx);
/* Restart the system call when we may have been revoked */
if (tp->t_revokecnt != revokecnt)
@@ -1225,18 +1219,7 @@
#endif
tty_lock_assert(tp, MA_OWNED);
- if (tp->t_mtx == &Giant) {
- /*
- * XXX: condvar(9) doesn't allow Giant to be passed as
- * its mutex. Because we don't use the per-TTY mutex
- * here, temporarily abuse it to make condvar(9) work.
- */
- mtx_lock(&tp->t_mtxobj);
- error = cv_timedwait_sig(cv, &tp->t_mtxobj, hz);
- mtx_unlock(&tp->t_mtxobj);
- } else {
- error = cv_timedwait_sig(cv, tp->t_mtx, hz);
- }
+ error = cv_timedwait_sig(cv, tp->t_mtx, hz);
/* Restart the system call when we may have been revoked */
if (tp->t_revokecnt != revokecnt)
More information about the p4-projects
mailing list