c - Linux 内核 task_struct void *stack

标签 c linux memory-management process linux-kernel

sched.htask_struct 中的 void *stack 声明是什么? ?

它是指向进程镜像(堆栈、堆、.bss、数据、文本)堆栈的指针吗?如果是这样,指向过程镜像其余部分的指针在哪里?

最佳答案

在Linux内核源代码中你可以看到宏task_thread_info() :

#define task_thread_info(task)  ((struct thread_info *)(task)->stack)

task_structvoid *stack指针指向thread_info

自 2.6 版本起,Linux 使用任务的内核堆栈页帧的一部分来存储“线程信息”(thread_info)。 thread_info 又包含一个指向 task_struct 的指针:

struct task_struct *task = info->task;

F.e. (对于堆栈沿着内存地址值减小的方向增长的平台):

enter image description here

有用的链接:1 , 2

<小时/>

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;
    //...
}

必读:How The Kernel Manages Your Memory

关于c - Linux 内核 task_struct void *stack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59054053/

相关文章:

c - 自动售货机 - 只接受硬币

c - 如何使用c程序查找我的机器是16位、32位还是64位

linux - 没有管理员权限的服务器中组的 Git 存储库

c - C中的段错误,操作系统如何管理它?

c++ - 重写 operator new 时编译器错误

iphone - 如何在运行时指定一个数组?

c - 结构内部结构类型的填充

c - 什么编译器支持多编程语言?

linux - 如何创建和运行安装了相同配置和软件的多个ec2实例?

安卓内存统计