内核函数autoremove_wake_function

int autoremove_wake_function(wait_queue_t *wait,   //等待队列中的某一个元素 
                                                            unsigned mode,         //能被唤醒的进程所处于的状态
                                                            int sync,                       //非0同步唤醒, 0代表非同步唤醒
                                                            void *key                    //唤醒进程时执行的函数

                                                            )
{
    //唤醒等待队列中的某一个进程
    int ret = default_wake_function(wait, mode, sync, key);

    //唤醒成功后 将此进程从等待队列中删除
    if (ret)
        list_del_init(&wait->task_list);
    return ret;
}

功能: 将进程唤醒后自动将此进程从等待队列中删除

返回值:

0: 没有唤醒成功,并且进程没有从等待队列中删除 

非0:唤醒成功,并且进程从等待队列中删除

头文件: #include <linux/wait.h>

例子:

猜你喜欢

转载自blog.csdn.net/yldfree/article/details/81089506