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.
This commit is contained in:
Bruce Evans 1995-07-22 01:30:45 +00:00
parent 2ce42987d3
commit a16721a13a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9626
17 changed files with 59 additions and 155 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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) &&

View File

@ -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;
@ -549,6 +552,7 @@ void cxoproc (struct tty *tp)
}
selwakeup(&tp->t_wsel);
}
#endif
#endif
/*
* Enable TXMPTY interrupt,

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 $
*/
/*-
@ -2053,6 +2053,23 @@ ttwakeup(tp)
wakeup((caddr_t)&tp->t_rawq);
}
/*
* 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.

View File

@ -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);
}

View File

@ -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));