minix/servers/vfs/timers.c
Ben Gras 35a108b911 panic() cleanup.
this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
2010-03-05 15:05:11 +00:00

62 lines
1.4 KiB
C

/* FS timers library
*/
#include "fs.h"
#include <timers.h>
#include <minix/syslib.h>
#include <minix/com.h>
PRIVATE timer_t *fs_timers = NULL;
PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
int r;
clock_t now, old_head = 0, new_head;
if ((r = getuptime(&now)) != OK)
panic("FS couldn't get uptime from system task");
tmr_arg(tp)->ta_int = arg;
old_head = tmrs_settimer(&fs_timers, tp, now+ticks, watchdog, &new_head);
/* reschedule our synchronous alarm if necessary */
if (!old_head || old_head > new_head) {
if (sys_setalarm(new_head, 1) != OK)
panic("FS set timer couldn't set synchronous alarm");
}
return;
}
PUBLIC void fs_expire_timers(clock_t now)
{
clock_t new_head;
tmrs_exptimers(&fs_timers, now, &new_head);
if (new_head > 0) {
if (sys_setalarm(new_head, 1) != OK)
panic("FS expire timer couldn't set synchronous alarm");
}
}
PUBLIC void fs_init_timer(timer_t *tp)
{
tmr_inittimer(tp);
}
PUBLIC void fs_cancel_timer(timer_t *tp)
{
clock_t new_head, old_head;
old_head = tmrs_clrtimer(&fs_timers, tp, &new_head);
/* if the earliest timer has been removed, we have to set
* the synalarm to the next timer, or cancel the synalarm
* altogether if th last time has been cancelled (new_head
* will be 0 then).
*/
if (old_head < new_head || !new_head) {
if (sys_setalarm(new_head, 1) != OK)
panic("FS expire timer couldn't set synchronous alarm");
}
}