What is the void *stack
declaration in task_struct
in sched.h?
Is it the pointer to the process image (stack, heap, .bss, data, text) stack? If so, where are the pointers to the rest of the process image?
What is the void *stack
declaration in task_struct
in sched.h?
Is it the pointer to the process image (stack, heap, .bss, data, text) stack? If so, where are the pointers to the rest of the process image?
In Linux kernel source code you can see the macros task_thread_info():
#define task_thread_info(task) ((struct thread_info *)(task)->stack)
The void *stack
pointer of task_struct
points to thread_info
.
Since 2.6 version Linux uses part of a task's kernel-stack page-frame to store "thread information" (thread_info
). The thread_info
in its turn includes a pointer to the task_struct
:
struct task_struct *task = info->task;
F.e. (for platforms where the stack grows in the direction of decreasing the value of the memory address):
where are the pointers to the rest of the process image?
Such info is contained in memory descriptor mm_struct
. F.e.:
struct mm_struct {
//...
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack;
//...
}
Must-read: How The Kernel Manages Your Memory