Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys New callout mechanism with two major improvements over t...
details: https://anonhg.NetBSD.org/src/rev/ce5173565d4a
branches: trunk
changeset: 484015:ce5173565d4a
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Mar 23 06:30:07 2000 +0000
description:
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
diffstat:
sys/arch/alpha/alpha/promcons.c | 12 +-
sys/arch/alpha/isa/fd.c | 44 +-
sys/arch/amiga/amiga/machdep.c | 7 +-
sys/arch/amiga/dev/fd.c | 17 +-
sys/arch/amiga/dev/ite.c | 17 +-
sys/arch/amiga/dev/ms.c | 17 +-
sys/arch/amiga/dev/par.c | 41 +-
sys/arch/amiga/dev/sbic.c | 9 +-
sys/arch/amiga/dev/sbicvar.h | 4 +-
sys/arch/arc/dev/fd.c | 46 +-
sys/arch/arc/dev/pccons.c | 11 +-
sys/arch/arc/dti/btl.c | 7 +-
sys/arch/arc/isa/isabus.c | 8 +-
sys/arch/arm32/dev/kbd.c | 31 +-
sys/arch/arm32/dev/pms.c | 8 +-
sys/arch/arm32/dev/pmsvar.h | 6 +-
sys/arch/arm32/footbridge/footbridge_com.c | 11 +-
sys/arch/arm32/mainbus/fd.c | 48 +-
sys/arch/arm32/mainbus/wdc_pioc.c | 6 +-
sys/arch/arm32/podulebus/sbic.c | 9 +-
sys/arch/arm32/podulebus/sbicvar.h | 4 +-
sys/arch/arm32/shark/pccons.c | 9 +-
sys/arch/arm32/shark/sequoia.c | 8 +-
sys/arch/arm32/vidc/console/console.c | 4 +-
sys/arch/arm32/vidc/lmcaudio.c | 9 +-
sys/arch/atari/dev/fd.c | 28 +-
sys/arch/atari/dev/hdfd.c | 45 +-
sys/arch/atari/dev/ite.c | 17 +-
sys/arch/atari/dev/lpt.c | 10 +-
sys/arch/atari/dev/ms.c | 9 +-
sys/arch/atari/dev/msvar.h | 3 +-
sys/arch/atari/dev/ser.c | 11 +-
sys/arch/atari/dev/wdc_mb.c | 6 +-
sys/arch/bebox/isa/fd.c | 44 +-
sys/arch/bebox/isa/isaclock.c | 8 +-
sys/arch/bebox/isa/pccons.c | 10 +-
sys/arch/bebox/isa/spkr.c | 10 +-
sys/arch/hp300/dev/apci.c | 9 +-
sys/arch/hp300/dev/dma.c | 9 +-
sys/arch/hp300/dev/fhpib.c | 15 +-
sys/arch/hp300/dev/ite.c | 4 +-
sys/arch/hp300/dev/mt.c | 21 +-
sys/arch/hp300/dev/nhpib.c | 15 +-
sys/arch/hp300/dev/ppi.c | 19 +-
sys/arch/hp300/dev/rd.c | 6 +-
sys/arch/hp300/dev/rdvar.h | 5 +-
sys/arch/hp300/hp300/machdep.c | 8 +-
sys/arch/hpcmips/dev/biconsdev.c | 4 +-
sys/arch/hpcmips/dev/tc5165buf.c | 14 +-
sys/arch/hpcmips/tx/txcom.c | 9 +-
sys/arch/i386/isa/fd.c | 44 +-
sys/arch/i386/isa/pccons.c | 10 +-
sys/arch/i386/isa/pcvt/pcvt_kbd.c | 8 +-
sys/arch/i386/isa/pcvt/pcvt_sup.c | 22 +-
sys/arch/mac68k/dev/adb_direct.c | 11 +-
sys/arch/mac68k/dev/aed.c | 14 +-
sys/arch/mac68k/dev/aedvar.h | 5 +-
sys/arch/mac68k/obio/asc.c | 7 +-
sys/arch/mac68k/obio/ascvar.h | 5 +-
sys/arch/mac68k/obio/iwm_fd.c | 10 +-
sys/arch/mac68k/obio/iwm_fdvar.h | 3 +-
sys/kern/init_main.c | 12 +-
sys/kern/kern_allocsys.c | 7 +-
sys/kern/kern_clock.c | 466 +++++++++++++++++++++-------
sys/kern/kern_exit.c | 4 +-
sys/kern/kern_fork.c | 5 +-
sys/kern/kern_synch.c | 14 +-
sys/kern/kern_time.c | 11 +-
sys/kern/tty.c | 10 +-
sys/kern/uipc_domain.c | 17 +-
sys/sys/callout.h | 79 ++++-
sys/sys/kernel.h | 15 +-
sys/sys/proc.h | 5 +-
sys/sys/systm.h | 4 +-
sys/sys/tty.h | 5 +-
75 files changed, 1063 insertions(+), 462 deletions(-)
diffs (truncated from 4667 to 300 lines):
diff -r 4f14d91eb49c -r ce5173565d4a sys/arch/alpha/alpha/promcons.c
--- a/sys/arch/alpha/alpha/promcons.c Thu Mar 23 06:04:24 2000 +0000
+++ b/sys/arch/alpha/alpha/promcons.c Thu Mar 23 06:30:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: promcons.c,v 1.13 1998/03/21 22:52:59 mycroft Exp $ */
+/* $NetBSD: promcons.c,v 1.14 2000/03/23 06:32:32 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.13 1998/03/21 22:52:59 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.14 2000/03/23 06:32:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -60,6 +60,8 @@
void promtimeout __P((void *));
int promparam __P((struct tty *, struct termios *));
+struct callout prom_ch = CALLOUT_INITIALIZER;
+
int
promopen(dev, flag, mode, p)
dev_t dev;
@@ -108,7 +110,7 @@
polltime = hz / PROM_POLL_HZ;
if (polltime < 1)
polltime = 1;
- timeout(promtimeout, tp, polltime);
+ callout_reset(&prom_ch, polltime, promtimeout, tp);
}
return error;
}
@@ -122,7 +124,7 @@
int unit = minor(dev);
struct tty *tp = prom_tty[unit];
- untimeout(promtimeout, tp);
+ callout_stop(&prom_ch);
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return 0;
@@ -232,7 +234,7 @@
if (tp->t_state & TS_ISOPEN)
(*linesw[tp->t_line].l_rint)(c, tp);
}
- timeout(promtimeout, tp, polltime);
+ callout_reset(&prom_ch, polltime, promtimeout, tp);
}
struct tty *
diff -r 4f14d91eb49c -r ce5173565d4a sys/arch/alpha/isa/fd.c
--- a/sys/arch/alpha/isa/fd.c Thu Mar 23 06:04:24 2000 +0000
+++ b/sys/arch/alpha/isa/fd.c Thu Mar 23 06:30:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.8 2000/02/07 22:07:28 thorpej Exp $ */
+/* $NetBSD: fd.c,v 1.9 2000/03/23 06:32:33 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -96,6 +96,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/callout.h>
#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/ioctl.h>
@@ -165,6 +166,9 @@
bus_space_handle_t sc_ioh; /* ISA io handle */
isa_chipset_tag_t sc_ic; /* ISA chipset info */
+ struct callout sc_timo_ch; /* timeout callout */
+ struct callout sc_intr_ch; /* pseudo-intr callout */
+
/*
* XXX We have port overlap with the first IDE controller.
* Until we have a reasonable solution for handling overlap
@@ -238,6 +242,8 @@
struct fd_type *sc_type; /* current type descriptor */
struct fd_type sc_type_copy; /* copy for fiddling when formatting */
+ struct callout sc_motor_ch;
+
daddr_t sc_blkno; /* starting block number */
int sc_bcount; /* byte count left */
int sc_opts; /* user-set options */
@@ -432,6 +438,9 @@
printf("\n");
+ callout_init(&fdc->sc_timo_ch);
+ callout_init(&fdc->sc_intr_ch);
+
/* Re-map the I/O space. */
if (bus_space_map(iot, ia->ia_iobase, 6 /* XXX FDC_NPORT */, 0, &ioh)) {
printf("%s: can't map i/o space\n", fdc->sc_dev.dv_xname);
@@ -545,6 +554,8 @@
struct fd_type *type = fa->fa_deftype;
int drive = fa->fa_drive;
+ callout_init(&fd->sc_motor_ch);
+
/* XXX Allow `flags' to override device type? */
if (type)
@@ -640,7 +651,7 @@
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
disksort_cylinder(&fd->sc_q, bp);
- untimeout(fd_motor_off, fd); /* a good idea */
+ callout_stop(&fd->sc_motor_ch); /* a good idea */
if (fd->sc_active == 0)
fdstart(fd);
#ifdef DIAGNOSTIC
@@ -710,7 +721,7 @@
biodone(bp);
/* turn off motor 5s from now */
- timeout(fd_motor_off, fd, 5 * hz);
+ timeout(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
fdc->sc_state = DEVIDLE;
}
@@ -1013,7 +1024,7 @@
fd->sc_skip = 0;
fd->sc_bcount = bp->b_bcount;
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
- untimeout(fd_motor_off, fd);
+ callout_stop(&fd->sc_motor_ch);
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
fdc->sc_state = MOTORWAIT;
return 1;
@@ -1022,14 +1033,15 @@
/* Turn on the motor, being careful about pairing. */
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
if (ofd && ofd->sc_flags & FD_MOTOR) {
- untimeout(fd_motor_off, ofd);
+ callout_stop(&ofd->sc_motor_ch);
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
}
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
fd_set_motor(fdc, 0);
fdc->sc_state = MOTORWAIT;
/* Allow .25s for motor to stabilize. */
- timeout(fd_motor_on, fd, hz / 4);
+ callout_reset(&fd->fd_motor_ch, hz / 4,
+ fd_motor_on, fd);
return 1;
}
/* Make sure the right drive is selected. */
@@ -1055,7 +1067,7 @@
fd->sc_dk.dk_seek++;
disk_busy(&fd->sc_dk);
- timeout(fdctimeout, fdc, 4 * hz);
+ callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc);
return 1;
case DOIO:
@@ -1128,14 +1140,14 @@
disk_busy(&fd->sc_dk);
/* allow 2 seconds for operation */
- timeout(fdctimeout, fdc, 2 * hz);
+ callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc);
return 1; /* will return later */
case SEEKWAIT:
- untimeout(fdctimeout, fdc);
+ callout_stop(&fdc->sc_timo_ch);
fdc->sc_state = SEEKCOMPLETE;
/* allow 1/50 second for heads to settle */
- timeout(fdcpseudointr, fdc, hz / 50);
+ callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc);
return 1;
case SEEKCOMPLETE:
@@ -1163,7 +1175,7 @@
goto loop;
case IOCOMPLETE: /* IO DONE, post-analyze */
- untimeout(fdctimeout, fdc);
+ callout_stop(&fdc->sc_timo_ch);
disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid));
@@ -1201,11 +1213,11 @@
delay(100);
fd_set_motor(fdc, 0);
fdc->sc_state = RESETCOMPLETE;
- timeout(fdctimeout, fdc, hz / 2);
+ callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc);
return 1; /* will return later */
case RESETCOMPLETE:
- untimeout(fdctimeout, fdc);
+ callout_stop(&fdc->sc_timo_ch);
/* clear the controller output buffer */
for (i = 0; i < 4; i++) {
out_fdc(iot, ioh, NE7CMD_SENSEI);
@@ -1217,14 +1229,14 @@
out_fdc(iot, ioh, NE7CMD_RECAL); /* recalibrate function */
out_fdc(iot, ioh, fd->sc_drive);
fdc->sc_state = RECALWAIT;
- timeout(fdctimeout, fdc, 5 * hz);
+ callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc);
return 1; /* will return later */
case RECALWAIT:
- untimeout(fdctimeout, fdc);
+ callout_stop(&fdc->sc_timo_ch);
fdc->sc_state = RECALCOMPLETE;
/* allow 1/30 second for heads to settle */
- timeout(fdcpseudointr, fdc, hz / 30);
+ callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc);
return 1; /* will return later */
case RECALCOMPLETE:
diff -r 4f14d91eb49c -r ce5173565d4a sys/arch/amiga/amiga/machdep.c
--- a/sys/arch/amiga/amiga/machdep.c Thu Mar 23 06:04:24 2000 +0000
+++ b/sys/arch/amiga/amiga/machdep.c Thu Mar 23 06:30:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.147 2000/02/21 20:38:46 erh Exp $ */
+/* $NetBSD: machdep.c,v 1.148 2000/03/23 06:33:08 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -51,6 +51,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/callout.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/map.h>
@@ -1559,6 +1560,7 @@
int crashandburn = 0;
int candbdelay = 50; /* give em half a second */
void candbtimer __P((void));
+struct callout candbtimer_ch = CALLOUT_INITIALIZER;
void
candbtimer()
@@ -1594,7 +1596,8 @@
"forced crash, nosync" : "forced crash");
}
crashandburn++;
- timeout(candbtimer, (caddr_t)0, candbdelay);
+ callout_reset(&candbtimer_ch, candbdelay,
+ candbtimer, NULL);
}
#endif
return;
diff -r 4f14d91eb49c -r ce5173565d4a sys/arch/amiga/dev/fd.c
--- a/sys/arch/amiga/dev/fd.c Thu Mar 23 06:04:24 2000 +0000
+++ b/sys/arch/amiga/dev/fd.c Thu Mar 23 06:30:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.44 2000/03/16 16:37:20 kleink Exp $ */
+/* $NetBSD: fd.c,v 1.45 2000/03/23 06:33:10 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -33,6 +33,7 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/callout.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/buf.h>
@@ -143,6 +144,8 @@
struct disk dkdev; /* generic disk info */
struct buf_queue bufq; /* queue pending I/O operations */
struct buf curbuf; /* state of current I/O operation */
+ struct callout calibrate_ch;
+ struct callout motor_ch;
struct fdtype *type;
void *cachep; /* cached track data (write through) */
int cachetrk; /* cahced track -1 for none */
@@ -389,6 +392,8 @@
sc = (struct fd_softc *)dp;
BUFQ_INIT(&sc->bufq);
+ callout_init(&sc->calibrate_ch);
+ callout_init(&sc->motor_ch);
sc->curcyl = sc->cachetrk = -1;
sc->openpart = -1;
@@ -1468,11 +1473,11 @@
* trk++, trk, trk++, trk, trk++, trk, trk++, trk and dma
*/
if (loopcnt < 8)
- timeout(fdcalibrate, sc, hz / 8);
+ callout_reset(&sc->calibrate_ch, hz / 8, fdcalibrate, sc);
else {
loopcnt = 0;
Home |
Main Index |
Thread Index |
Old Index