diff options
author | jake <jake@FreeBSD.org> | 2000-11-27 22:52:31 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2000-11-27 22:52:31 +0000 |
commit | 9326f655fcd4caf90e69a0e773ed128fe10e8996 (patch) | |
tree | 81303d866925ac21a87e7c5eb42a74a8327dafc2 /sys/kern | |
parent | 79bed97f3ef08feeef87c05d8ecd1eb1a6c486e4 (diff) | |
download | FreeBSD-src-9326f655fcd4caf90e69a0e773ed128fe10e8996.zip FreeBSD-src-9326f655fcd4caf90e69a0e773ed128fe10e8996.tar.gz |
Use callout_reset instead of timeout(9). Most callouts are statically
allocated, 2 have been added to struct proc for setitimer and sleep.
Reviewed by: jhb, jlemon
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_acct.c | 11 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 21 | ||||
-rw-r--r-- | sys/kern/kern_time.c | 10 | ||||
-rw-r--r-- | sys/kern/uipc_domain.c | 14 |
7 files changed, 40 insertions, 24 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index c4d1767..d251030 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -312,6 +312,9 @@ proc0_init(void *dummy __unused) bcopy("swapper", p->p_comm, sizeof ("swapper")); + callout_init(&p->p_itcallout, 0); + callout_init(&p->p_slpcallout, 0); + /* Create credentials. */ cred0.p_refcnt = 1; cred0.p_uidinfo = uifind(0); diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ff982e0..8f4ae90 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -77,11 +77,9 @@ static comp_t encode_comp_t __P((u_long, u_long)); static void acctwatch __P((void *)); /* - * Accounting callout handle used for periodic scheduling of - * acctwatch. + * Accounting callout used for periodic scheduling of acctwatch. */ -static struct callout_handle acctwatch_handle - = CALLOUT_HANDLE_INITIALIZER(&acctwatch_handle); +static struct callout acctwatch_callout; /* * Accounting vnode pointer, and saved vnode pointer. @@ -148,7 +146,7 @@ acct(a1, uap) * close the file, and (if no new file was specified, leave). */ if (acctp != NULLVP || savacctp != NULLVP) { - untimeout(acctwatch, NULL, acctwatch_handle); + callout_stop(&acctwatch_callout); error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE, p->p_ucred, p); acctp = savacctp = NULLVP; @@ -161,6 +159,7 @@ acct(a1, uap) * free space watcher. */ acctp = nd.ni_vp; + callout_init(&acctwatch_callout, 0); acctwatch(NULL); return (error); } @@ -329,5 +328,5 @@ acctwatch(a) log(LOG_NOTICE, "Accounting suspended\n"); } } - acctwatch_handle = timeout(acctwatch, NULL, acctchkfreq * hz); + callout_reset(&acctwatch_callout, acctchkfreq * hz, acctwatch, NULL); } diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 9e5d488..a57b914 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -172,7 +172,7 @@ exit1(p, rv) p->p_flag |= P_WEXIT; SIGEMPTYSET(p->p_siglist); if (timevalisset(&p->p_realtimer.it_value)) - untimeout(realitexpire, (caddr_t)p, p->p_ithandle); + callout_stop(&p->p_itcallout); /* * Reset any sigio structures pointing to us as a result of diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 55324c6..ca40474 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -483,6 +483,9 @@ again: LIST_INIT(&p2->p_heldmtx); LIST_INIT(&p2->p_contested); + callout_init(&p2->p_itcallout, 0); + callout_init(&p2->p_slpcallout, 0); + #ifdef KTRACE /* * Copy traceflag and tracefile if enabled. diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 585d1ff..bf4b89d 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -70,6 +70,9 @@ int hogticks; int lbolt; int sched_quantum; /* Roundrobin scheduling quantum in ticks. */ +static struct callout schedcpu_callout; +static struct callout roundrobin_callout; + static int curpriority_cmp __P((struct proc *p)); static void endtsleep __P((void *)); static void maybe_resched __P((struct proc *chk)); @@ -175,7 +178,7 @@ roundrobin(arg) need_resched(); #endif - timeout(roundrobin, NULL, sched_quantum); + callout_reset(&roundrobin_callout, sched_quantum, roundrobin, NULL); } /* @@ -344,7 +347,7 @@ schedcpu(arg) lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); vmmeter(); wakeup((caddr_t)&lbolt); - timeout(schedcpu, (void *)0, hz); + callout_reset(&schedcpu_callout, hz, schedcpu, NULL); } /* @@ -414,7 +417,6 @@ msleep(ident, mtx, priority, wmesg, timo) { struct proc *p = curproc; int s, sig, catch = priority & PCATCH; - struct callout_handle thandle; int rval = 0; WITNESS_SAVE_DECL(mtx); @@ -465,7 +467,7 @@ msleep(ident, mtx, priority, wmesg, timo) p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); if (timo) - thandle = timeout(endtsleep, (void *)p, timo); + callout_reset(&p->p_slpcallout, timo, endtsleep, p); /* * We put ourselves on the sleep queue and start our timeout * before calling CURSIG, as we could stop there, and a wakeup @@ -517,7 +519,7 @@ resume: goto out; } } else if (timo) - untimeout(endtsleep, (void *)p, thandle); + callout_stop(&p->p_slpcallout); mtx_exit(&sched_lock, MTX_SPIN); if (catch && (sig != 0 || (sig = CURSIG(p)))) { @@ -628,7 +630,6 @@ mawait(struct mtx *mtx, int priority, int timo) s = splhigh(); if (p->p_wchan != NULL) { - struct callout_handle thandle; int sig; int catch; @@ -646,7 +647,7 @@ mawait(struct mtx *mtx, int priority, int timo) */ if (timo) - thandle = timeout(endtsleep, (void *)p, timo); + callout_reset(&p->p_slpcallout, timo, endtsleep, p); sig = 0; catch = priority & PCATCH; @@ -687,7 +688,7 @@ resume: goto out; } } else if (timo) - untimeout(endtsleep, (void *)p, thandle); + callout_stop(&p->p_slpcallout); mtx_exit(&sched_lock, MTX_SPIN); if (catch && (sig != 0 || (sig = CURSIG(p)))) { @@ -1036,6 +1037,10 @@ static void sched_setup(dummy) void *dummy; { + + callout_init(&schedcpu_callout, 1); + callout_init(&roundrobin_callout, 0); + /* Kick off timeout driven events by calling first time. */ roundrobin(NULL); schedcpu(NULL); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index b94421e..93ab1dc 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -513,10 +513,10 @@ setitimer(p, uap) s = splclock(); /* XXX: still needed ? */ if (uap->which == ITIMER_REAL) { if (timevalisset(&p->p_realtimer.it_value)) - untimeout(realitexpire, (caddr_t)p, p->p_ithandle); + callout_stop(&p->p_itcallout); if (timevalisset(&aitv.it_value)) - p->p_ithandle = timeout(realitexpire, (caddr_t)p, - tvtohz(&aitv.it_value)); + callout_reset(&p->p_itcallout, tvtohz(&aitv.it_value), + realitexpire, p); getmicrouptime(&ctv); timevaladd(&aitv.it_value, &ctv); p->p_realtimer = aitv; @@ -560,8 +560,8 @@ realitexpire(arg) if (timevalcmp(&p->p_realtimer.it_value, &ctv, >)) { ntv = p->p_realtimer.it_value; timevalsub(&ntv, &ctv); - p->p_ithandle = timeout(realitexpire, (caddr_t)p, - tvtohz(&ntv) - 1); + callout_reset(&p->p_itcallout, tvtohz(&ntv) - 1, + realitexpire, p); splx(s); return; } diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index d4aa88f..0e3b6a3 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -61,6 +61,9 @@ static void domaininit __P((void *)); SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL) +static struct callout pffast_callout; +static struct callout pfslow_callout; + static void pffasttimo __P((void *)); static void pfslowtimo __P((void *)); @@ -137,8 +140,11 @@ domaininit(void *dummy) if (max_linkhdr < 16) /* XXX */ max_linkhdr = 16; - timeout(pffasttimo, (void *)0, 1); - timeout(pfslowtimo, (void *)0, 1); + callout_init(&pffast_callout, 0); + callout_init(&pfslow_callout, 0); + + callout_reset(&pffast_callout, 1, pffasttimo, NULL); + callout_reset(&pfslow_callout, 1, pfslowtimo, NULL); } @@ -214,7 +220,7 @@ pfslowtimo(arg) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_slowtimo) (*pr->pr_slowtimo)(); - timeout(pfslowtimo, (void *)0, hz/2); + callout_reset(&pfslow_callout, hz/2, pfslowtimo, NULL); } static void @@ -228,5 +234,5 @@ pffasttimo(arg) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_fasttimo) (*pr->pr_fasttimo)(); - timeout(pffasttimo, (void *)0, hz/5); + callout_reset(&pffast_callout, hz/5, pffasttimo, NULL); } |