1

カーネル ツリーで wait_event_interruptible のコードはどこにありますか。私が見つけることができるのは、wait_event_interruptible が __wait_event_interruptible として定義されていることです。しかし、コードが見つかりません。私を助けてください。

wait_event_interruptible によってスリープ状態になったプロセスを考えてみましょう。現在割り込みがあり、割り込みハンドラーがスリープ状態のプロセスを起こす (wake_up_event_interruptible) とします。プロセスが正常にウェイクアップするには、wait_event_interruptible で指定された条件が true である必要がありますか?

ありがとう

4

2 に答える 2

4

それは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)
于 2012-06-05T08:51:55.660 に答える
0

はい、2番目の質問に答えます。

割り込みハンドラー(またはその他のスレッド)が待機キューを呼び出すwake_up()と、待機キューで待機しているすべてのスレッドがウェイクアップされ、状態がチェックされます。条件が真であるスレッドのみが続行し、残りはスリープに戻ります。LDD3の待機キューを参照してください。

ctagsまたはを使用cscopeして、このような定義を簡単に見つけられるようにします。

于 2012-06-07T02:10:48.933 に答える