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(__FILE__
, "FS couldn't get uptime from system task.", NO_NUM
);
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(__FILE__
, "FS set timer "
27 "couldn't set synchronous alarm.", NO_NUM
);
33 PUBLIC
void fs_expire_timers(clock_t now
)
36 tmrs_exptimers(&fs_timers
, now
, &new_head
);
38 if (sys_setalarm(new_head
, 1) != OK
)
39 panic(__FILE__
, "FS expire timer couldn't set "
40 "synchronous alarm.", NO_NUM
);
44 PUBLIC
void fs_init_timer(timer_t
*tp
)
49 PUBLIC
void fs_cancel_timer(timer_t
*tp
)
51 clock_t new_head
, old_head
;
52 old_head
= tmrs_clrtimer(&fs_timers
, tp
, &new_head
);
54 /* if the earliest timer has been removed, we have to set
55 * the synalarm to the next timer, or cancel the synalarm
56 * altogether if th last time has been cancelled (new_head
59 if (old_head
< new_head
|| !new_head
) {
60 if (sys_setalarm(new_head
, 1) != OK
)
62 "FS expire timer couldn't set synchronous alarm.",