From 895850b8cfc24898e05a260c9097e1f8d0313e19 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Fri, 9 Jul 2010 12:58:18 +0000 Subject: [PATCH] move timers code to libsys --- drivers/floppy/floppy.c | 78 ++++++---------------------------- drivers/fxp/fxp.c | 87 +++----------------------------------- drivers/orinoco/orinoco.c | 3 -- drivers/rtl8139/rtl8139.c | 3 -- drivers/rtl8139/rtl8139.h | 2 - drivers/rtl8169/rtl8169.c | 3 -- drivers/tty/console.c | 26 +++--------- drivers/tty/keyboard.c | 26 +++--------- drivers/tty/tty.c | 62 ++++----------------------- drivers/tty/tty.h | 4 -- include/Makefile | 2 +- include/minix/drivers.h | 1 + include/minix/timers.h | 16 +++++++ lib/libsys/Makefile | 3 +- lib/libsys/timers.c | 88 +++++++++++++++++++++++++++++++++++++++ servers/inet/inet.c | 1 - servers/pm/Makefile | 2 +- servers/pm/alarm.c | 11 ++--- servers/pm/main.c | 4 +- servers/pm/pm.h | 1 + servers/pm/proto.h | 6 --- servers/pm/timers.c | 87 -------------------------------------- servers/sched/Makefile | 2 +- servers/sched/main.c | 2 +- servers/sched/proto.h | 7 +--- servers/sched/sched.h | 1 + servers/sched/schedule.c | 6 +-- servers/sched/timers.c | 62 --------------------------- servers/vfs/Makefile | 2 +- servers/vfs/fs.h | 1 + servers/vfs/main.c | 2 +- servers/vfs/proto.h | 9 ---- servers/vfs/select.c | 6 +-- servers/vfs/timers.c | 61 --------------------------- 34 files changed, 168 insertions(+), 509 deletions(-) create mode 100644 include/minix/timers.h create mode 100644 lib/libsys/timers.c delete mode 100644 servers/pm/timers.c delete mode 100644 servers/sched/timers.c delete mode 100644 servers/vfs/timers.c diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index d8384d8e7..2a706e5a1 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -238,12 +238,8 @@ PRIVATE u8_t f_results[MAX_RESULTS];/* the controller can give lots of output */ * floppy disk drive contains a 'fl_tmr_stop' timer. */ PRIVATE timer_t f_tmr_timeout; /* timer for various timeouts */ -PRIVATE timer_t *f_timers; /* queue of floppy timers */ -PRIVATE clock_t f_next_timeout; /* the next timeout time */ PRIVATE u32_t system_hz; /* system clock frequency */ FORWARD _PROTOTYPE( void f_expire_tmrs, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( void f_set_timer, (timer_t *tp, clock_t delta, - tmr_func_t watchdog) ); FORWARD _PROTOTYPE( void stop_motor, (timer_t *tp) ); FORWARD _PROTOTYPE( void f_timeout, (timer_t *tp) ); @@ -348,14 +344,13 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info) AC_LOWER16M | AC_ALIGN4K, &floppy_buf_phys))) panic("couldn't allocate dma buffer"); - f_next_timeout = TMR_NEVER; - tmr_inittimer(&f_tmr_timeout); + init_timer(&f_tmr_timeout); for (fp = &floppy[0]; fp < &floppy[NR_DRIVES]; fp++) { fp->fl_curcyl = NO_CYL; fp->fl_density = NO_DENS; fp->fl_class = ~0; - tmr_inittimer(&fp->fl_tmr_stop); + init_timer(&fp->fl_tmr_stop); } /* Set IRQ policy, only request notifications, do not automatically @@ -394,57 +389,11 @@ PRIVATE void sef_cb_signal_handler(int signo) *===========================================================================*/ PRIVATE void f_expire_tmrs(struct driver *dp, message *m_ptr) { -/* A synchronous alarm message was received. Check if there are any expired - * timers. Possibly reschedule the next alarm. +/* A synchronous alarm message was received. Call the watchdog function for + * each expired timer, if any. */ - clock_t now; /* current time */ - int s; - /* Get the current time to compare the timers against. */ - if ((s=getuptime(&now)) != OK) - panic("Couldn't get uptime from clock: %d", s); - - /* Scan the timers queue for expired timers. Dispatch the watchdog function - * for each expired timers. FLOPPY watchdog functions are f_tmr_timeout() - * and stop_motor(). Possibly a new alarm call must be scheduled. - */ - tmrs_exptimers(&f_timers, now, NULL); - if (f_timers == NULL) { - f_next_timeout = TMR_NEVER; - } else { /* set new sync alarm */ - f_next_timeout = f_timers->tmr_exp_time; - if ((s=sys_setalarm(f_next_timeout, 1)) != OK) - panic("Couldn't set synchronous alarm: %d", s); - } -} - -/*===========================================================================* - * f_set_timer * - *===========================================================================*/ -PRIVATE void f_set_timer(tp, delta, watchdog) -timer_t *tp; /* timer to be set */ -clock_t delta; /* in how many ticks */ -tmr_func_t watchdog; /* watchdog function to be called */ -{ - clock_t now; /* current time */ - int s; - - /* Get the current time. */ - if ((s=getuptime(&now)) != OK) - panic("Couldn't get uptime from clock: %d", s); - - /* Add the timer to the local timer queue. */ - tmrs_settimer(&f_timers, tp, now + delta, watchdog, NULL); - - /* Possibly reschedule an alarm call. This happens when the front of the - * timers queue was reinserted at another position, i.e., when a timer was - * reset, or when a new timer was added in front. - */ - if (f_timers->tmr_exp_time != f_next_timeout) { - f_next_timeout = f_timers->tmr_exp_time; - if ((s=sys_setalarm(f_next_timeout, 1)) != OK) - panic("Couldn't set synchronous alarm: %d", s); - } + expire_timers(m_ptr->NOTIFY_TIMESTAMP); } /*===========================================================================* @@ -492,8 +441,7 @@ PRIVATE char *f_name(void) PRIVATE void f_cleanup(void) { /* Start a timer to turn the motor off in a few seconds. */ - tmr_arg(&f_fp->fl_tmr_stop)->ta_int = f_drive; - f_set_timer(&f_fp->fl_tmr_stop, MOTOR_OFF, stop_motor); + set_timer(&f_fp->fl_tmr_stop, MOTOR_OFF, stop_motor, f_drive); /* Exiting the floppy driver, so forget where we are. */ f_fp->fl_sector = NO_SECTOR; @@ -818,7 +766,7 @@ PRIVATE void start_motor(void) /* Set an alarm timer to force a timeout if the hardware does not interrupt * in time. Expect an interrupt, but check for a timeout. */ - f_set_timer(&f_tmr_timeout, f_dp->start_ms * system_hz / 1000, f_timeout); + set_timer(&f_tmr_timeout, f_dp->start_ms * system_hz / 1000, f_timeout, 0); f_busy = BSY_IO; do { driver_receive(ANY, &mess, &ipc_status); @@ -826,7 +774,7 @@ PRIVATE void start_motor(void) if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(mess.m_source)) { case CLOCK: - f_expire_tmrs(NULL, NULL); + f_expire_tmrs(NULL, &mess); break; default : f_busy = BSY_IDLE; @@ -893,7 +841,7 @@ PRIVATE int seek(void) /* Set a synchronous alarm to force a timeout if the hardware does * not interrupt. */ - f_set_timer(&f_tmr_timeout, system_hz/30, f_timeout); + set_timer(&f_tmr_timeout, system_hz/30, f_timeout, 0); f_busy = BSY_IO; do { driver_receive(ANY, &mess, &ipc_status); @@ -901,7 +849,7 @@ PRIVATE int seek(void) if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(mess.m_source)) { case CLOCK: - f_expire_tmrs(NULL, NULL); + f_expire_tmrs(NULL, &mess); break; default : f_busy = BSY_IDLE; @@ -1057,7 +1005,7 @@ PRIVATE int fdc_command( * Note that the actual check is done by the code that issued the * fdc_command() call. */ - f_set_timer(&f_tmr_timeout, WAKEUP, f_timeout); + set_timer(&f_tmr_timeout, WAKEUP, f_timeout, 0); f_busy = BSY_IO; while (len > 0) { @@ -1183,7 +1131,7 @@ PRIVATE void f_reset(void) if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(mess.m_source)) { case CLOCK: - f_expire_tmrs(NULL, NULL); + f_expire_tmrs(NULL, &mess); break; default : f_busy = BSY_IDLE; @@ -1233,7 +1181,7 @@ PRIVATE int f_intr_wait(void) if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(mess.m_source)) { case CLOCK: - f_expire_tmrs(NULL, NULL); + f_expire_tmrs(NULL, &mess); break; default : f_busy = BSY_IDLE; diff --git a/drivers/fxp/fxp.c b/drivers/fxp/fxp.c index 02480986b..3271c6620 100644 --- a/drivers/fxp/fxp.c +++ b/drivers/fxp/fxp.c @@ -20,8 +20,6 @@ #include -#define tmra_ut timer_t -#define tmra_inittimer(tp) tmr_inittimer(tp) #define debug 0 #define RAND_UPDATE /**/ #define printW() ((void)0) @@ -61,9 +59,6 @@ PRIVATE struct pcitab pcitab_fxp[]= typedef int irq_hook_t; -static timer_t *fxp_timers= NULL; -static clock_t fxp_next_timeout= 0; - /* ignore interrupt for the moment */ #define interrupt(x) 0 @@ -165,7 +160,7 @@ PRIVATE int fxp_instance; PRIVATE fxp_t *fxp_state; -PRIVATE tmra_ut fxp_watchdog; +PRIVATE timer_t fxp_watchdog; PRIVATE u32_t system_hz; @@ -202,9 +197,6 @@ _PROTOTYPE( static void mess_reply, (message *req, message *reply) ); _PROTOTYPE( static u16_t eeprom_read, (fxp_t *fp, int reg) ); _PROTOTYPE( static void eeprom_addrsize, (fxp_t *fp) ); _PROTOTYPE( static u16_t mii_read, (fxp_t *fp, int reg) ); -_PROTOTYPE( static void fxp_set_timer,(timer_t *tp, clock_t delta, - tmr_func_t watchdog) ); -_PROTOTYPE( static void fxp_expire_timers,(void) ); _PROTOTYPE( static u8_t do_inb, (port_t port) ); _PROTOTYPE( static u32_t do_inl, (port_t port) ); _PROTOTYPE( static void do_outb, (port_t port, u8_t v) ); @@ -266,7 +258,7 @@ int main(int argc, char *argv[]) handle_hw_intr(); break; case CLOCK: - fxp_expire_timers(); + expire_timers(m.NOTIFY_TIMESTAMP); break; default: panic(" illegal notify from: %d", m.m_source); @@ -382,9 +374,8 @@ message *mp; first_time= 0; fxp_pci_conf(); /* Configure PCI devices. */ - tmra_inittimer(&fxp_watchdog); - tmr_arg(&fxp_watchdog)->ta_int= 0; - fxp_set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f); + init_timer(&fxp_watchdog); + set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f, 0); } fp= fxp_state; @@ -1771,8 +1762,7 @@ timer_t *tp; { fxp_t *fp; - tmr_arg(&fxp_watchdog)->ta_int= 0; - fxp_set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f); + set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f, 0); fp= fxp_state; if (fp->fxp_mode != FM_ENABLED) @@ -2260,73 +2250,6 @@ int reg; return v & CM_DATA_MASK; } -/*===========================================================================* - * fxp_set_timer * - *===========================================================================*/ -PRIVATE void fxp_set_timer(tp, delta, watchdog) -timer_t *tp; /* timer to be set */ -clock_t delta; /* in how many ticks */ -tmr_func_t watchdog; /* watchdog function to be called */ -{ - clock_t now; /* current time */ - int r; - - /* Get the current time. */ - r= getuptime(&now); - if (r != OK) - panic("unable to get uptime from clock: %d", r); - - /* Add the timer to the local timer queue. */ - tmrs_settimer(&fxp_timers, tp, now + delta, watchdog, NULL); - - /* Possibly reschedule an alarm call. This happens when a new timer - * is added in front. - */ - if (fxp_next_timeout == 0 || - fxp_timers->tmr_exp_time < fxp_next_timeout) - { - fxp_next_timeout= fxp_timers->tmr_exp_time; -#if VERBOSE - printf("fxp_set_timer: calling sys_setalarm for %d (now+%d)\n", - fxp_next_timeout, fxp_next_timeout-now); -#endif - r= sys_setalarm(fxp_next_timeout, 1); - if (r != OK) - panic("unable to set synchronous alarm: %d", r); - } -} - -/*===========================================================================* - * fxp_expire_tmrs * - *===========================================================================*/ -PRIVATE void fxp_expire_timers() -{ -/* A synchronous alarm message was received. Check if there are any expired - * timers. Possibly reschedule the next alarm. - */ - clock_t now; /* current time */ - int r; - - /* Get the current time to compare the timers against. */ - r= getuptime(&now); - if (r != OK) - panic("Unable to get uptime from clock: %d", r); - - /* Scan the timers queue for expired timers. Dispatch the watchdog function - * for each expired timers. Possibly a new alarm call must be scheduled. - */ - tmrs_exptimers(&fxp_timers, now, NULL); - if (fxp_timers == NULL) - fxp_next_timeout= TMR_NEVER; - else - { /* set new alarm */ - fxp_next_timeout = fxp_timers->tmr_exp_time; - r= sys_setalarm(fxp_next_timeout, 1); - if (r != OK) - panic("Unable to set synchronous alarm: %d", r); - } -} - static u8_t do_inb(port_t port) { int r; diff --git a/drivers/orinoco/orinoco.c b/drivers/orinoco/orinoco.c index 97409e943..43430493b 100644 --- a/drivers/orinoco/orinoco.c +++ b/drivers/orinoco/orinoco.c @@ -37,8 +37,6 @@ PRIVATE struct pcitab { }; -static timer_t or_watchdog; - #include #include #include @@ -437,7 +435,6 @@ static void or_init (message * mp) { first_time = 0; or_pci_conf (); /* Configure PCI devices. */ - tmr_inittimer(&or_watchdog); /* Use a synchronous alarm instead of a watchdog timer. */ sys_setalarm(system_hz, 0); } diff --git a/drivers/rtl8139/rtl8139.c b/drivers/rtl8139/rtl8139.c index 3ba0c411f..c7cef8c84 100644 --- a/drivers/rtl8139/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -50,8 +50,6 @@ PUBLIC re_t re_state; static int re_instance; -static tmra_ut rl_watchdog; - static unsigned my_inb(u16_t port) { u32_t value; int s; @@ -372,7 +370,6 @@ message *mp; first_time= 0; rl_pci_conf(); /* Configure PCI devices. */ - tmra_inittimer(&rl_watchdog); /* Use a synchronous alarm instead of a watchdog timer. */ sys_setalarm(system_hz, 0); } diff --git a/drivers/rtl8139/rtl8139.h b/drivers/rtl8139/rtl8139.h index 9ed63d914..cebda5b72 100644 --- a/drivers/rtl8139/rtl8139.h +++ b/drivers/rtl8139/rtl8139.h @@ -453,8 +453,6 @@ d8 R/W Config5 Configuration register 5 d9-ff reserved #endif -#define tmra_ut timer_t -#define tmra_inittimer(tp) tmr_inittimer(tp) #define Proc_number(p) proc_number(p) #define debug 0 #define printW() ((void)0) diff --git a/drivers/rtl8169/rtl8169.c b/drivers/rtl8169/rtl8169.c index a1ff8108c..82b86a5c2 100644 --- a/drivers/rtl8169/rtl8169.c +++ b/drivers/rtl8169/rtl8169.c @@ -179,8 +179,6 @@ static re_t re_state; static int re_instance; -static timer_t rl_watchdog; - static unsigned my_inb(u16_t port) { u32_t value; @@ -579,7 +577,6 @@ message *mp; first_time = 0; rl_pci_conf(); /* Configure PCI devices. */ - tmr_inittimer(&rl_watchdog); /* Use a synchronous alarm instead of a watchdog timer. */ sys_setalarm(system_hz, 0); } diff --git a/drivers/tty/console.c b/drivers/tty/console.c index deb920153..bbe4b3cf1 100644 --- a/drivers/tty/console.c +++ b/drivers/tty/console.c @@ -771,9 +771,9 @@ PRIVATE void beep() unsigned long port_b_val; int s; - /* Fetch current time in advance to prevent beeping delay. */ - if ((s=getuptime(&now)) != OK) - panic("Console couldn't get clock's uptime: %d", s); + /* Set timer in advance to prevent beeping delay. */ + set_timer(&tmr_stop_beep, B_TIME, stop_beep, 0); + if (!beeping) { /* Set timer channel 2, square wave, with given frequency. */ pv_set(char_out[0], TIMER_MODE, 0xB6); @@ -785,13 +785,6 @@ PRIVATE void beep() beeping = TRUE; } } - /* Add a timer to the timers list. Possibly reschedule the alarm. */ - tmrs_settimer(&tty_timers, &tmr_stop_beep, now+B_TIME, stop_beep, NULL); - if (tty_timers->tmr_exp_time != tty_next_timeout) { - tty_next_timeout = tty_timers->tmr_exp_time; - if ((s=sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Console couldn't set alarm: %d", s); - } } @@ -898,9 +891,9 @@ clock_t dur; if (ival == 0 || ival > 0xffff) return; /* Frequency out of range */ - /* Fetch current time in advance to prevent beeping delay. */ - if ((s=getuptime(&now)) != OK) - panic("Console couldn't get clock's uptime: %d", s); + /* Set timer in advance to prevent beeping delay. */ + set_timer(&tmr_stop_beep, dur, stop_beep, 0); + if (!beeping) { /* Set timer channel 2, square wave, with given frequency. */ pv_set(char_out[0], TIMER_MODE, 0xB6); @@ -912,13 +905,6 @@ clock_t dur; beeping = TRUE; } } - /* Add a timer to the timers list. Possibly reschedule the alarm. */ - tmrs_settimer(&tty_timers, &tmr_stop_beep, now+dur, stop_beep, NULL); - if (tty_timers->tmr_exp_time != tty_next_timeout) { - tty_next_timeout = tty_timers->tmr_exp_time; - if ((s=sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Console couldn't set alarm: %d", s); - } } /*===========================================================================* diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index aece6f9f8..6938e4a91 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -706,18 +706,9 @@ PRIVATE void kbd_send() kbd_alive= 1; if (kbd_watchdog_set) { - /* Add a timer to the timers list. Possibly reschedule the - * alarm. - */ - if ((r= getuptime(&now)) != OK) - panic("Keyboard couldn't get clock's uptime: %d", r); - tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog, - NULL); - if (tty_timers->tmr_exp_time != tty_next_timeout) { - tty_next_timeout = tty_timers->tmr_exp_time; - if ((r= sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Keyboard couldn't set alarm: %d", r); - } + /* Set a watchdog timer for one second. */ + set_timer(&tmr_kbd_wd, system_hz, kbd_watchdog, 0); + kbd_watchdog_set= 1; } } @@ -1320,14 +1311,7 @@ timer_t *tmrp; } kbd_alive= 0; - if ((r= getuptime(&now)) != OK) - panic("Keyboard couldn't get clock's uptime: %d", r); - tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog, - NULL); - if (tty_timers->tmr_exp_time != tty_next_timeout) { - tty_next_timeout = tty_timers->tmr_exp_time; - if ((r= sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Keyboard couldn't set alarm: %d", r); - } + set_timer(&tmr_kbd_wd, system_hz, kbd_watchdog, 0); + kbd_watchdog_set= 1; } diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 9a1ea518e..6f3b6d9bb 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -102,7 +102,6 @@ unsigned long rs_irq_set = 0; struct kmessages kmess; FORWARD _PROTOTYPE( void tty_timed_out, (timer_t *tp) ); -FORWARD _PROTOTYPE( void expire_timers, (void) ); FORWARD _PROTOTYPE( void settimer, (tty_t *tty_ptr, int enable) ); FORWARD _PROTOTYPE( void do_cancel, (tty_t *tp, message *m_ptr) ); FORWARD _PROTOTYPE( void do_ioctl, (tty_t *tp, message *m_ptr, int s) ); @@ -136,8 +135,6 @@ PRIVATE struct winsize winsize_defaults; /* = all zeroes */ /* Global variables for the TTY task (declared extern in tty.h). */ PUBLIC tty_t tty_table[NR_CONS+NR_RS_LINES+NR_PTYS]; PUBLIC int ccurrent; /* currently active console */ -PUBLIC timer_t *tty_timers; /* queue of TTY timers */ -PUBLIC clock_t tty_next_timeout; /* time that the next alarm is due */ PUBLIC struct machine machine; /* kernel environment variables */ PUBLIC u32_t system_hz; @@ -187,7 +184,7 @@ PUBLIC int main(void) switch (_ENDPOINT_P(tty_mess.m_source)) { case CLOCK: /* run watchdogs of expired timers */ - expire_timers(); + expire_timers(tty_mess.NOTIFY_TIMESTAMP); break; case HARDWARE: /* hardware interrupt notification */ @@ -201,7 +198,7 @@ PUBLIC int main(void) rs_interrupt(&tty_mess); #endif /* run watchdogs of expired timers */ - expire_timers(); + expire_timers(tty_mess.NOTIFY_TIMESTAMP); break; default: /* do nothing */ @@ -1629,7 +1626,7 @@ PRIVATE void tty_init() tp->tty_index = s; - tmr_inittimer(&tp->tty_tmr); + init_timer(&tp->tty_tmr); tp->tty_intail = tp->tty_inhead = tp->tty_inbuf; tp->tty_min = 1; @@ -1667,33 +1664,6 @@ PRIVATE void tty_timed_out(timer_t *tp) tty_ptr->tty_events = 1; } -/*===========================================================================* - * expire_timers * - *===========================================================================*/ -PRIVATE void expire_timers(void) -{ -/* A synchronous alarm message was received. Check if there are any expired - * timers. Possibly set the event flag and reschedule another alarm. - */ - clock_t now; /* current time */ - int s; - - /* Get the current time to compare the timers against. */ - if ((s=getuptime(&now)) != OK) - panic("Couldn't get uptime from clock: %d", s); - - /* Scan the queue of timers for expired timers. This dispatch the watchdog - * functions of expired timers. Possibly a new alarm call must be scheduled. - */ - tmrs_exptimers(&tty_timers, now, NULL); - if (tty_timers == NULL) tty_next_timeout = TMR_NEVER; - else { /* set new sync alarm */ - tty_next_timeout = tty_timers->tmr_exp_time; - if ((s=sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Couldn't set synchronous alarm: %d", s); - } -} - /*===========================================================================* * settimer * *===========================================================================*/ @@ -1701,32 +1671,16 @@ PRIVATE void settimer(tty_ptr, enable) tty_t *tty_ptr; /* line to set or unset a timer on */ int enable; /* set timer if true, otherwise unset */ { - clock_t now; /* current time */ - clock_t exp_time; - int s; + clock_t ticks; - /* Get the current time to calculate the timeout time. */ - if ((s=getuptime(&now)) != OK) - panic("Couldn't get uptime from clock: %d", s); if (enable) { - exp_time = now + tty_ptr->tty_termios.c_cc[VTIME] * (system_hz/10); + ticks = tty_ptr->tty_termios.c_cc[VTIME] * (system_hz/10); + /* Set a new timer for enabling the TTY events flags. */ - tmrs_settimer(&tty_timers, &tty_ptr->tty_tmr, - exp_time, tty_timed_out, NULL); + set_timer(&tty_ptr->tty_tmr, ticks, tty_timed_out, 0); } else { /* Remove the timer from the active and expired lists. */ - tmrs_clrtimer(&tty_timers, &tty_ptr->tty_tmr, NULL); - } - - /* Now check if a new alarm must be scheduled. This happens when the front - * of the timers queue was disabled or reinserted at another position, or - * when a new timer was added to the front. - */ - if (tty_timers == NULL) tty_next_timeout = TMR_NEVER; - else if (tty_timers->tmr_exp_time != tty_next_timeout) { - tty_next_timeout = tty_timers->tmr_exp_time; - if ((s=sys_setalarm(tty_next_timeout, 1)) != OK) - panic("Couldn't set synchronous alarm: %d", s); + cancel_timer(&tty_ptr->tty_tmr); } } diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index c77d03a09..ff9329ffa 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -128,10 +128,6 @@ extern unsigned long rs_irq_set; /* Times and timeouts. */ #define force_timeout() ((void) (0)) -/* Memory allocated in tty.c, so extern here. */ -extern timer_t *tty_timers; /* queue of TTY timers */ -extern clock_t tty_next_timeout; /* next TTY timeout */ - /* Number of elements and limit of a buffer. */ #define buflen(buf) (sizeof(buf) / sizeof((buf)[0])) #define bufend(buf) ((buf) + buflen(buf)) diff --git a/include/Makefile b/include/Makefile index e453d0c1f..13f1855e2 100644 --- a/include/Makefile +++ b/include/Makefile @@ -23,7 +23,7 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \ minix/portio.h minix/profile.h minix/queryparam.h \ minix/rs.h minix/safecopies.h minix/sched.h minix/sef.h minix/sound.h \ minix/sys_config.h minix/sysinfo.h minix/syslib.h \ - minix/sysutil.h minix/tty.h minix/type.h minix/types.h \ + minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \ minix/u64.h minix/vfsif.h minix/vm.h \ minix/compiler.h minix/compiler-ack.h minix/sha2.h INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h diff --git a/include/minix/drivers.h b/include/minix/drivers.h index b68b447fb..fd2ae6cb6 100644 --- a/include/minix/drivers.h +++ b/include/minix/drivers.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include /* IRQ vectors and miscellaneous ports */ diff --git a/include/minix/timers.h b/include/minix/timers.h new file mode 100644 index 000000000..edc44e4c3 --- /dev/null +++ b/include/minix/timers.h @@ -0,0 +1,16 @@ +#ifndef _MINIX_TIMERS_H +#define _MINIX_TIMERS_H + +/* Timers abstraction for system processes. This would be in minix/sysutil.h + * if it weren't for naming conflicts. + */ + +#include + +_PROTOTYPE( void init_timer, (timer_t *tp)); +_PROTOTYPE( void set_timer, (timer_t *tp, int ticks, tmr_func_t watchdog, + int arg)); +_PROTOTYPE( void cancel_timer, (timer_t *tp)); +_PROTOTYPE( void expire_timers, (clock_t now)); + +#endif /* _MINIX_TIMERS_H */ diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index ad76629e8..cc8e7773c 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -120,7 +120,8 @@ SRCS= \ timing.c \ profile_extern.c \ profile.c \ - vprintf.c + vprintf.c \ + timers.c CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR} diff --git a/lib/libsys/timers.c b/lib/libsys/timers.c new file mode 100644 index 000000000..726583c28 --- /dev/null +++ b/lib/libsys/timers.c @@ -0,0 +1,88 @@ +/* Watchdog timer management. These functions in this file provide a + * convenient interface to the timers library that manages a list of + * watchdog timers. All details of scheduling an alarm at the CLOCK task + * are hidden behind this interface. + * + * The entry points into this file are: + * init_timer: initialize a timer structure + * set_timer: reset and existing or set a new watchdog timer + * cancel_timer: remove a timer from the list of timers + * expire_timers: check for expired timers and run watchdog functions + * + */ + +#include "syslib.h" +#include + +PRIVATE timer_t *timers = NULL; +PRIVATE int expiring = 0; + +/*===========================================================================* + * init_timer * + *===========================================================================*/ +PUBLIC void init_timer(timer_t *tp) +{ + tmr_inittimer(tp); +} + +/*===========================================================================* + * set_timer * + *===========================================================================*/ +PUBLIC void set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) +{ + int r; + clock_t now, prev_time = 0, next_time; + + if ((r = getuptime(&now)) != OK) + panic("set_timer: couldn't get uptime"); + + /* Set timer argument and add timer to the list. */ + tmr_arg(tp)->ta_int = arg; + prev_time = tmrs_settimer(&timers, tp, now+ticks, watchdog, &next_time); + + /* Reschedule our synchronous alarm if necessary. */ + if (expiring == 0 && (! prev_time || prev_time > next_time)) { + if (sys_setalarm(next_time, 1) != OK) + panic("set_timer: couldn't set alarm"); + } +} + +/*===========================================================================* + * cancel_timer * + *===========================================================================*/ +PUBLIC void cancel_timer(timer_t *tp) +{ + clock_t next_time, prev_time; + prev_time = tmrs_clrtimer(&timers, tp, &next_time); + + /* If the earliest timer has been removed, we have to set the alarm to + * the next timer, or cancel the alarm altogether if the last timer + * has been cancelled (next_time will be 0 then). + */ + if (expiring == 0 && (prev_time < next_time || ! next_time)) { + if (sys_setalarm(next_time, 1) != OK) + panic("cancel_timer: couldn't set alarm"); + } +} + +/*===========================================================================* + * expire_timers * + *===========================================================================*/ +PUBLIC void expire_timers(clock_t now) +{ + clock_t next_time; + + /* Check for expired timers. Use a global variable to indicate that + * watchdog functions are called, so that sys_setalarm() isn't called + * more often than necessary when set_timer or cancel_timer are called + * from these watchdog functions. */ + expiring = 1; + tmrs_exptimers(&timers, now, &next_time); + expiring = 0; + + /* Reschedule an alarm if necessary. */ + if (next_time > 0) { + if (sys_setalarm(next_time, 1) != OK) + panic("expire_timers: couldn't set alarm"); + } +} diff --git a/servers/inet/inet.c b/servers/inet/inet.c index cf4b5785b..40dae5e8f 100644 --- a/servers/inet/inet.c +++ b/servers/inet/inet.c @@ -42,7 +42,6 @@ from DL_ETH: #include #include #include -#include #include #include "mq.h" diff --git a/servers/pm/Makefile b/servers/pm/Makefile index ef0f950ac..c1acafd78 100644 --- a/servers/pm/Makefile +++ b/servers/pm/Makefile @@ -1,6 +1,6 @@ # Makefile for Process Manager (PM) PROG= pm -SRCS= main.c forkexit.c break.c exec.c time.c timers.c alarm.c \ +SRCS= main.c forkexit.c break.c exec.c time.c alarm.c \ signal.c utility.c table.c trace.c getset.c misc.c \ profile.c dma.c mcontext.c schedule.c diff --git a/servers/pm/alarm.c b/servers/pm/alarm.c index 4c29103e4..9bb3a4a73 100644 --- a/servers/pm/alarm.c +++ b/servers/pm/alarm.c @@ -337,10 +337,10 @@ struct mproc *rmp; /* process that wants the alarm */ clock_t ticks; /* how many ticks delay before the signal */ { if (ticks > 0) { - pm_set_timer(&rmp->mp_timer, ticks, cause_sigalrm, rmp->mp_endpoint); + set_timer(&rmp->mp_timer, ticks, cause_sigalrm, rmp->mp_endpoint); rmp->mp_flags |= ALARM_ON; } else if (rmp->mp_flags & ALARM_ON) { - pm_cancel_timer(&rmp->mp_timer); + cancel_timer(&rmp->mp_timer); rmp->mp_flags &= ~ALARM_ON; } } @@ -367,9 +367,10 @@ struct timer *tp; if ((rmp->mp_flags & ALARM_ON) == 0) return; /* If an interval is set, set a new timer; otherwise clear the ALARM_ON flag. - * The set_alarm call will be calling pm_set_timer from within this callback - * from the pm_expire_timers function. This is safe, but we must not use the - * "tp" structure below this point anymore. */ + * The set_alarm call will be calling set_timer from within this callback + * from the expire_timers function. This is safe, but we must not use the + * "tp" structure below this point anymore. + */ if (rmp->mp_interval[ITIMER_REAL] > 0) set_alarm(rmp, rmp->mp_interval[ITIMER_REAL]); else rmp->mp_flags &= ~ALARM_ON; diff --git a/servers/pm/main.c b/servers/pm/main.c index 3142c4f88..6c7e89fd1 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -94,7 +94,7 @@ PUBLIC int main() if (is_ipc_notify(ipc_status)) { switch(who_p) { case CLOCK: - pm_expire_timers(m_in.NOTIFY_TIMESTAMP); + expire_timers(m_in.NOTIFY_TIMESTAMP); result = SUSPEND; /* don't reply */ break; default : @@ -201,7 +201,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info) /* Initialize process table, including timers. */ for (rmp=&mproc[0]; rmp<&mproc[NR_PROCS]; rmp++) { - tmr_inittimer(&rmp->mp_timer); + init_timer(&rmp->mp_timer); } /* Build the set of signals which cause core dumps, and the set of signals diff --git a/servers/pm/pm.h b/servers/pm/pm.h index 0d610454e..c915aa8ae 100644 --- a/servers/pm/pm.h +++ b/servers/pm/pm.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/servers/pm/proto.h b/servers/pm/proto.h index 4a216ba84..76d0ef318 100644 --- a/servers/pm/proto.h +++ b/servers/pm/proto.h @@ -92,12 +92,6 @@ _PROTOTYPE( int do_stime, (void) ); _PROTOTYPE( int do_time, (void) ); _PROTOTYPE( int do_times, (void) ); -/* timers.c */ -_PROTOTYPE( void pm_set_timer, (timer_t *tp, int delta, - tmr_func_t watchdog, int arg) ); -_PROTOTYPE( void pm_expire_timers, (clock_t now) ); -_PROTOTYPE( void pm_cancel_timer, (timer_t *tp) ); - /* trace.c */ _PROTOTYPE( int do_trace, (void) ); _PROTOTYPE( void stop_proc, (struct mproc *rmp, int sig_nr) ); diff --git a/servers/pm/timers.c b/servers/pm/timers.c deleted file mode 100644 index df6d4addb..000000000 --- a/servers/pm/timers.c +++ /dev/null @@ -1,87 +0,0 @@ -/* PM watchdog timer management. These functions in this file provide - * a convenient interface to the timers library that manages a list of - * watchdog timers. All details of scheduling an alarm at the CLOCK task - * are hidden behind this interface. - * Only system processes are allowed to set an alarm timer at the kernel. - * Therefore, the PM maintains a local list of timers for user processes - * that requested an alarm signal. - * - * The entry points into this file are: - * pm_set_timer: reset and existing or set a new watchdog timer - * pm_expire_timers: check for expired timers and run watchdog functions - * pm_cancel_timer: remove a time from the list of timers - * - */ - -#include "pm.h" - -#include -#include -#include - -PRIVATE timer_t *pm_timers = NULL; -PRIVATE int pm_expiring = 0; - -/*===========================================================================* - * pm_set_timer * - *===========================================================================*/ -PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) -{ - int r; - clock_t now, prev_time = 0, next_time; - - if ((r = getuptime(&now)) != OK) - panic("PM couldn't get uptime"); - - /* Set timer argument and add timer to the list. */ - tmr_arg(tp)->ta_int = arg; - prev_time = tmrs_settimer(&pm_timers,tp,now+ticks,watchdog,&next_time); - - /* Reschedule our synchronous alarm if necessary. */ - if (pm_expiring == 0 && (! prev_time || prev_time > next_time)) { - if (sys_setalarm(next_time, 1) != OK) - panic("PM set timer couldn't set alarm"); - } - - return; -} - -/*===========================================================================* - * pm_expire_timers * - *===========================================================================*/ -PUBLIC void pm_expire_timers(clock_t now) -{ - clock_t next_time; - - /* Check for expired timers. Use a global variable to indicate that - * watchdog functions are called, so that sys_setalarm() isn't called - * more often than necessary when pm_set_timer or pm_cancel_timer are - * called from these watchdog functions. */ - pm_expiring = 1; - tmrs_exptimers(&pm_timers, now, &next_time); - pm_expiring = 0; - - /* Reschedule an alarm if necessary. */ - if (next_time > 0) { - if (sys_setalarm(next_time, 1) != OK) - panic("PM expire timer couldn't set alarm"); - } -} - -/*===========================================================================* - * pm_cancel_timer * - *===========================================================================*/ -PUBLIC void pm_cancel_timer(timer_t *tp) -{ - clock_t next_time, prev_time; - prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time); - - /* If the earliest timer has been removed, we have to set the alarm to - * the next timer, or cancel the alarm altogether if the last timer has - * been cancelled (next_time will be 0 then). - */ - if (pm_expiring == 0 && (prev_time < next_time || ! next_time)) { - if (sys_setalarm(next_time, 1) != OK) - panic("PM expire timer couldn't set alarm"); - } -} diff --git a/servers/sched/Makefile b/servers/sched/Makefile index 777216c35..da3b08115 100644 --- a/servers/sched/Makefile +++ b/servers/sched/Makefile @@ -1,6 +1,6 @@ # Makefile for Scheduler (SCHED) PROG= sched -SRCS= main.c schedule.c utility.c timers.c +SRCS= main.c schedule.c utility.c DPADD+= ${LIBSYS} ${LIBTIMERS} LDADD+= -lsys -ltimers diff --git a/servers/sched/main.c b/servers/sched/main.c index 5a51da7b9..1b6a12113 100644 --- a/servers/sched/main.c +++ b/servers/sched/main.c @@ -45,7 +45,7 @@ PUBLIC int main(void) if (is_ipc_notify(ipc_status)) { switch(who_e) { case CLOCK: - sched_expire_timers(m_in.NOTIFY_TIMESTAMP); + expire_timers(m_in.NOTIFY_TIMESTAMP); continue; /* don't reply */ default : result = ENOSYS; diff --git a/servers/sched/proto.h b/servers/sched/proto.h index e6312f23e..fcf59e046 100644 --- a/servers/sched/proto.h +++ b/servers/sched/proto.h @@ -19,9 +19,4 @@ _PROTOTYPE( void init_scheduling, (void) ); _PROTOTYPE( int no_sys, (int who_e, int call_nr) ); _PROTOTYPE( int sched_isokendpt, (int ep, int *proc) ); _PROTOTYPE( int sched_isemtyendpt, (int ep, int *proc) ); -_PROTOTYPE( int accept_message, (message *m_ptr) ); - -/* timers.c */ -_PROTOTYPE( void sched_set_timer, (timer_t *tp, int delta, - tmr_func_t watchdog, int arg) ); -_PROTOTYPE( void sched_expire_timers, (clock_t now) ); +_PROTOTYPE( int accept_message, (message *m_ptr) ); diff --git a/servers/sched/sched.h b/servers/sched/sched.h index 24cfeb36d..3388a2fa5 100644 --- a/servers/sched/sched.h +++ b/servers/sched/sched.h @@ -13,6 +13,7 @@ #include #include +#include #include diff --git a/servers/sched/schedule.c b/servers/sched/schedule.c index 9ed806d35..be904c12c 100644 --- a/servers/sched/schedule.c +++ b/servers/sched/schedule.c @@ -227,8 +227,8 @@ PRIVATE int schedule_process(struct schedproc * rmp) PUBLIC void init_scheduling(void) { balance_timeout = BALANCE_TIMEOUT * sys_hz(); - tmr_inittimer(&sched_timer); - sched_set_timer(&sched_timer, balance_timeout, balance_queues, 0); + init_timer(&sched_timer); + set_timer(&sched_timer, balance_timeout, balance_queues, 0); } /*===========================================================================* @@ -255,5 +255,5 @@ PRIVATE void balance_queues(struct timer *tp) } } - sched_set_timer(&sched_timer, balance_timeout, balance_queues, 0); + set_timer(&sched_timer, balance_timeout, balance_queues, 0); } diff --git a/servers/sched/timers.c b/servers/sched/timers.c deleted file mode 100644 index 39efb9b0a..000000000 --- a/servers/sched/timers.c +++ /dev/null @@ -1,62 +0,0 @@ -/* SCHED watchdog timer management, based on servers/pm/timers.c. - * - * The entry points into this file are: - * sched_set_timer: reset and existing or set a new watchdog timer - * sched_expire_timers: check for expired timers and run watchdog functions - * - */ - -#include "sched.h" - -#include -#include -#include - -PRIVATE timer_t *sched_timers = NULL; -PRIVATE int sched_expiring = 0; - -/*===========================================================================* - * pm_set_timer * - *===========================================================================*/ -PUBLIC void sched_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) -{ - int r; - clock_t now, prev_time = 0, next_time; - - if ((r = getuptime(&now)) != OK) - panic("SCHED couldn't get uptime"); - - /* Set timer argument and add timer to the list. */ - tmr_arg(tp)->ta_int = arg; - prev_time = tmrs_settimer(&sched_timers,tp,now+ticks,watchdog,&next_time); - - /* Reschedule our synchronous alarm if necessary. */ - if (sched_expiring == 0 && (! prev_time || prev_time > next_time)) { - if (sys_setalarm(next_time, 1) != OK) - panic("SCHED set timer couldn't set alarm"); - } - - return; -} - -/*===========================================================================* - * sched_expire_timers * - *===========================================================================*/ -PUBLIC void sched_expire_timers(clock_t now) -{ - clock_t next_time; - - /* Check for expired timers. Use a global variable to indicate that - * watchdog functions are called, so that sys_setalarm() isn't called - * more often than necessary when sched_set_timer is - * called from these watchdog functions. */ - sched_expiring = 1; - tmrs_exptimers(&sched_timers, now, &next_time); - sched_expiring = 0; - - /* Reschedule an alarm if necessary. */ - if (next_time > 0) { - if (sys_setalarm(next_time, 1) != OK) - panic("SCHED expire timer couldn't set alarm"); - } -} diff --git a/servers/vfs/Makefile b/servers/vfs/Makefile index 3c0ed1375..ae1806016 100644 --- a/servers/vfs/Makefile +++ b/servers/vfs/Makefile @@ -3,7 +3,7 @@ PROG= vfs SRCS= main.c open.c read.c write.c pipe.c dmap.c \ path.c device.c mount.c link.c exec.c \ filedes.c stadir.c protect.c time.c \ - lock.c misc.c utility.c select.c timers.c table.c \ + lock.c misc.c utility.c select.c table.c \ vnode.c vmnt.c request.c fscall.c DPADD+= ${LIBSYS} ${LIBTIMERS} diff --git a/servers/vfs/fs.h b/servers/vfs/fs.h index 62a7cb744..7ac097f24 100644 --- a/servers/vfs/fs.h +++ b/servers/vfs/fs.h @@ -34,6 +34,7 @@ #include #include +#include #include "const.h" #include "dmap.h" diff --git a/servers/vfs/main.c b/servers/vfs/main.c index d4be05cb2..974f16af1 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -111,7 +111,7 @@ PUBLIC int main(void) /* Alarm timer expired. Used only for select(). * Check it. */ - fs_expire_timers(m_in.NOTIFY_TIMESTAMP); + expire_timers(m_in.NOTIFY_TIMESTAMP); } else if(who_e == DS_PROC_NR) { diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 2d799972d..0a107e4c9 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -265,12 +265,3 @@ _PROTOTYPE( void select_timeout_check, (timer_t *) ); _PROTOTYPE( void init_select, (void) ); _PROTOTYPE( void select_unsuspend_by_endpt, (endpoint_t proc) ); _PROTOTYPE( int select_notified, (int major, int minor, int ops) ); - -/* timers.c */ -_PROTOTYPE( void fs_set_timer, (timer_t *tp, int delta, - tmr_func_t watchdog, int arg) ); -_PROTOTYPE( void fs_expire_timers, (clock_t now) ); -_PROTOTYPE( void fs_cancel_timer, (timer_t *tp) ); -_PROTOTYPE( void fs_init_timer, (timer_t *tp) ); - - diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 3dcf25497..8e1badc67 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -235,7 +235,7 @@ PUBLIC int do_select(void) ticks = timeout.tv_sec * system_hz + (timeout.tv_usec * system_hz + USECPERSEC-1) / USECPERSEC; se->expiry = ticks; - fs_set_timer(&se->timer, ticks, select_timeout_check, s); + set_timer(&se->timer, ticks, select_timeout_check, s); } /* if we're blocking, the table entry is now valid. */ @@ -456,7 +456,7 @@ PRIVATE void select_cancel_all(struct selectentry *e) #if DEBUG_SELECT printf("cancelling timer %d\n", e - selecttab); #endif - fs_cancel_timer(&e->timer); + cancel_timer(&e->timer); e->expiry = 0; } @@ -612,7 +612,7 @@ PUBLIC void init_select(void) int s; for(s = 0; s < MAXSELECTS; s++) - fs_init_timer(&selecttab[s].timer); + init_timer(&selecttab[s].timer); } diff --git a/servers/vfs/timers.c b/servers/vfs/timers.c deleted file mode 100644 index c191a790a..000000000 --- a/servers/vfs/timers.c +++ /dev/null @@ -1,61 +0,0 @@ -/* FS timers library - */ - -#include "fs.h" -#include -#include -#include - -PRIVATE timer_t *fs_timers = NULL; - -PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg) -{ - int r; - clock_t now, old_head = 0, new_head; - - if ((r = getuptime(&now)) != OK) - panic("FS couldn't get uptime from system task"); - - tmr_arg(tp)->ta_int = arg; - - old_head = tmrs_settimer(&fs_timers, tp, now+ticks, watchdog, &new_head); - - /* reschedule our synchronous alarm if necessary */ - if (!old_head || old_head > new_head) { - if (sys_setalarm(new_head, 1) != OK) - panic("FS set timer couldn't set synchronous alarm"); - } - - return; -} - -PUBLIC void fs_expire_timers(clock_t now) -{ - clock_t new_head; - tmrs_exptimers(&fs_timers, now, &new_head); - if (new_head > 0) { - if (sys_setalarm(new_head, 1) != OK) - panic("FS expire timer couldn't set synchronous alarm"); - } -} - -PUBLIC void fs_init_timer(timer_t *tp) -{ - tmr_inittimer(tp); -} - -PUBLIC void fs_cancel_timer(timer_t *tp) -{ - clock_t new_head, old_head; - old_head = tmrs_clrtimer(&fs_timers, tp, &new_head); - - /* if the earliest timer has been removed, we have to set - * the synalarm to the next timer, or cancel the synalarm - * altogether if th last time has been cancelled (new_head - * will be 0 then). - */ - if (old_head < new_head || !new_head) { - if (sys_setalarm(new_head, 1) != OK) - panic("FS expire timer couldn't set synchronous alarm"); - } -}