From 688f94b1434ed320dfa1c4a16c80bac5f308daf5 Mon Sep 17 00:00:00 2001 From: bde Date: Sat, 22 Jul 1995 01:30:45 +0000 Subject: Move the inline code for waking up writers to a new function ttwwakeup(). The conditions for doing the wakeup will soon become more complicated and I don't want them duplicated in all drivers. It's probably not worth making ttwwakeup() a macro or an inline function. The cost of the function call is relatively small when there is a process to wake up. There is usually a process to wake up for large writes and the system call overhead dwarfs the function call overhead for small writes. --- sys/dev/cy/cy.c | 19 ++----------------- sys/dev/cy/cy_isa.c | 19 ++----------------- sys/dev/rc/rc.c | 8 +------- sys/dev/sio/sio.c | 17 ++--------------- sys/dev/syscons/syscons.c | 10 ++-------- sys/gnu/isdn/iitty.c | 20 +++++++++----------- sys/i386/isa/cx.c | 4 ++++ sys/i386/isa/cy.c | 19 ++----------------- sys/i386/isa/pcvt/pcvt_drv.c | 4 ++++ sys/i386/isa/rc.c | 8 +------- sys/i386/isa/sio.c | 17 ++--------------- sys/i386/isa/syscons.c | 10 ++-------- sys/isa/sio.c | 17 ++--------------- sys/isa/syscons.c | 10 ++-------- sys/kern/tty.c | 19 ++++++++++++++++++- sys/kern/tty_pty.c | 10 ++-------- sys/sys/tty.h | 3 ++- 17 files changed, 59 insertions(+), 155 deletions(-) (limited to 'sys') diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 090901f..338abb1 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cy.c,v 1.8 1995/07/05 12:15:52 bde Exp $ + * $Id: cy.c,v 1.9 1995/07/21 22:51:31 bde Exp $ */ #include "cy.h" @@ -155,8 +155,6 @@ * XXX temporary kludges for 2.0 (XXX TK2.0). */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) -#define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -2137,20 +2135,7 @@ comstart(tp) siointr1(com); /* fake interrupt to start output */ enable_intr(); #endif - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif - + ttwwakeup(tp); splx(s); } diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 090901f..338abb1 100644 --- a/sys/dev/cy/cy_isa.c +++ b/sys/dev/cy/cy_isa.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cy.c,v 1.8 1995/07/05 12:15:52 bde Exp $ + * $Id: cy.c,v 1.9 1995/07/21 22:51:31 bde Exp $ */ #include "cy.h" @@ -155,8 +155,6 @@ * XXX temporary kludges for 2.0 (XXX TK2.0). */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) -#define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -2137,20 +2135,7 @@ comstart(tp) siointr1(com); /* fake interrupt to start output */ enable_intr(); #endif - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif - + ttwwakeup(tp); splx(s); } diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c index 8eb0f93..1db4a3d 100644 --- a/sys/dev/rc/rc.c +++ b/sys/dev/rc/rc.c @@ -551,13 +551,7 @@ register struct tty *tp; #ifdef RCDEBUG printrcflags(rc, "rcstart"); #endif - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); #ifdef RCDEBUG printf("rcstart: outq = %d obuf = %d\n", tp->t_outq.c_cc, rc->rc_obufend - rc->rc_optr); diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index d880196..39683e9 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.102 1995/07/05 14:30:07 bde Exp $ + * $Id: sio.c,v 1.103 1995/07/21 22:51:34 bde Exp $ */ #include "sio.h" @@ -71,7 +71,6 @@ */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) #define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -1868,19 +1867,7 @@ comstart(tp) if (com->state >= (CS_BUSY | CS_TTGO)) siointr1(com); /* fake interrupt to start output */ enable_intr(); - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif + ttwwakeup(tp); splx(s); } diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index c48d470..e00049b 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.119 1995/07/11 17:59:22 bde Exp $ + * $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $ */ #include "sc.h" @@ -1102,13 +1102,7 @@ scstart(struct tty *tp) s = spltty(); } tp->t_state &= ~TS_BUSY; - if (rbp->c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)rbp); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); } splx(s); } diff --git a/sys/gnu/isdn/iitty.c b/sys/gnu/isdn/iitty.c index 63f19ad..f5fc948 100644 --- a/sys/gnu/isdn/iitty.c +++ b/sys/gnu/isdn/iitty.c @@ -1,6 +1,6 @@ -static char _ittyid[] = "@(#)$Id: iitty.c,v 1.6 1995/07/21 16:30:37 bde Exp $"; +static char _ittyid[] = "@(#)$Id: iitty.c,v 1.7 1995/07/21 20:52:21 bde Exp $"; /******************************************************************************* - * II - Version 0.1 $Revision: 1.6 $ $State: Exp $ + * II - Version 0.1 $Revision: 1.7 $ $State: Exp $ * * Copyright 1994 Dietmar Friede ******************************************************************************* @@ -10,6 +10,12 @@ static char _ittyid[] = "@(#)$Id: iitty.c,v 1.6 1995/07/21 16:30:37 bde Exp * ******************************************************************************* * $Log: iitty.c,v $ + * Revision 1.7 1995/07/21 20:52:21 bde + * Obtained from: partly from ancient patches by ache and me via 1.1.5 + * + * Nuke `symbolic sleep message strings'. Use unique literal messages so that + * `ps l' shows unambiguously where processes are sleeping. + * * Revision 1.6 1995/07/21 16:30:37 bde * Obtained from: partly from an ancient patch of mine via 1.1.5 * @@ -226,15 +232,7 @@ itystart(struct tty *tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) - { - if (tp->t_state & TS_ASLEEP) - { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t) & tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); if (tp->t_outq.c_cc) { if(OUTBOUND(tp->t_dev) && (tp->t_cflag & CLOCAL) && diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index c66f645..ff4b6b7 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -542,6 +542,9 @@ void cxoproc (struct tty *tp) if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) ttwwakeup (tp); #else /* FreeBSD 2.x and BSDI */ +#ifndef TS_ASLEEP /* FreeBSD some time after 2.0.5 */ + ttwwakeup(tp); +#else if (RB_LEN (tp->t_out) <= tp->t_lowat) { if (tp->t_state & TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; @@ -550,6 +553,7 @@ void cxoproc (struct tty *tp) selwakeup(&tp->t_wsel); } #endif +#endif /* * Enable TXMPTY interrupt, * to catch the case when the second buffer is empty. diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index 090901f..338abb1 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cy.c,v 1.8 1995/07/05 12:15:52 bde Exp $ + * $Id: cy.c,v 1.9 1995/07/21 22:51:31 bde Exp $ */ #include "cy.h" @@ -155,8 +155,6 @@ * XXX temporary kludges for 2.0 (XXX TK2.0). */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) -#define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -2137,20 +2135,7 @@ comstart(tp) siointr1(com); /* fake interrupt to start output */ enable_intr(); #endif - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif - + ttwwakeup(tp); splx(s); } diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index e578d4a..a8d6c98 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -974,6 +974,9 @@ pcstart(register struct tty *tp) timeout(ttrstrt, tp, 1); } +#ifndef TS_ASLEEP /* FreeBSD some time after 2.0.5 */ + ttwwakeup(tp); +#else if (rbp->c_cc <= tp->t_lowat) { if (tp->t_state&TS_ASLEEP) @@ -983,6 +986,7 @@ pcstart(register struct tty *tp) } selwakeup(&tp->t_wsel); } +#endif out: splx(s); } diff --git a/sys/i386/isa/rc.c b/sys/i386/isa/rc.c index 8eb0f93..1db4a3d 100644 --- a/sys/i386/isa/rc.c +++ b/sys/i386/isa/rc.c @@ -551,13 +551,7 @@ register struct tty *tp; #ifdef RCDEBUG printrcflags(rc, "rcstart"); #endif - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); #ifdef RCDEBUG printf("rcstart: outq = %d obuf = %d\n", tp->t_outq.c_cc, rc->rc_obufend - rc->rc_optr); diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c index d880196..39683e9 100644 --- a/sys/i386/isa/sio.c +++ b/sys/i386/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.102 1995/07/05 14:30:07 bde Exp $ + * $Id: sio.c,v 1.103 1995/07/21 22:51:34 bde Exp $ */ #include "sio.h" @@ -71,7 +71,6 @@ */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) #define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -1868,19 +1867,7 @@ comstart(tp) if (com->state >= (CS_BUSY | CS_TTGO)) siointr1(com); /* fake interrupt to start output */ enable_intr(); - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif + ttwwakeup(tp); splx(s); } diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index c48d470..e00049b 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.119 1995/07/11 17:59:22 bde Exp $ + * $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $ */ #include "sc.h" @@ -1102,13 +1102,7 @@ scstart(struct tty *tp) s = spltty(); } tp->t_state &= ~TS_BUSY; - if (rbp->c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)rbp); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); } splx(s); } diff --git a/sys/isa/sio.c b/sys/isa/sio.c index d880196..39683e9 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.102 1995/07/05 14:30:07 bde Exp $ + * $Id: sio.c,v 1.103 1995/07/21 22:51:34 bde Exp $ */ #include "sio.h" @@ -71,7 +71,6 @@ */ #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) #define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq) -#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ #define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE) @@ -1868,19 +1867,7 @@ comstart(tp) if (com->state >= (CS_BUSY | CS_TTGO)) siointr1(com); /* fake interrupt to start output */ enable_intr(); - -#if 0 /* XXX TK2.0 */ - if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel) - ttwwakeup(tp); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(TSA_OLOWAT(tp)); - } - selwakeup(&tp->t_wsel); - } -#endif + ttwwakeup(tp); splx(s); } diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index c48d470..e00049b 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.119 1995/07/11 17:59:22 bde Exp $ + * $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $ */ #include "sc.h" @@ -1102,13 +1102,7 @@ scstart(struct tty *tp) s = spltty(); } tp->t_state &= ~TS_BUSY; - if (rbp->c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)rbp); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); } splx(s); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 8efe14b..9802f10 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id: tty.c,v 1.54 1995/07/21 20:52:38 bde Exp $ + * $Id: tty.c,v 1.55 1995/07/21 22:51:50 bde Exp $ */ /*- @@ -2054,6 +2054,23 @@ ttwakeup(tp) } /* + * Wake up any writers on a tty. + */ +void +ttwwakeup(tp) + register struct tty *tp; +{ + + if (tp->t_outq.c_cc <= tp->t_lowat) { + if (tp->t_state & TS_ASLEEP) { + tp->t_state &= ~TS_ASLEEP; + wakeup(&tp->t_outq); + } + selwakeup(&tp->t_wsel); + } +} + +/* * Look up a code for a specified speed in a conversion table; * used by drivers to map software speed values to hardware parameters. */ diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 0a582fe..35fe857 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93 - * $Id: tty_pty.c,v 1.12 1995/07/21 16:30:52 bde Exp $ + * $Id: tty_pty.c,v 1.13 1995/07/21 20:52:40 bde Exp $ */ /* @@ -373,13 +373,7 @@ ptcread(dev, uio, flag) break; error = uiomove(buf, cc, uio); } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwwakeup(tp); return (error); } diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 84cd46b..032db54 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.h 8.6 (Berkeley) 1/21/94 - * $Id: tty.h,v 1.21 1995/07/21 20:57:15 bde Exp $ + * $Id: tty.h,v 1.22 1995/07/21 22:52:01 bde Exp $ */ #ifndef _SYS_TTY_H_ @@ -231,6 +231,7 @@ int ttspeedtab __P((int speed, struct speedtab *table)); int ttstart __P((struct tty *tp)); void ttwakeup __P((struct tty *tp)); int ttwrite __P((struct tty *tp, struct uio *uio, int flag)); +void ttwwakeup __P((struct tty *tp)); void ttychars __P((struct tty *tp)); int ttycheckoutq __P((struct tty *tp, int wait)); int ttyclose __P((struct tty *tp)); -- cgit v1.1