linux内核常用数据结构和函数解释

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                                                      
                                                                  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 时钟基准的偏移量*/};




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值