for_each_process - Does it iterate over the threads and the processes as well?

和自甴很熟 提交于 2019-12-04 04:55:34

The following macros are what you need:

/*
 * Careful: do_each_thread/while_each_thread is a double loop so
 *          'break' will not work as expected - use goto instead.
 */
#define do_each_thread(g, t) \
        for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do

#define while_each_thread(g, t) \
        while ((t = next_thread(t)) != g)

Use them like this:

        rcu_read_lock();
        do_each_thread(g, t) {
            //...
        } while_each_thread(g, t);

        rcu_read_unlock();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!