sched.h 中 task_struct
中的 void *stack
声明是什么? ?
它是指向进程镜像(堆栈、堆、.bss、数据、文本)堆栈的指针吗?如果是这样,指向过程镜像其余部分的指针在哪里?
最佳答案
在Linux内核源代码中你可以看到宏task_thread_info() :
#define task_thread_info(task) ((struct thread_info *)(task)->stack)
task_struct
的void *stack
指针指向thread_info
。
自 2.6 版本起,Linux 使用任务的内核堆栈页帧的一部分来存储“线程信息”(thread_info
)。 thread_info
又包含一个指向 task_struct
的指针:
struct task_struct *task = info->task;
F.e. (对于堆栈沿着内存地址值减小的方向增长的平台):
<小时/>where are the pointers to the rest of the process image?
此类信息包含在内存描述符 mm_struct
中。例如:
struct mm_struct {
//...
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack;
//...
}
关于c - Linux 内核 task_struct void *stack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59054053/