分类: LINUX
2013-08-29 21:29:33
v2.6.24
-----------------linux\kernel\cpu.c-----------------
//通知块结构
struct notifier_block {
int (*notifier_call)(struct notifier_block *, unsigned long, void *); //该通知块执行的函数
struct notifier_block *next; //指向链表中下一个通知块的指针
int priority; //优先级
};
//通知块链表的定义
static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain);
//注册一个通知块nb到链表cpu_chain中
int __cpuinit register_cpu_notifier(struct notifier_block *nb)
{
int ret;
mutex_lock(&cpu_add_remove_lock);
ret = raw_notifier_chain_register(&cpu_chain, nb);
mutex_unlock(&cpu_add_remove_lock);
return ret;
}
//注销通知块的注册
void unregister_cpu_notifier(struct notifier_block *nb)
{
mutex_lock(&cpu_add_remove_lock);
raw_notifier_chain_unregister(&cpu_chain, nb);
mutex_unlock(&cpu_add_remove_lock);
}
//通知链中通知块函数的执行:调用路径
start_kernel->rest_init->kernel_init->smp_init->cpu_up->_cpu_up->raw_notifier_call_chain