The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/servers/fs/timers.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* FS timers library
    2  */
    3 
    4 #include "fs.h"
    5 
    6 #include <timers.h>
    7 #include <minix/syslib.h>
    8 #include <minix/com.h>
    9 
   10 PRIVATE timer_t *fs_timers = NULL;
   11 
   12 PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
   13 {
   14         int r;
   15         clock_t now, old_head = 0, new_head;
   16 
   17         if ((r = getuptime(&now)) != OK)
   18                 panic(__FILE__, "FS couldn't get uptime from system task.", NO_NUM);
   19 
   20         tmr_arg(tp)->ta_int = arg;
   21 
   22         old_head = tmrs_settimer(&fs_timers, tp, now+ticks, watchdog, &new_head);
   23 
   24         /* reschedule our synchronous alarm if necessary */
   25         if (!old_head || old_head > new_head) {
   26                 if (sys_setalarm(new_head, 1) != OK)
   27                         panic(__FILE__, "FS set timer "
   28                         "couldn't set synchronous alarm.", NO_NUM);
   29         }
   30 
   31         return;
   32 }
   33 
   34 PUBLIC void fs_expire_timers(clock_t now)
   35 {
   36         clock_t new_head;
   37         tmrs_exptimers(&fs_timers, now, &new_head);
   38         if (new_head > 0) {
   39                 if (sys_setalarm(new_head, 1) != OK)
   40                         panic(__FILE__, "FS expire timer couldn't set "
   41                                 "synchronous alarm.", NO_NUM);
   42         }
   43 }
   44 
   45 PUBLIC void fs_init_timer(timer_t *tp)
   46 {
   47         tmr_inittimer(tp);
   48 }
   49 
   50 PUBLIC void fs_cancel_timer(timer_t *tp)
   51 {
   52         clock_t new_head, old_head;
   53         old_head = tmrs_clrtimer(&fs_timers, tp, &new_head);
   54 
   55         /* if the earliest timer has been removed, we have to set
   56          * the synalarm to the next timer, or cancel the synalarm
   57          * altogether if th last time has been cancelled (new_head
   58          * will be 0 then).
   59          */
   60         if (old_head < new_head || !new_head) {
   61                 if (sys_setalarm(new_head, 1) != OK)
   62                         panic(__FILE__,
   63                         "FS expire timer couldn't set synchronous alarm.",
   64                                  NO_NUM);
   65         }
   66 }

Cache object: f9e2a3a7695f9f3906b627510239d3d7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.