add swifi to the build/install.
[minix.git] / servers / vfs / timers.c
blobd1f94f0c00eb9fafec60c8638c8f2c1d529cc50d
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(__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);
30 return;
33 PUBLIC void fs_expire_timers(clock_t now)
35 clock_t new_head;
36 tmrs_exptimers(&fs_timers, now, &new_head);
37 if (new_head > 0) {
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)
46 tmr_inittimer(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
57 * will be 0 then).
59 if (old_head < new_head || !new_head) {
60 if (sys_setalarm(new_head, 1) != OK)
61 panic(__FILE__,
62 "FS expire timer couldn't set synchronous alarm.",
63 NO_NUM);