7 #include <minix/syslib.h>
10 PRIVATE timer_t
*fs_timers
= NULL
;
12 PUBLIC
void fs_set_timer(timer_t
*tp
, int ticks
, tmr_func_t watchdog
, int arg
)
15 clock_t now
, old_head
= 0, new_head
;
17 if ((r
= getuptime(&now
)) != OK
)
18 panic(__FILE__
, "FS couldn't get uptime from system task.", NO_NUM
);
20 tmr_arg(tp
)->ta_int
= arg
;
22 old_head
= tmrs_settimer(&fs_timers
, tp
, now
+ticks
, watchdog
, &new_head
);
24 /* reschedule our synchronous alarm if necessary */
25 if (!old_head
|| old_head
> new_head
) {
26 if (sys_setalarm(new_head
, 1) != OK
)
27 panic(__FILE__
, "FS set timer "
28 "couldn't set synchronous alarm.", NO_NUM
);
34 PUBLIC
void fs_expire_timers(clock_t now
)
37 tmrs_exptimers(&fs_timers
, now
, &new_head
);
39 if (sys_setalarm(new_head
, 1) != OK
)
40 panic(__FILE__
, "FS expire timer couldn't set "
41 "synchronous alarm.", NO_NUM
);
45 PUBLIC
void fs_init_timer(timer_t
*tp
)
50 PUBLIC
void fs_cancel_timer(timer_t
*tp
)
52 clock_t new_head
, old_head
;
53 old_head
= tmrs_clrtimer(&fs_timers
, tp
, &new_head
);
55 /* if the earliest timer has been removed, we have to set
56 * the synalarm to the next timer, or cancel the synalarm
57 * altogether if th last time has been cancelled (new_head
60 if (old_head
< new_head
|| !new_head
) {
61 if (sys_setalarm(new_head
, 1) != OK
)
63 "FS expire timer couldn't set synchronous alarm.",