进程调度API之preempt_notifier_register/preempt_notifier_unregister
来源:互联网 发布:淘宝下架软件 编辑:程序博客网 时间:2024/06/05 17:41
void preempt_notifier_register(struct preempt_notifier *notifier)用于简单thread是否被抢占或者重新调度形参preempt_notifier的定义如下:struct preempt_notifier {struct hlist_node link;struct preempt_ops *ops;};其中struct preempt_ops {void (*sched_in)(struct preempt_notifier *notifier, int cpu);void (*sched_out)(struct preempt_notifier *notifier, struct task_struct *next);};可以看到这个函数可以分别检测thread被sched_in和sched_out的时间点,这样应该就可以计算函数被执行的时间其源码分析如下:void preempt_notifier_register(struct preempt_notifier *notifier){if (!static_key_false(&preempt_notifier_key))WARN(1, "registering preempt_notifier while notifiers disabled\n");hlist_add_head(¬ifier->link, ¤t->preempt_notifiers);}可以看到首先要notifier enable,也即是preempt_notifier_key 为true。然后调用hlist_add_head将形参的notifier添加到当前进程的preempt_notifiers 中,这样当前进程被sched_in和sched_out的时候就会分别调用preempt_ops 中的sched_in和sched_out函数.与preempt_notifier_register 对应的是preempt_notifier_unregister。其源码如下:void preempt_notifier_unregister(struct preempt_notifier *notifier){hlist_del(¬ifier->link);}仅仅是调用hlist_del 删除notifier->link,并没有修改current->preempt_notifiers。所以preempt_notifier_register 只能在当前thread中调用,而preempt_notifier_unregister 可以在任何thread中调用.
阅读全文
0 0
- 进程调度API之preempt_notifier_register/preempt_notifier_unregister
- 进程调度API之__wake_up
- 进程调度API之__wake_up_sync
- 进程调度API之preempt_count_dec_and_test
- 进程调度API之should_resched
- 进程调度API之preempt_schedule
- 进程调度API之add_wait_queue_exclusive
- 进程调度API之autoremove_wake_function
- 进程调度API之complete
- 进程调度API之complete_all
- 进程调度API之completion_done
- 进程调度API之wait_for_completion_x
- 进程调度API之finish_wait
- 进程调度API之init_waitqueue_entry
- 进程调度API之init_waitqueue_head
- 进程调度API之prepare_to_wait
- 进程调度API之set_cpus_allowed_ptr
- 进程调度API之set_user_nice
- iOS最新型号设备信息对照表
- tnc-fhh开源代码之IMCV测试
- mysql 存储 emoji报错的解决方案
- Android 如何在onCreate中拿到View的宽度和高度
- Logback新版本报no applicable action for [Encoding]问题
- 进程调度API之preempt_notifier_register/preempt_notifier_unregister
- effective C++ 12_复制对象时勿忘其每一个成分 读书笔记
- NOIP 2017 Day2 题2:宝藏 状态压缩
- 75. Sort Colors
- 机器学习笔记(XII)决策树(II)剪枝处理
- 关于html5中的部分标签,在IE9以下的支持情况
- nova 中的taskflow的实现
- ElasticSearch的reIndex
- Gobblin data quality checker