00001
00002
00003
00004 #include "fs.h"
00005
00006 #include <timers.h>
00007 #include <minix/syslib.h>
00008 #include <minix/com.h>
00009
00010 PRIVATE timer_t *fs_timers = NULL;
00011
00012 PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
00013 {
00014 int r;
00015 clock_t now, old_head = 0, new_head;
00016
00017 if ((r = getuptime(&now)) != OK)
00018 panic(__FILE__, "FS couldn't get uptime from system task.", NO_NUM);
00019
00020 tmr_arg(tp)->ta_int = arg;
00021
00022 old_head = tmrs_settimer(&fs_timers, tp, now+ticks, watchdog, &new_head);
00023
00024
00025 if (!old_head || old_head > new_head) {
00026 if (sys_setalarm(new_head, 1) != OK)
00027 panic(__FILE__, "FS set timer "
00028 "couldn't set synchronous alarm.", NO_NUM);
00029 }
00030
00031 return;
00032 }
00033
00034 PUBLIC void fs_expire_timers(clock_t now)
00035 {
00036 clock_t new_head;
00037 tmrs_exptimers(&fs_timers, now, &new_head);
00038 if (new_head > 0) {
00039 if (sys_setalarm(new_head, 1) != OK)
00040 panic(__FILE__, "FS expire timer couldn't set "
00041 "synchronous alarm.", NO_NUM);
00042 }
00043 }
00044
00045 PUBLIC void fs_init_timer(timer_t *tp)
00046 {
00047 tmr_inittimer(tp);
00048 }
00049
00050 PUBLIC void fs_cancel_timer(timer_t *tp)
00051 {
00052 clock_t new_head, old_head;
00053 old_head = tmrs_clrtimer(&fs_timers, tp, &new_head);
00054
00055
00056
00057
00058
00059
00060 if (old_head < new_head || !new_head) {
00061 if (sys_setalarm(new_head, 1) != OK)
00062 panic(__FILE__,
00063 "FS expire timer couldn't set synchronous alarm.",
00064 NO_NUM);
00065 }
00066 }