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/sys/timeout.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 /*      $OpenBSD: timeout.h,v 1.47 2022/12/31 16:06:24 cheloha Exp $    */
    2 /*
    3  * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
    4  * All rights reserved. 
    5  *
    6  * Redistribution and use in source and binary forms, with or without 
    7  * modification, are permitted provided that the following conditions 
    8  * are met: 
    9  *
   10  * 1. Redistributions of source code must retain the above copyright 
   11  *    notice, this list of conditions and the following disclaimer. 
   12  * 2. The name of the author may not be used to endorse or promote products
   13  *    derived from this software without specific prior written permission. 
   14  *
   15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
   16  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
   17  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
   18  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   19  * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
   21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
   25  */
   26 
   27 #ifndef _SYS_TIMEOUT_H_
   28 #define _SYS_TIMEOUT_H_
   29 
   30 #include <sys/time.h>
   31 
   32 struct circq {
   33         struct circq *next;             /* next element */
   34         struct circq *prev;             /* previous element */
   35 };
   36 
   37 struct timeout {
   38         struct circq to_list;                   /* timeout queue, don't move */
   39         struct timespec to_abstime;             /* absolute time to run at */
   40         void (*to_func)(void *);                /* function to call */
   41         void *to_arg;                           /* function argument */
   42 #if 1 /* NKCOV > 0 */
   43         struct process *to_process;             /* kcov identifier */
   44 #endif
   45         int to_time;                            /* ticks on event */
   46         int to_flags;                           /* misc flags */
   47         int to_kclock;                          /* abstime's kernel clock */
   48 };
   49 
   50 /*
   51  * flags in the to_flags field.
   52  */
   53 #define TIMEOUT_PROC            0x01    /* needs a process context */
   54 #define TIMEOUT_ONQUEUE         0x02    /* on any timeout queue */
   55 #define TIMEOUT_INITIALIZED     0x04    /* initialized */
   56 #define TIMEOUT_TRIGGERED       0x08    /* running or ran */
   57 
   58 struct timeoutstat {
   59         uint64_t tos_added;             /* timeout_add*(9) calls */
   60         uint64_t tos_cancelled;         /* dequeued during timeout_del*(9) */
   61         uint64_t tos_deleted;           /* timeout_del*(9) calls */
   62         uint64_t tos_late;              /* run after deadline */
   63         uint64_t tos_pending;           /* number currently ONQUEUE */
   64         uint64_t tos_readded;           /* timeout_add*(9) + already ONQUEUE */
   65         uint64_t tos_rescheduled;       /* bucketed + already SCHEDULED */
   66         uint64_t tos_run_softclock;     /* run from softclock() */
   67         uint64_t tos_run_thread;        /* run from softclock_thread() */
   68         uint64_t tos_scheduled;         /* bucketed during softclock() */
   69         uint64_t tos_softclocks;        /* softclock() calls */
   70         uint64_t tos_thread_wakeups;    /* wakeups in softclock_thread() */
   71 };
   72 
   73 #ifdef _KERNEL
   74 int timeout_sysctl(void *, size_t *, void *, size_t);
   75 
   76 /*
   77  * special macros
   78  *
   79  * timeout_pending(to) - is this timeout already scheduled to run?
   80  * timeout_initialized(to) - is this timeout initialized?
   81  */
   82 #define timeout_pending(to) ((to)->to_flags & TIMEOUT_ONQUEUE)
   83 #define timeout_initialized(to) ((to)->to_flags & TIMEOUT_INITIALIZED)
   84 #define timeout_triggered(to) ((to)->to_flags & TIMEOUT_TRIGGERED)
   85 
   86 #define KCLOCK_NONE     (-1)            /* dummy clock for sanity checks */
   87 #define KCLOCK_UPTIME   0               /* uptime clock; time since boot */
   88 #define KCLOCK_MAX      1
   89 
   90 #define TIMEOUT_INITIALIZER_FLAGS(_fn, _arg, _kclock, _flags) {         \
   91         .to_list = { NULL, NULL },                                      \
   92         .to_abstime = { .tv_sec = 0, .tv_nsec = 0 },                    \
   93         .to_func = (_fn),                                               \
   94         .to_arg = (_arg),                                               \
   95         .to_time = 0,                                                   \
   96         .to_flags = (_flags) | TIMEOUT_INITIALIZED,                     \
   97         .to_kclock = (_kclock)                                          \
   98 }
   99 
  100 #define TIMEOUT_INITIALIZER(_f, _a)                                     \
  101     TIMEOUT_INITIALIZER_FLAGS((_f), (_a), KCLOCK_NONE, 0)
  102 
  103 void timeout_set(struct timeout *, void (*)(void *), void *);
  104 void timeout_set_flags(struct timeout *, void (*)(void *), void *, int, int);
  105 void timeout_set_proc(struct timeout *, void (*)(void *), void *);
  106 
  107 int timeout_add(struct timeout *, int);
  108 int timeout_add_tv(struct timeout *, const struct timeval *);
  109 int timeout_add_sec(struct timeout *, int);
  110 int timeout_add_msec(struct timeout *, int);
  111 int timeout_add_usec(struct timeout *, int);
  112 int timeout_add_nsec(struct timeout *, int);
  113 
  114 int timeout_abs_ts(struct timeout *, const struct timespec *);
  115 
  116 int timeout_del(struct timeout *);
  117 int timeout_del_barrier(struct timeout *);
  118 void timeout_barrier(struct timeout *);
  119 
  120 void timeout_adjust_ticks(int);
  121 void timeout_hardclock_update(void);
  122 void timeout_startup(void);
  123 
  124 #endif /* _KERNEL */
  125 
  126 #endif  /* _SYS_TIMEOUT_H_ */

Cache object: e7dd23c3341eaec17cfcda0d8f493f73


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