aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_timeout.c
diff options
context:
space:
mode:
authorMatthew Dillon <dillon@FreeBSD.org>2001-08-22 04:07:27 +0000
committerMatthew Dillon <dillon@FreeBSD.org>2001-08-22 04:07:27 +0000
commit219d632c15f42d97ccd44cc1f9af6ab443077a9f (patch)
tree6a4cf0c6700067e8baefaa4a41196fff464d0368 /sys/kern/kern_timeout.c
parent0b76df7146c736313bf3a70d88030f6ef7c36b3c (diff)
downloadsrc-219d632c15f42d97ccd44cc1f9af6ab443077a9f.tar.gz
src-219d632c15f42d97ccd44cc1f9af6ab443077a9f.zip
Move most of the kernel submap initialization code, including the
timeout callwheel and buffer cache, out of the platform specific areas and into the machine independant area. i386 and alpha adjusted here. Other cpus can be fixed piecemeal. Reviewed by: freebsd-smp, jake
Notes
Notes: svn path=/head/; revision=82127
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r--sys/kern/kern_timeout.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 4f88bab52029..da29c55efa6c 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -62,6 +62,55 @@ struct mtx callout_lock;
static struct callout *nextsoftcheck; /* Next callout to be checked. */
/*
+ * kern_timeout_callwheel_alloc() - kernel low level callwheel initialization
+ *
+ * This code is called very early in the kernel initialization sequence,
+ * and may be called more then once.
+ */
+caddr_t
+kern_timeout_callwheel_alloc(caddr_t v)
+{
+ /*
+ * Calculate callout wheel size
+ */
+ for (callwheelsize = 1, callwheelbits = 0;
+ callwheelsize < ncallout;
+ callwheelsize <<= 1, ++callwheelbits)
+ ;
+ callwheelmask = callwheelsize - 1;
+
+ callout = (struct callout *)v;
+ v = (caddr_t)(callout + ncallout);
+ callwheel = (struct callout_tailq *)v;
+ v = (caddr_t)(callwheel + callwheelsize);
+ return(v);
+}
+
+/*
+ * kern_timeout_callwheel_init() - initialize previously reserved callwheel
+ * space.
+ *
+ * This code is called just once, after the space reserved for the
+ * callout wheel has been finalized.
+ */
+void
+kern_timeout_callwheel_init(void)
+{
+ int i;
+
+ SLIST_INIT(&callfree);
+ for (i = 0; i < ncallout; i++) {
+ callout_init(&callout[i], 0);
+ callout[i].c_flags = CALLOUT_LOCAL_ALLOC;
+ SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle);
+ }
+ for (i = 0; i < callwheelsize; i++) {
+ TAILQ_INIT(&callwheel[i]);
+ }
+ mtx_init(&callout_lock, "callout", MTX_SPIN | MTX_RECURSE);
+}
+
+/*
* The callout mechanism is based on the work of Adam M. Costello and
* George Varghese, published in a technical report entitled "Redesigning
* the BSD Callout and Timer Facilities" and modified slightly for inclusion