]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/linux/hrtimer.h
2 * include/linux/hrtimer.h
4 * hrtimers - High-resolution kernel timers
6 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
7 * Copyright(C) 2005, Red Hat, Inc., Ingo Molnar
9 * data type definitions, declarations, prototypes
11 * Started by: Thomas Gleixner and Ingo Molnar
13 * For licencing details see kernel-base/COPYING
15 #ifndef _LINUX_HRTIMER_H
16 #define _LINUX_HRTIMER_H
18 #include <linux/rbtree.h>
19 #include <linux/ktime.h>
20 #include <linux/init.h>
21 #include <linux/list.h>
22 #include <linux/wait.h>
25 * Mode arguments of xxx_hrtimer functions:
28 HRTIMER_ABS
, /* Time value is absolute */
29 HRTIMER_REL
, /* Time value is relative to now */
32 enum hrtimer_restart
{
41 HRTIMER_INACTIVE
, /* Timer is inactive */
42 HRTIMER_EXPIRED
, /* Timer is expired */
43 HRTIMER_PENDING
, /* Timer is pending */
49 * struct hrtimer - the basic hrtimer structure
51 * @node: red black tree node for time ordered insertion
52 * @list: list head for easier access to the time ordered list,
53 * without walking the red black tree.
54 * @expires: the absolute expiry time in the hrtimers internal
55 * representation. The time is related to the clock on
56 * which the timer is based.
57 * @state: state of the timer
58 * @function: timer expiry callback function
59 * @data: argument for the callback function
60 * @base: pointer to the timer base (per cpu and per clock)
62 * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE()
66 struct list_head list
;
68 enum hrtimer_state state
;
69 int (*function
)(void *);
71 struct hrtimer_base
*base
;
75 * struct hrtimer_base - the timer base for a specific clock
77 * @index: clock type index for per_cpu support when moving a timer
78 * to a base on another cpu.
79 * @lock: lock protecting the base and associated timers
80 * @active: red black tree root node for the active timers
81 * @pending: list of pending timers for simple time ordered access
82 * @resolution: the resolution of the clock, in nanoseconds
83 * @get_time: function to retrieve the current time of the clock
84 * @curr_timer: the timer which is executing a callback right now
89 struct rb_root active
;
90 struct list_head pending
;
91 unsigned long resolution
;
92 ktime_t (*get_time
)(void);
93 struct hrtimer
*curr_timer
;
96 /* Exported timer functions: */
98 /* Initialize timers: */
99 extern void hrtimer_init(struct hrtimer
*timer
, const clockid_t which_clock
);
100 extern void hrtimer_rebase(struct hrtimer
*timer
, const clockid_t which_clock
);
103 /* Basic timer operations: */
104 extern int hrtimer_start(struct hrtimer
*timer
, ktime_t tim
,
105 const enum hrtimer_mode mode
);
106 extern int hrtimer_cancel(struct hrtimer
*timer
);
107 extern int hrtimer_try_to_cancel(struct hrtimer
*timer
);
109 #define hrtimer_restart(timer) hrtimer_start((timer), (timer)->expires, HRTIMER_ABS)
112 extern ktime_t
hrtimer_get_remaining(const struct hrtimer
*timer
);
113 extern int hrtimer_get_res(const clockid_t which_clock
, struct timespec
*tp
);
115 static inline int hrtimer_active(const struct hrtimer
*timer
)
117 return timer
->state
== HRTIMER_PENDING
;
120 /* Forward a hrtimer so it expires after now: */
121 extern unsigned long hrtimer_forward(struct hrtimer
*timer
,
122 const ktime_t interval
);
124 /* Soft interrupt function to run the hrtimer queues: */
125 extern void hrtimer_run_queues(void);
127 /* Bootup initialization: */
128 extern void __init
hrtimers_init(void);