for_each_process - Does it iterate over the threads and the processes as well?
问题 I would like to iterate all the tasks in the kernel (threads and processes) and print tid/pid and name using for_each_process macro: #define for_each_process(p) \ for (p = &init_task ; (p = next_task(p)) != &init_task ; ) How can I distinguish between thread and process? So I'll print it like that: if (p->real_parent->pid == NULL) printk("PROCESS: name: %s pid: %d \n",p->comm,p->pid); else printk("THREAD: name: %s tid: %d \n",p->comm,p->pid); 回答1: The following macros are what you need: /* *