Understanding and accessing the kernel task structure
As you have learned by now, every single user and kernel space thread is internally represented within the Linux kernel by a metadata structure containing all its attributes – the task structure. The task structure is represented within the kernel code here: include/linux/sched.h:struct task_struct
.
To view any version of the kernel code online, a superb (searchable) system is in place here: https://elixir.bootlin.com/linux/latest/source. For the 6.1.25 LTS kernel release, for example, here’s the task structure definition: https://elixir.bootlin.com/linux/v6.1.25/source/include/linux/sched.h#L737.
It’s often, unfortunately, referred to as the “process descriptor,” causing no end of confusion! Thankfully, the phrase task structure is so much better; it represents a runnable task – in effect, a thread.
So, there we have it: in the Linux design, every process consists...