您的位置:首页 > 理论基础 > 数据结构算法

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

2013-12-24 22:51 190 查看
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分析(一):/article/7833624.html

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


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: