进程调度API之finish_wait
来源:互联网 发布:淘宝功能介绍百度百科 编辑:程序博客网 时间:2024/05/18 06:32
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)用于结束wait queue 之后的清理工作,首先将当前函数的状态设置为TASK_RUNNING,如果第二个形参wait->task_list 不为null的话,则将wait->task_list 做置null,并重新对wait->task_list进行初始化其用法之前已经博文展示过了其源码分析如下:void finish_wait(wait_queue_head_t *q, wait_queue_t *wait){unsigned long flags;//将当前进程的状态设置为TASK_RUNNING__set_current_state(TASK_RUNNING);/* * We can check for list emptiness outside the lock * IFF: * - we use the "careful" check that verifies both * the next and prev pointers, so that there cannot * be any half-pending updates in progress on other * CPU's that we haven't seen yet (and that might * still change the stack area. * and * - all other users take the lock (ie we can only * have _one_ other CPU that looks at or modifies * the list). *///wait->task_list 不为null的话,则调用list_del_init删除这个list上的entry,并重新初始化if (!list_empty_careful(&wait->task_list)) {spin_lock_irqsave(&q->lock, flags);list_del_init(&wait->task_list);spin_unlock_irqrestore(&q->lock, flags);}}这里用list_empty_careful 来判断list是否为null。这个函数和list_empty相比检测更严格一点,个人感觉list_empty 适用用单向链表和list_empty_careful 适用于双向链表static inline int list_empty(const struct list_head *head){return READ_ONCE(head->next) == head;}通过code 对比很容易看出区别.static inline int list_empty_careful(const struct list_head *head){struct list_head *next = head->next;return (next == head) && (next == head->prev);}
阅读全文
0 0
- 进程调度API之finish_wait
- 进程调度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之init_waitqueue_entry
- 进程调度API之init_waitqueue_head
- 进程调度API之prepare_to_wait
- 进程调度API之set_cpus_allowed_ptr
- 进程调度API之set_user_nice
- 进程调度API之sleep_on_spinunlock
- 数据结构基本概念
- opencv_tutorial_code学习——opencv decolor效果
- 炼数成金NoSQL与NewSQL数据库引航
- 23种设计模式(17)-命令模式
- 弹性扩展的宽屏液晶KVM切换器
- 进程调度API之finish_wait
- 打砖块
- 一组数据中只有一个数字出现了一次。其他所有数字都是成对出现的。找出这个数字。(使用位运算)
- 《重构——改善既有代码的设计》【PDF】下载
- 在集成开发环境中使用Kotlin
- 2018 年值得尝试的 11 个 React 组件库
- Window 'ls' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
- 史上最强屏幕适配方案,傻瓜式集成,一步到位---不服来辩!
- ES6/核心内容(上)