From: art Date: Thu, 23 Mar 2000 16:54:43 +0000 (+0000) Subject: Don't reinitialize the tsleep and ITIMER_REAL timers all the time. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d256b03a776c2cbec7b02264a5e4a253a24fe78e;p=openbsd Don't reinitialize the tsleep and ITIMER_REAL timers all the time. The function and the argument never change. --- diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 0b3f2795abf..13ba4c4f93d 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.51 2000/03/23 10:13:58 art Exp $ */ +/* $OpenBSD: init_main.c,v 1.52 2000/03/23 16:54:44 art Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -190,6 +190,8 @@ main(framep) extern struct pdevinit pdevinit[]; extern void scheduler_start __P((void)); extern void disk_init __P((void)); + extern void endtsleep __P((void *)); + extern void realitexpire __P((void *)); /* * Initialize the current process pointer (curproc) before @@ -244,6 +246,10 @@ main(framep) p->p_emul = &emul_native; bcopy("swapper", p->p_comm, sizeof ("swapper")); + /* Init timeouts. */ + timeout_set(&p->p_sleep_to, endtsleep, p); + timeout_set(&p->p_realit_to, realitexpire, p); + /* Create credentials. */ cred0.p_refcnt = 1; p->p_cred = &cred0; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 55c0ac1710c..b2a08f77625 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.30 2000/03/03 11:46:09 art Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.31 2000/03/23 16:54:44 art Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -141,13 +141,15 @@ fork1(p1, flags, stack, stacksize, retval) size_t stacksize; register_t *retval; { - register struct proc *p2; - register uid_t uid; + struct proc *p2; + uid_t uid; struct proc *newproc; struct vmspace *vm; int count; static int pidchecked = 0; vaddr_t uaddr; + extern void endtsleep __P((void *)); + extern void realitexpire __P((void *)); /* * Although process entries are dynamically created, we still keep @@ -251,6 +253,12 @@ again: bcopy(&p1->p_startcopy, &p2->p_startcopy, (unsigned) ((caddr_t)&p2->p_endcopy - (caddr_t)&p2->p_startcopy)); + /* + * Initialize the timeouts. + */ + timeout_set(&p2->p_sleep_to, endtsleep, p2); + timeout_set(&p2->p_realit_to, realitexpire, p2); + /* * Duplicate sub-structures as needed. * Increase reference counts on shared objects. diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index ebb7199d205..804e830e8bf 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.22 2000/03/23 14:44:37 art Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.23 2000/03/23 16:54:43 art Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -378,10 +378,8 @@ tsleep(ident, priority, wmesg, timo) else *qp->sq_tailp = p; *(qp->sq_tailp = &p->p_forw) = 0; - if (timo) { - timeout_set(&p->p_sleep_to, endtsleep, p); + if (timo) timeout_add(&p->p_sleep_to, timo); - } /* * We put ourselves on the sleep queue and start our timeout * before calling CURSIG, as we could stop there, and a wakeup diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 736fe37775a..8ee5899f8de 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.18 2000/03/23 15:55:52 art Exp $ */ +/* $OpenBSD: kern_time.c,v 1.19 2000/03/23 16:54:44 art Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -489,7 +489,6 @@ sys_setitimer(p, v, retval) timeout_del(&p->p_realit_to); if (timerisset(&aitv.it_value)) { timeradd(&aitv.it_value, &time, &aitv.it_value); - timeout_set(&p->p_realit_to, realitexpire, p); timeout_add(&p->p_realit_to, hzto(&aitv.it_value)); } p->p_realtimer = aitv;