等待队列函数分析


函数分析:

wait_event();

        --> if (condition)   break; //条件为假,该函数才能起作用!

        --> __wait_event(wq, condition); //实现进程运行状态的改变

             --> DEFINE_WAIT(__wait); //给进程唤醒留的接口函数

                        DEFINE_WAIT_FUNC(name, autoremove_wake_function)

                                int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);

            --> prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); //修改进程运行状态

            --> schedule(); //刷新进行运行状态

wake_up();

        --> __wake_up(x, TASK_NORMAL, 1, NULL);

                --> __wake_up_common(q, mode, nr_exclusive, 0, key);

                        --> wait_queue_func_t  func;

                                int (*wait_queue_func_t)     (wait_queue_t *wait, unsigned mode, int flags, void *key);

                                int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);

wait_event();

        功能:把一个处于就绪状态的进程放入到不可中断的等待队列中!

                  该状态的进程在睡眠时不会被信号唤醒!

wake_up();

   功能:把一个被wait_event();睡眠的进程重新唤醒。改变为就绪状态!

wait_event_timeout(wq, condition, timeout);

        功能:超时等待

wait_event(wq, condition);

        功能:不可中断的睡眠!

wait_event_interruptible(wq, condition);

        功能:可中断的睡眠!!!


wake_up();

   功能:唤醒由wait_event(wq, condition);睡眠的进程!

wake_up_interruptible(x);

   功能:唤醒由wait_event_interruptible(wq, condition);睡眠的进程!

猜你喜欢

转载自blog.csdn.net/qq_35769746/article/details/81006405