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  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
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.