linux notification内核通知链
2016-03-25 17:34
513 查看
/******linux notification内核通知链***********/
linux/notifier.h //内核中的一处来告知内核另一处某事件的发生,并执行注册的
struct notifier_block { //notifier_call方法。
int (*notifier_call)(struct notifier_block *self,unsigned long,void*);
struct notifier_block *next;
int priority;
};//notifier_call必须注册,大priority优先执行。
struct blocking_notifier_head {
struct rw_semaphore rwsem;
struct notifier_block *head;
}
struct atomic_notifier_head {
spinlock_t lock;
struct notifier_block *head;
}
BLOCKING_NOTIFIER_HEAD(name); (1)
//两种方法阻塞型初始化通知链头
struct blocking_notifier_head name; //用于可以阻塞的环境
BLOCKING_INIT_NOTIFIER_HEAD(name); (2)
int blocking_notifier_chain_register(struct blocking_notifier_head *chain,
struct notifier_block *nf);//注册一个通知到通知链上去
int blocking_notifier_chain_unregister(struct blocking_notifier_head *chain,
struct notifier_block *fn);
int blocking_notifier_call_chain(struct blocking_notifier_head *chain,
unsigned long event,void* data);//轮循每个通知,并执行其中的函数
ATOMIC_NOTIFIER_HEAD(name); (1) //原子型,同上
struct atomic_notifier_head name; //用于原子型环境,比如中断
ATOMIC_INIT_NOTIFIER_HEAD(name); (2)
int atomic_notifier_chain_register(struct atomic_notifier_head *chain,
struct notifier_block *nf);
int atomic_notifier_chain_unregister(struct atomic_notifier_head *chain,
struct notifier_block *nf);
int atomic_notifier_call_chain(struct blocking_notifier_head *chain,
unsigned long event,void* data)
/* notifier_call有几个常用可选的返回值:NOTIFY_OK,NOTIFY_STOP,NOTIFY_BAD代
* 表不同的结束意义。
*/
linux/notifier.h //内核中的一处来告知内核另一处某事件的发生,并执行注册的
struct notifier_block { //notifier_call方法。
int (*notifier_call)(struct notifier_block *self,unsigned long,void*);
struct notifier_block *next;
int priority;
};//notifier_call必须注册,大priority优先执行。
struct blocking_notifier_head {
struct rw_semaphore rwsem;
struct notifier_block *head;
}
struct atomic_notifier_head {
spinlock_t lock;
struct notifier_block *head;
}
BLOCKING_NOTIFIER_HEAD(name); (1)
//两种方法阻塞型初始化通知链头
struct blocking_notifier_head name; //用于可以阻塞的环境
BLOCKING_INIT_NOTIFIER_HEAD(name); (2)
int blocking_notifier_chain_register(struct blocking_notifier_head *chain,
struct notifier_block *nf);//注册一个通知到通知链上去
int blocking_notifier_chain_unregister(struct blocking_notifier_head *chain,
struct notifier_block *fn);
int blocking_notifier_call_chain(struct blocking_notifier_head *chain,
unsigned long event,void* data);//轮循每个通知,并执行其中的函数
ATOMIC_NOTIFIER_HEAD(name); (1) //原子型,同上
struct atomic_notifier_head name; //用于原子型环境,比如中断
ATOMIC_INIT_NOTIFIER_HEAD(name); (2)
int atomic_notifier_chain_register(struct atomic_notifier_head *chain,
struct notifier_block *nf);
int atomic_notifier_chain_unregister(struct atomic_notifier_head *chain,
struct notifier_block *nf);
int atomic_notifier_call_chain(struct blocking_notifier_head *chain,
unsigned long event,void* data)
/* notifier_call有几个常用可选的返回值:NOTIFY_OK,NOTIFY_STOP,NOTIFY_BAD代
* 表不同的结束意义。
*/
相关文章推荐
- Linux 内核源代码情景分析 chap 1 预备知识
- 排障思路--------杀毒
- linux下Android环境的搭建
- 16. Linux 文件目录权限
- centos7下快速安装mysql-yum安装
- Linux环境下,更新代码补丁后,重启服务器常用命令
- centos安装gradle,极简
- vim 在linux下中如何设置显示行数
- linux 之PATH、LD_LIBRARY_PATH及编译指定头文件、动态库
- 4. Linux 系统目录
- Salt官方将RHEL5/CentOS5 源
- 1. 用U盘安装Centos6.5 + Win7 双系统
- linux tasklet和workqueue的应用情景
- Linux内存管理之综合篇
- Linux中断研究
- Linux vi/vim 多行注释
- Linux驱动中completion接口浅析(wait_for_complete例子,很好)
- linux上连接的数据库命令,及解锁表
- Linux C Socket编程原理及简单实例
- Centos7 Cacti-0.8.8g安装及SNMP简介