wait システム コールのパスをたどっているときに、do_wait_thread を呼び出す前に tasklist_lock を取得していることに気付きました。tasklist_lock の重要性と使用するのが適切な場所を理解しようとしています。
716 read_lock(&tasklist_lock);
1717 tsk = current;
1718 do {
1719 retval = do_wait_thread(wo, tsk);
1720 if (retval)
1721 goto end;
1722
1723 retval = ptrace_do_wait(wo, tsk);
1724 if (retval)
1725 goto end;
1726
1727 if (wo->wo_flags & __WNOTHREAD)
1728 break;
1729 } while_each_thread(current, tsk);
1730 read_unlock(&tasklist_lock);
tasklist_lock の宣言を見てみると、以下のようになっています。
/*
251 * This serializes "schedule()" and also protects
252 * the run-queue from deletions/modifications (but
253 * _adding_ to the beginning of the run-queue has
254 * a separate lock).
255 */
256 extern rwlock_t tasklist_lock;
257 extern spinlock_t mmlist_lock;
これをどこで使うべきか理解できません。それについて教えてください。あなたの助けに感謝。