-/* $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 $ */
/*
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));
/*
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)
-/* $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 $ */
/*-
#include <sys/resourcevar.h>
#include <vm/vm.h>
#include <sys/sched.h>
+#include <sys/timeout.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
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()).
*/
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.
*/
roundrobin(arg)
void *arg;
{
+ struct timeout *to = (struct timeout *)arg;
need_resched();
roundrobin_attempts++;
- timeout(roundrobin, NULL, hz / 10);
+ timeout_add(to, hz / 10);
}
/*
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;
/*
vmmeter();
#endif
wakeup((caddr_t)&lbolt);
- timeout(schedcpu, (void *)0, hz);
+ timeout_add(to, hz);
}
/*