主要是宏do_each_thread、while_each_thread的使用signal.h - include/linux/sched/signal.h - Linux source code (v4.19.89) - Bootlin
struct task_struct *gTask;
struct task_struct *task;
do_each_thread(gTask, task)
{
// task就是遍历的当前进程/线程
// 拿到当前task_struct做你想做的事情
...
}
while_each_thread(gTask, task);