linux notification内核通知链

/******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代
 *   表不同的结束意义。
 */
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值