Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys stop using lbolt in tty



details:   https://anonhg.NetBSD.org/src/rev/23c8bde2a353
branches:  trunk
changeset: 767665:23c8bde2a353
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue Jul 26 13:14:17 2011 +0000

description:
stop using lbolt in tty

diffstat:

 sys/kern/tty.c     |  30 ++++++++++++++++++++++--------
 sys/kern/tty_pty.c |   6 +++---
 sys/sys/tty.h      |   3 ++-
 3 files changed, 27 insertions(+), 12 deletions(-)

diffs (137 lines):

diff -r 1bde6ba33b3b -r 23c8bde2a353 sys/kern/tty.c
--- a/sys/kern/tty.c    Tue Jul 26 13:09:11 2011 +0000
+++ b/sys/kern/tty.c    Tue Jul 26 13:14:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.245 2011/07/17 20:54:52 joerg Exp $  */
+/*     $NetBSD: tty.c,v 1.246 2011/07/26 13:14:18 yamt Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.245 2011/07/17 20:54:52 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.246 2011/07/26 13:14:18 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -875,7 +875,7 @@
                        mutex_exit(proc_lock);
                        
                        mutex_spin_enter(&tty_lock);
-                       error = ttysleep(tp, &lbolt, true, 0);
+                       error = ttypause(tp, hz);
                        if (error) {
                                mutex_spin_exit(&tty_lock);
                                return (error);
@@ -1719,7 +1719,7 @@
                mutex_exit(proc_lock);
 
                mutex_spin_enter(&tty_lock);
-               error = ttysleep(tp, &lbolt, true, 0);
+               error = ttypause(tp, hz);
                mutex_spin_exit(&tty_lock);
                if (error)
                        return (error);
@@ -1843,7 +1843,7 @@
                        mutex_spin_enter(&tty_lock);
                        ttysig(tp, TTYSIG_PG1, SIGTSTP);
                        if (first) {
-                               error = ttysleep(tp, &lbolt, true, 0);
+                               error = ttypause(tp, hz);
                                mutex_spin_exit(&tty_lock);
                                if (error)
                                        break;
@@ -1990,7 +1990,7 @@
                mutex_exit(proc_lock);
 
                mutex_spin_enter(&tty_lock);
-               error = ttysleep(tp, &lbolt, true, 0);
+               error = ttypause(tp, hz);
                mutex_spin_exit(&tty_lock);
                if (error)
                        goto out;
@@ -2605,7 +2605,8 @@
 
 /*
  * Sleep on chan, returning ERESTART if tty changed while we napped and
- * returning any errors (e.g. EINTR/ETIMEDOUT) reported by cv_timedwait(_sig).
+ * returning any errors (e.g. EINTR/EWOULDBLOCK) reported by
+ * cv_timedwait(_sig).
  * If the tty is revoked, restarting a pending call will redo validation done
  * at the start of the call.
  *
@@ -2620,7 +2621,9 @@
        KASSERT(mutex_owned(&tty_lock));
 
        gen = tp->t_gen;
-       if (catch)
+       if (cv == NULL)
+               error = kpause("ttypause", catch, timo, &tty_lock);
+       else if (catch)
                error = cv_timedwait_sig(cv, &tty_lock, timo);
        else
                error = cv_timedwait(cv, &tty_lock, timo);
@@ -2629,6 +2632,17 @@
        return (tp->t_gen == gen ? 0 : ERESTART);
 }
 
+int
+ttypause(struct tty *tp, int timo)
+{
+       int error;
+
+       error = ttysleep(tp, NULL, true, timo);
+       if (error == EWOULDBLOCK)
+               error = 0;
+       return error;
+}
+
 /*
  * Attach a tty to the tty list.
  *
diff -r 1bde6ba33b3b -r 23c8bde2a353 sys/kern/tty_pty.c
--- a/sys/kern/tty_pty.c        Tue Jul 26 13:09:11 2011 +0000
+++ b/sys/kern/tty_pty.c        Tue Jul 26 13:14:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_pty.c,v 1.128 2011/04/24 16:26:51 rmind Exp $      */
+/*     $NetBSD: tty_pty.c,v 1.129 2011/07/26 13:14:18 yamt Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.128 2011/04/24 16:26:51 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.129 2011/07/26 13:14:18 yamt Exp $");
 
 #include "opt_ptm.h"
 
@@ -402,7 +402,7 @@
                                return EIO;
                        }
                        ttysig(tp, TTYSIG_PG1, SIGTTIN);
-                       error = ttysleep(tp, &lbolt, true, 0);
+                       error = ttypause(tp, hz);
                        if (error != 0) {
                                mutex_spin_exit(&tty_lock);
                                return error;
diff -r 1bde6ba33b3b -r 23c8bde2a353 sys/sys/tty.h
--- a/sys/sys/tty.h     Tue Jul 26 13:09:11 2011 +0000
+++ b/sys/sys/tty.h     Tue Jul 26 13:14:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.h,v 1.87 2011/04/24 16:26:52 rmind Exp $   */
+/*     $NetBSD: tty.h,v 1.88 2011/07/26 13:14:17 yamt Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -282,6 +282,7 @@
 void    ttyretype(struct tty *);
 void    ttyrub(int, struct tty *);
 int     ttysleep(struct tty *, kcondvar_t *, bool, int);
+int     ttypause(struct tty *, int);
 int     ttywait(struct tty *);
 int     ttywflush(struct tty *);
 void    ttysig(struct tty *, enum ttysigtype, int);



Home | Main Index | Thread Index | Old Index