Reputation: 639
I want to know next and previous processes of every process,that it's state is "TASK_RUNNING". In older kernels there is a run_list struct as a member of task_struct. How can I do something like this in kernel 3 ? For example tracing a list of running processes, but I don't know which struct is defined as such list in kernel 3.
Upvotes: 2
Views: 764
Reputation: 3768
In newer kernels, Linux does not maintain a list of all running processes. Instead CFS uses red-black tree of sched_entity
to store information about running processes.
task_struct
contains member se
of type sched_entity
. Sched entity contains member run_node
of type struct rb_node
. This is what you are looking for.
Consult with include/linux/rbtree.h
for interface of rbtree. To extract task_struct
from sched_entity
you can use container_of(your_se, struct task_struct, se);
(consult with task_of()
in kernel/sched/fair.c
).
Upvotes: 4