http://www.bubuko.com/infodetail-425054.html try_to_wake_up()
2015-10-04 15:26
591 查看
先介绍一个非常基础的函数: try_to_wake_up()
此函数的作用是:从等待队列中唤醒一个进程,让后将其放到就绪队列中。
static int try_to_wake_up(struct task_struct *p, int state,
int wake_flags)
参数的含义:p : 表示的是将要被唤醒的进程;
state : 可以被唤醒的进程的状态掩码;
wake_flags : 同步唤醒还是异步唤醒;
try_to_wake_up()返回失败值,如果p进程本身已经是active状态的话。
成功返回 1;失败返回 0;
等待队列中的等待进程的默认唤醒函数:default_wake_function()
int default_wake_function(wait_queue_t *curr, unsigned int mode,
int wake_flags, void *key)
{
return try_to_wake_up(curr->private, mode, wake_flags);
}
EXPORT_SYMBOL(default_wake_function);
可以看出,default_wake_function()本质上也是对 try_to_wake_up()函数的封装。
int autoremove_wake_function(wait_queue_t *wait,
unsigned int mode, int sync, void *key)
{
int ret;
ret = default_wake_function(wait, mode, sync, key);//从等待队列
中找到满足条件的等待进程;
if(ret)
list_del_init(&wait->task_list); // 将满足条件的等待进程从等待
队列中删除;
return ret;
}
从以上的几个函数可以总结出linux内核中对进程的状态的处理过程:
当一个正在运行的进程需要被阻塞时,调用 set_curent_state()或者__set_current_state()函数来改变一个进程的状态,然后通过init_wait()来分配一个wait_queue_t结构体,并将其一当前进程进行挂钩,最后通过add_wait_queue()函数或者add_wait_queue_exclusive()函数将其加入到等待队列之中。
try_to_wake_up()、default_wake_function()、autoremove_wake_function()函数详解
标签:唤醒进程的处理函数wait_queue_func_t
此函数的作用是:从等待队列中唤醒一个进程,让后将其放到就绪队列中。
static int try_to_wake_up(struct task_struct *p, int state,
int wake_flags)
参数的含义:p : 表示的是将要被唤醒的进程;
state : 可以被唤醒的进程的状态掩码;
wake_flags : 同步唤醒还是异步唤醒;
try_to_wake_up()返回失败值,如果p进程本身已经是active状态的话。
成功返回 1;失败返回 0;
等待队列中的等待进程的默认唤醒函数:default_wake_function()
int default_wake_function(wait_queue_t *curr, unsigned int mode,
int wake_flags, void *key)
{
return try_to_wake_up(curr->private, mode, wake_flags);
}
EXPORT_SYMBOL(default_wake_function);
可以看出,default_wake_function()本质上也是对 try_to_wake_up()函数的封装。
int autoremove_wake_function(wait_queue_t *wait,
unsigned int mode, int sync, void *key)
{
int ret;
ret = default_wake_function(wait, mode, sync, key);//从等待队列
中找到满足条件的等待进程;
if(ret)
list_del_init(&wait->task_list); // 将满足条件的等待进程从等待
队列中删除;
return ret;
}
从以上的几个函数可以总结出linux内核中对进程的状态的处理过程:
当一个正在运行的进程需要被阻塞时,调用 set_curent_state()或者__set_current_state()函数来改变一个进程的状态,然后通过init_wait()来分配一个wait_queue_t结构体,并将其一当前进程进行挂钩,最后通过add_wait_queue()函数或者add_wait_queue_exclusive()函数将其加入到等待队列之中。
try_to_wake_up()、default_wake_function()、autoremove_wake_function()函数详解
标签:唤醒进程的处理函数wait_queue_func_t
相关文章推荐
- Centos下apache启动时httpd: apr_sockaddr_info_get() failed for 报错
- linux 惊群问题 http://blog.csdn.net/liujiyong7/article/details/43346829
- 错误: 无法找到或可以不被加载到主类 Main
- 海量数据处理常用思路和方法 http://blog.csdn.net/lmh12506/article/details/7563266
- poll函数源码详细分析 http://blog.csdn.net/lmh12506/article/details/7556297
- CF#323-DIV2-D. Once Again-暴力贪心LIS
- TCP协议发送SKB时ip_summed成员的设置 http://blog.csdn.net/justlinux2010/article/details/8508455
- epoll源码分析---sys_epoll_wait()函数 http://blog.csdn.net/hbhhww/article/details/7746638
- 【bzoj1260】【CQOI2007】【涂色paint】【dp】
- unknown host www.baidu.com network is unreachable
- kernel painic not syncing
- Software caused connection abort: recv failed
- Hadoop Failed to set permissions of path
- Failed to set permissions of path:\tmp\hadoop-yth\mapred\staging\yth-2036315919\.staging to 0700
- Failed to list databases
- nginx:accept() failed (24: Too many open files)
- Codeforces #323 D. Once Again... (LIS)
- 直接使用JDB解决ndk-gdb调试时的“waiting for debugger”弹窗不消失问题
- Mac Please try running this command again as root/Administrator.
- 责任链模式----ChainOfResponsibility