- 论坛徽章:
- 9
|
本帖最后由 Tinnal 于 2014-05-21 20:32 编辑
功能类似,都是让当前进程阻塞,等待任务完成。差别为:
DEFINE_WAIT为等待队列,一唤‘醒,队列上所有的任务都会唤‘醒,wait_event_interruptible有一个条件参数,只会唤‘醒队列上满足条件的任务。
其实 wait_event_interruptible就是DEFINE_WAIT的简单包装。- #define wait_event_interruptible(wq, condition) \
- ({ \
- int __ret = 0; \
- if (!(condition)) \
- __wait_event_interruptible(wq, condition, __ret); \
- __ret; \
- })
- #define __wait_event_interruptible(wq, condition, ret) \
- do { \
- DEFINE_WAIT(__wait); \
- \
- for (;;) { \
- prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (!signal_pending(current)) { \
- schedule(); \
- continue; \
- } \
- ret = -ERESTARTSYS; \
- break; \
- } \
- finish_wait(&wq, &__wait); \
- } while (0)
复制代码 |
|