linux进程状态-TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
来源:互联网 发布:什么是移动数据流量 编辑:程序博客网 时间:2024/05/29 16:39
睡眠--TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
因为等待事件而进入睡眠状态的方法:
The task performs the following steps to add itself to a wait queue:
进程通过执行下面几步将自己加入到一个等待队列中:
1. Creates a wait queue entry via DECLARE_WAITQUEUE().调用DECLARE_WAITQUEUE()创建一个等待队列的项
|--------------------------------------------------------|
| |
|DECLARE_WAITQUEUE(wait, current); |
|--------------------------------------------------------|
|DECLARE_WAITQUEUE(wait, current);
|--------------------------------------------------------|
2. Adds itself to a wait queue via add_wait_queue(). This wait queue awakens the process when the condition for which it is waiting occurs. Of course, there needs to be code elsewhere that calls wake_up() on the queue when the event actually does occur.调用add_wait_queue()把自己加入到队列中。该队列在进程等待的条件满足时唤醒它。当然我们必须在其他地方撰写相关代码,在事件发生时,对等待队列执行wake_up()操作
|--------------------------------------------------------|
|add_wait_queue(q, &wait); |
|--------------------------------------------------------|
while (!condition) {
|--------------------------------------------------------|
|add_wait_queue(q, &wait);
|--------------------------------------------------------|
while (!condition) {
3. Changes the process state to TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE.将进程的状态变更为TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE
|--------------------------------------------------------|
|
|
|--------------------------------------------------------|
4. If the state is set to TASK_INTERRUPTIBLE, a signal wakes the process up. This is called a spurious wake up (a wake-up not caused by the occurrence of the event). So check and handle signals.如果状态被设置为TASK_INTERRUPTIBLE,则信号可以唤醒进程(信号和事件都可以唤醒该进程)。这就是所谓的伪唤醒(唤醒不是因为事件的发生,而是由信号唤醒的),因此检查并处理信号。注: 信号和等待事件都可以唤醒处于 TASK_INTERRUPTIBLE 状态的进程,信号唤醒该进程为伪唤醒; 该进程被唤醒后,如果 (!condition) 结果为真,则说明该进程不是由等待事件唤醒的, 而是由信号唤醒的。 所以该进程处理信号后将再次让出CPU控制权
|--------------------------------------------------------|
|
|
|--------------------------------------------------------|
5. Tests whether the condition is true. If it is, there is no need to sleep. If it is not true, the task calls schedule().本进程在此处交出CPU控制权,如果该进程再次被唤醒,将从while循环结尾处继续执行,因而将回到while循环的开始处while (!condition),进测等待事件是否真正发生.
|--------------------------------------------------------|
|
|--------------------------------------------------------|
}
6. Now that the condition is true, the task can set itself to TASK_RUNNING and remove itself from the wait queue via remove_wait_queue().
|--------------------------------------------------------|
|set_current_state(TASK_RUNNING);
|remove_wait_queue(q, &wait);
|--------------------------------------------------------|
0 0
- linux进程状态-TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
- 睡眠--TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
- 睡眠--TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
- 进程资源和进程状态 TASK_RUNNING TASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE 和 TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE 的区别
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE 的区别
- TASK_INTERRUPTIBLE 和TASK_UNINTERRUPTIBLE 的区别
- TASK_INTERRUPTIBLE
- linux 进程 状态
- Linux进程状态
- Linux进程状态解析
- linux进程状态
- linux进程状态浅析
- 数据库设计技巧14则 - 数据库设计14个技巧
- IOS代码管控APP页面横竖屏切换
- select poll使用
- 关于代理和反向代理
- crtmpserver 基本流程分析
- linux进程状态-TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE
- Android仿新版微信主界面(使用android-support-v7兼容包,兼容2.2及其以上版本)
- AutoLayout(自动布局)入门
- poll和select的使用和差异
- <MFC多线程> 读者写者问题
- Java Insert Interval(插入间隔)
- 2014华为机试题——取出整型数据中出现次数最多的元素,并按照升序排列返回
- java痛苦学习之路[七]---专注移动互联网产品设计研发
- WeChall Training: Crypto - Caesar I