From bd6aa174762fe0536eeb548b582babe74bc68590 Mon Sep 17 00:00:00 2001 From: art Date: Thu, 23 Mar 2000 10:13:58 +0000 Subject: [PATCH] Adapt roundrobin and schedcpu to the new timeout API. --- sys/kern/init_main.c | 10 ++++----- sys/kern/kern_synch.c | 49 ++++++++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index e2c7d71a6f1..0b3f2795abf 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.50 2000/03/22 21:35:37 mickey Exp $ */ +/* $OpenBSD: init_main.c,v 1.51 2000/03/23 10:13:58 art Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -188,8 +188,7 @@ main(framep) int s; register_t rval[2]; extern struct pdevinit pdevinit[]; - extern void roundrobin __P((void *)); - extern void schedcpu __P((void *)); + extern void scheduler_start __P((void)); extern void disk_init __P((void)); /* @@ -372,9 +371,8 @@ main(framep) kmstartup(); #endif - /* Kick off timeout driven events by calling first time. */ - roundrobin(NULL); - schedcpu(NULL); + /* Start the scheduler */ + scheduler_start(); /* Configure root/swap devices */ if (md_diskconf) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 99b9abc9f20..f419350c8f7 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.20 2000/03/03 16:49:25 art Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.21 2000/03/23 10:13:58 art Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -50,6 +50,7 @@ #include #include #include +#include #if defined(UVM) #include @@ -64,6 +65,33 @@ u_char curpriority; /* usrpri of curproc */ int lbolt; /* once a second sleep address */ +void scheduler_start __P((void)); + +void roundrobin __P((void *)); +void schedcpu __P((void *)); +void updatepri __P((struct proc *)); +void endtsleep __P((void *)); + +void +scheduler_start() +{ + static struct timeout roundrobin_to; + static struct timeout schedcpu_to; + + /* + * We avoid polluting the global namespace by keeping the scheduler + * timeouts static in this function. + * We setup the timeouts here and kick rundrobin and schedcpu once to + * make them do their job. + */ + + timeout_set(&roundrobin_to, roundrobin, &roundrobin_to); + timeout_set(&schedcpu_to, schedcpu, &schedcpu_to); + + roundrobin(&roundrobin_to); + schedcpu(&schedcpu_to); +} + /* * We need to keep track on how many times we call roundrobin before we * actually attempt a switch (that is when we call mi_switch()). @@ -72,11 +100,6 @@ int lbolt; /* once a second sleep address */ */ int roundrobin_attempts; -void roundrobin __P((void *)); -void schedcpu __P((void *)); -void updatepri __P((struct proc *)); -void endtsleep __P((void *)); - /* * Force switch among equal priority processes every 100ms. */ @@ -85,10 +108,11 @@ void roundrobin(arg) void *arg; { + struct timeout *to = (struct timeout *)arg; need_resched(); roundrobin_attempts++; - timeout(roundrobin, NULL, hz / 10); + timeout_add(to, hz / 10); } /* @@ -184,10 +208,11 @@ void schedcpu(arg) void *arg; { - register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); - register struct proc *p; - register int s; - register unsigned int newcpu; + struct timeout *to = (struct timeout *)arg; + fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); + struct proc *p; + int s; + unsigned int newcpu; int phz; /* @@ -251,7 +276,7 @@ schedcpu(arg) vmmeter(); #endif wakeup((caddr_t)&lbolt); - timeout(schedcpu, (void *)0, hz); + timeout_add(to, hz); } /* -- 2.20.1