What was the need of thread_ info structure?

What was the need of thread_ info structure?

The reason why we need the thread_info is due to the fact that we are allocating the memory for task_struct using the Slab Allocator. Now you may ask what is the relation between these? To understand that you need to understand how Slab Allocator works.

What is thread_info structure?

The task_struct structure is allocated from the heap like most other kernel data structures. The thread_info structure, though, lives at the bottom of the kernel stack, making it impossible to reuse the kernel stack as long as something might try to reference that structure.

What is a task_ struct?

In the Linux kernel, processes are defined as task_struct structures in include/linux/sched. This process state is seldom used. TASK_STOPPED identifies a process whose execution has been stopped. The process enters this state upon delivery of a SIGSTOP , SIGTSTP , SIGTTIN or SIGTTOU signal (see signal(7) ).

Where is task_struct stored?

From the perspective of Virtual memory system, task_struct is allocated by the Slab allocator, so that it’s located in the kernel space.

What is kernel stack used for?

The kernel stack is also used for interrupt handler execution, for the interrupts that occur while a particular thread is running. As we have talked about already, the interrupts are almost always doing something for another, blocked process/thread.

What is stored in task_struct?

linux process kernel task. Task_struct is used for keeping necessary information about a process by kernel. Thanks to that structure kernel can suspend a process and after a while proceed with its implementation.

Why do we need thread _ info in Linux?

Now the Kernel developers introduced thread_info and placed a pointer in it to the place where the task_struct resides. And that is why we have to live with thread_info. You can read about Slab Allocator in Robert Love’s book Linux Kernel Development.

What is the need of the struct thread _ info in?

Light-weight processes don’t have a task_struct; a stack and a small amount of information would be enough. Several LWPs share the same task_struct, which contains all the resource descriptions. Thanks for contributing an answer to Unix & Linux Stack Exchange!

How is memory allocated to task _ struct in Linux?

Without the Slab Allocator , the kernel developers could allocate memory for task_struct in the kernel stack for the particular process so that it can be accessed easily. Now with the advent of Slab Allocator , the memory is allocated to the task_struct as determined by the Slab Allocator.