What's the purpose of `on_rq` field in `task_struct`?

1.1k views Asked by At

I am now reading the source code of try_to_wake_up() function of Linux Kernel. This function does a lot and includes this: return p->on_rq == TASK_ON_RQ_QUEUED.

So, what is the actually purpose of on_rq field in task_struct.

BTW, does there exist some manuals or reading materials to introduce all the fields in task_struct? I think a fully understanding of these fields will help to clarify the mechanism of Linux's process scheduling.

1

There are 1 answers

0
cosinus0 On BEST ANSWER

Linux support separate run-queue for each CPU in the system. Task or task_struct could be in run-queue. Also task_struct could migrate beatween cpu's. p->on_rq indicate that task_struct is in a process of migrating between two run-queues. if p->on_rq == TASK_ON_RQ_MIGRATING task is migrating and other sheduler with this task cannot work it should busy wait. After it set to TASK_ON_RQ_QUEUED.