1.struct hrtimer:高精度定时器
struct hrtimer {
struct timerqueue_node node;
ktime_t _softexpires;
enum hrtimer_restart (*function)(struct hrtimer *);
struct hrtimer_clock_base *base;
unsigned long state;
#ifdef CONFIG_TIMER_STATS
int start_pid;
void *start_site;
char start_comm[16];
#endif
};
<1>参考链接:Linux hrtimer分析(一):http://blog.csdn.net/walkingman321/article/details/6133171
2.struct hrtimer_cpu_base:单个CPU的高精度时钟
struct hrtimer_cpu_base {
raw_spinlock_t lock; /*自旋锁*/
unsigned int active_bases;
unsigned int clock_was_set;
#ifdef CONFIG_HIGH_RES_TIMERS
ktime_t expires_next;
int hres_active;
int hang_detected;
unsigned long nr_events;
unsigned long nr_retries;
unsigned long nr_hangs;
ktime_t max_hang_time;
#endif
struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; /*时钟源*/
};
3. struct hrtimer_clock_base:时钟源
struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; int index; /*时钟源类型:CLOCK_REALTIME和CLOCK_MONOTONIC
*/clockid_t clockid; /*时钟编号*/struct timerqueue_head active; /*激活的高精度时钟红黑树*/ktime_t resolution; /*时钟的精度,ns单位*/ktime_t (*get_time)(void); /*获取当前时钟时间的函数指针*/ktime_t softirq_time; /*在软中断中运行时钟的时刻*/ktime_t offset; /*相对于monotonic 时钟基准的偏移量*/};CLOCK_REALTIME:用户更改系统时间,会受到影响 CLOCK_MONOTONIC:用户更改系统时间,不会受到影响