diff --git a/minix/servers/sched/Makefile b/minix/servers/sched/Makefile index 4202ecd9a..067e9fedb 100644 --- a/minix/servers/sched/Makefile +++ b/minix/servers/sched/Makefile @@ -2,11 +2,7 @@ PROG= sched SRCS= main.c schedule.c utility.c -DPADD+= ${LIBSYS} ${LIBTIMERS} -LDADD+= -lsys -ltimers - -CPPFLAGS.main.c+= -I${NETBSDSRCDIR}/minix -CPPFLAGS.schedule.c+= -I${NETBSDSRCDIR}/minix -CPPFLAGS.utility.c+= -I${NETBSDSRCDIR}/minix +DPADD+= ${LIBSYS} +LDADD+= -lsys .include diff --git a/minix/servers/sched/main.c b/minix/servers/sched/main.c index 8e0a990b5..1b87bb4b9 100644 --- a/minix/servers/sched/main.c +++ b/minix/servers/sched/main.c @@ -49,14 +49,14 @@ int main(void) /* Check for system notifications first. Special cases. */ if (is_ipc_notify(ipc_status)) { switch(who_e) { - case CLOCK: - expire_timers(m_in.m_notify.timestamp); - continue; /* don't reply */ - default : - result = ENOSYS; + case CLOCK: + balance_queues(); + break; + default : + break; } - goto sendreply; + continue; /* Don't reply. */ } switch(call_nr) { @@ -91,7 +91,6 @@ int main(void) result = no_sys(who_e, call_nr); } -sendreply: /* Send reply. */ if (result != SUSPEND) { m_in.m_type = result; /* build reply message */ diff --git a/minix/servers/sched/proto.h b/minix/servers/sched/proto.h index a4262e247..640550d90 100644 --- a/minix/servers/sched/proto.h +++ b/minix/servers/sched/proto.h @@ -1,7 +1,6 @@ /* Function prototypes. */ struct schedproc; -#include /* main.c */ int main(void); @@ -13,6 +12,7 @@ int do_start_scheduling(message *m_ptr); int do_stop_scheduling(message *m_ptr); int do_nice(message *m_ptr); void init_scheduling(void); +void balance_queues(void); /* utility.c */ int no_sys(int who_e, int call_nr); diff --git a/minix/servers/sched/sched.h b/minix/servers/sched/sched.h index c1bd76d1f..6d8190027 100644 --- a/minix/servers/sched/sched.h +++ b/minix/servers/sched/sched.h @@ -10,7 +10,6 @@ #include #include -#include #include diff --git a/minix/servers/sched/schedule.c b/minix/servers/sched/schedule.c index 6fac2fb82..9d1c503a2 100644 --- a/minix/servers/sched/schedule.c +++ b/minix/servers/sched/schedule.c @@ -12,15 +12,12 @@ #include #include #include -#include "kernel/proc.h" /* for queue constants */ -static minix_timer_t sched_timer; static unsigned balance_timeout; #define BALANCE_TIMEOUT 5 /* how often to balance queues in seconds */ static int schedule_process(struct schedproc * rmp, unsigned flags); -static void balance_queues(minix_timer_t *tp); #define SCHEDULE_CHANGE_PRIO 0x1 #define SCHEDULE_CHANGE_QUANTUM 0x2 @@ -330,29 +327,31 @@ static int schedule_process(struct schedproc * rmp, unsigned flags) /*===========================================================================* - * start_scheduling * + * init_scheduling * *===========================================================================*/ - void init_scheduling(void) { + int r; + balance_timeout = BALANCE_TIMEOUT * sys_hz(); - init_timer(&sched_timer); - set_timer(&sched_timer, balance_timeout, balance_queues, 0); + + if ((r = sys_setalarm(balance_timeout, 0)) != OK) + panic("sys_setalarm failed: %d", r); } /*===========================================================================* * balance_queues * *===========================================================================*/ -/* This function in called every 100 ticks to rebalance the queues. The current +/* This function in called every N ticks to rebalance the queues. The current * scheduler bumps processes down one priority when ever they run out of * quantum. This function will find all proccesses that have been bumped down, * and pulls them back up. This default policy will soon be changed. */ -static void balance_queues(minix_timer_t *tp) +void balance_queues(void) { struct schedproc *rmp; - int proc_nr; + int r, proc_nr; for (proc_nr=0, rmp=schedproc; proc_nr < NR_PROCS; proc_nr++, rmp++) { if (rmp->flags & IN_USE) { @@ -363,5 +362,6 @@ static void balance_queues(minix_timer_t *tp) } } - set_timer(&sched_timer, balance_timeout, balance_queues, 0); + if ((r = sys_setalarm(balance_timeout, 0)) != OK) + panic("sys_setalarm failed: %d", r); } diff --git a/minix/servers/sched/utility.c b/minix/servers/sched/utility.c index 3755ad1e1..f05bf8886 100644 --- a/minix/servers/sched/utility.c +++ b/minix/servers/sched/utility.c @@ -10,7 +10,6 @@ #include "sched.h" #include #include /* for PRIO_MAX & PRIO_MIN */ -#include "kernel/proc.h" /* for queue constants */ #include "schedproc.h" /*===========================================================================*