6 #include <minix/syslib.h>
9 PRIVATE timer_t
*fs_timers
= NULL
;
11 PUBLIC
void fs_set_timer(timer_t
*tp
, int ticks
, tmr_func_t watchdog
, int arg
)
14 clock_t now
, old_head
= 0, new_head
;
16 if ((r
= getuptime(&now
)) != OK
)
17 panic("FS couldn't get uptime from system task");
19 tmr_arg(tp
)->ta_int
= arg
;
21 old_head
= tmrs_settimer(&fs_timers
, tp
, now
+ticks
, watchdog
, &new_head
);
23 /* reschedule our synchronous alarm if necessary */
24 if (!old_head
|| old_head
> new_head
) {
25 if (sys_setalarm(new_head
, 1) != OK
)
26 panic("FS set timer couldn't set synchronous alarm");
32 PUBLIC
void fs_expire_timers(clock_t now
)
35 tmrs_exptimers(&fs_timers
, now
, &new_head
);
37 if (sys_setalarm(new_head
, 1) != OK
)
38 panic("FS expire timer couldn't set synchronous alarm");
42 PUBLIC
void fs_init_timer(timer_t
*tp
)
47 PUBLIC
void fs_cancel_timer(timer_t
*tp
)
49 clock_t new_head
, old_head
;
50 old_head
= tmrs_clrtimer(&fs_timers
, tp
, &new_head
);
52 /* if the earliest timer has been removed, we have to set
53 * the synalarm to the next timer, or cancel the synalarm
54 * altogether if th last time has been cancelled (new_head
57 if (old_head
< new_head
|| !new_head
) {
58 if (sys_setalarm(new_head
, 1) != OK
)
59 panic("FS expire timer couldn't set synchronous alarm");