vm: remove leftover diag print
[minix.git] / servers / vfs / timers.c
blobc191a790aa9d08f9aeb497de1a620da7e8cd305a
1 /* FS timers library
2 */
4 #include "fs.h"
5 #include <timers.h>
6 #include <minix/syslib.h>
7 #include <minix/com.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)
13 int r;
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");
29 return;
32 PUBLIC void fs_expire_timers(clock_t now)
34 clock_t new_head;
35 tmrs_exptimers(&fs_timers, now, &new_head);
36 if (new_head > 0) {
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)
44 tmr_inittimer(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
55 * will be 0 then).
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");