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/include/timers.h

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 /* This library provides generic watchdog timer management functionality.
    2  * The functions operate on a timer queue provided by the caller. Note that
    3  * the timers must use absolute time to allow sorting. The library provides:
    4  *
    5  *    tmrs_settimer:     (re)set a new watchdog timer in the timers queue 
    6  *    tmrs_clrtimer:     remove a timer from both the timers queue 
    7  *    tmrs_exptimers:    check for expired timers and run watchdog functions
    8  *
    9  * Author:
   10  *    Jorrit N. Herder <jnherder@cs.vu.nl>
   11  *    Adapted from tmr_settimer and tmr_clrtimer in src/kernel/clock.c. 
   12  *    Last modified: September 30, 2004.
   13  */
   14 
   15 #ifndef _TIMERS_H
   16 #define _TIMERS_H
   17 
   18 #include <limits.h>
   19 #include <sys/types.h>
   20 
   21 struct timer;
   22 typedef void (*tmr_func_t)(struct timer *tp);
   23 typedef union { int ta_int; long ta_long; void *ta_ptr; } tmr_arg_t;
   24 
   25 /* A timer_t variable must be declare for each distinct timer to be used.
   26  * The timers watchdog function and expiration time are automatically set
   27  * by the library function tmrs_settimer, but its argument is not.
   28  */
   29 typedef struct timer
   30 {
   31   struct timer  *tmr_next;      /* next in a timer chain */
   32   clock_t       tmr_exp_time;   /* expiration time */
   33   tmr_func_t    tmr_func;       /* function to call when expired */
   34   tmr_arg_t     tmr_arg;        /* random argument */
   35 } timer_t;
   36 
   37 /* Used when the timer is not active. */
   38 #define TMR_NEVER    ((clock_t) -1 < 0) ? ((clock_t) LONG_MAX) : ((clock_t) -1)
   39 #undef TMR_NEVER
   40 #define TMR_NEVER       ((clock_t) LONG_MAX)
   41 
   42 /* These definitions can be used to set or get data from a timer variable. */ 
   43 #define tmr_arg(tp) (&(tp)->tmr_arg)
   44 #define tmr_exp_time(tp) (&(tp)->tmr_exp_time)
   45 
   46 /* Timers should be initialized once before they are being used. Be careful
   47  * not to reinitialize a timer that is in a list of timers, or the chain
   48  * will be broken.
   49  */
   50 #define tmr_inittimer(tp) (void)((tp)->tmr_exp_time = TMR_NEVER, \
   51         (tp)->tmr_next = NULL)
   52 
   53 /* The following generic timer management functions are available. They
   54  * can be used to operate on the lists of timers. Adding a timer to a list 
   55  * automatically takes care of removing it.
   56  */
   57 _PROTOTYPE( clock_t tmrs_clrtimer, (timer_t **tmrs, timer_t *tp, clock_t *new_head)             );
   58 _PROTOTYPE( void tmrs_exptimers, (timer_t **tmrs, clock_t now, clock_t *new_head)               );
   59 _PROTOTYPE( clock_t tmrs_settimer, (timer_t **tmrs, timer_t *tp, 
   60         clock_t exp_time, tmr_func_t watchdog, clock_t *new_head)                               );
   61 
   62 #endif /* _TIMERS_H */
   63 

Cache object: ce649e70d11543e0ebef3da076d013ce


[ 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.