本文主要是介绍tick_init();,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*** tick_init - initialize the tick control** Register the notifier with the clockevents framework*/
void __init tick_init(void)
{clockevents_register_notifier(&tick_notifier);//这里用到了通知链技术,可以参考博文“内核通知链机制的原理及实现”
}static struct notifier_block tick_notifier = {.notifier_call = tick_notify,
};/*** clockevents_register_notifier - register a clock events change listener*/
int clockevents_register_notifier(struct notifier_block *nb)
{unsigned long flags;int ret;raw_spin_lock_irqsave(&clockevents_lock, flags); //get the spin lock ret = raw_notifier_chain_register(&clockevents_chain, nb); //registerraw_spin_unlock_irqrestore(&clockevents_lock, flags); //unlockreturn ret;
}/** Raw notifier chain routines. There is no protection;* the caller must provide it. Use at your own risk!*//*** raw_notifier_chain_register - Add notifier to a raw notifier chain* @nh: Pointer to head of the raw notifier chain* @n: New entry in notifier chain** Adds a notifier to a raw notifier chain.* All locking must be provided by the caller.** Currently always returns zero.*/
int raw_notifier_chain_register(struct raw_notifier_head *nh,struct notifier_block *n)
{return notifier_chain_register(&nh->head, n);
}
可以看到,tick_init的作用就是调用 clockevents_register_notifier 函数向 clockevents_chain 通知链注册元素: tick_notifier。这个元素的回调函数指明了当时钟事件设备信息发生
变化(例如新加入一个时钟事件设备等等)时,应该执行的操作,该回调函数为 tick_notify。
这篇关于tick_init();的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!