Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

While reading through the Linux Device Drivers, I could understand that the Process Descriptor (of type struct task_struct) has all the info regarding a particular task. The process descriptors are allocated dynamically by the slab allocator.

What I would like to know is about the need to introduce a new structure called thread_info which is stored at the bottom of the stack (assuming x86). Why was this done?

Why was it not possible to place the address of the current executing task address (struct task_struct) to the kernel stack?

share|improve this question

2 Answers 2

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.

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. So with the Slab Allocator you have task_struct stored somewhere else and not in the kernel stack of the particular process. 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.

share|improve this answer

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.

share|improve this answer
    
In linux kernel, taks_struct and thread_info is 1-1 mapping. –  Lai Jiangshan Jul 31 '12 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.