问题描述
在哪里可以在内核树中找到wait_event_interruptible的代码.我可以找到的是wait_event_interruptible在中定义为__wait_event_interruptible.但是我找不到代码.请帮帮我.
Where can I find the code for wait_event_interruptible in Kernel tree.What I can find is wait_event_interruptible is defined as __wait_event_interruptible in . But I am unable to find the code .Please help me out.
考虑一个由于wait_event_interruptible而进入睡眠状态的进程.假设现在有一个中断,并且中断处理程序将唤醒睡眠过程(wake_up_event_interruptible).为使过程成功唤醒,wait_event_interruptible中给出的条件是否应为真?
Consider a process which has gone to sleep by wait_event_interruptible. Suppose if there is an interrupt now and the interrupt handler wakes(wake_up_event_interruptible) up the sleeping process. For the process to wake up successfully should the condition given in wait_event_interruptible be true ?
谢谢
推荐答案
它在include/linux/wait.h
中:
#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)
这篇关于wait_event_interruptible的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!