每个进程是否存在内核堆栈? [英] Does there exist Kernel stack for each process ?

查看:32
本文介绍了每个进程是否存在内核堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个用户空间进程是否存在内核堆栈和用户空间堆栈?如果两个堆栈都存在,那么每个用户空间进程应该有 2 个堆栈指针,对吧?

Does there exist a Kernel stack and a user-space stack for each user space process? If both stacks exist, there should be 2 stack pointers for each user space process right?

推荐答案

在 Linux 中,每个任务(用户空间或内核线程)都有一个 8kb 或 4kb 的内核堆栈,具体取决于内核配置.确实有单独的堆栈指针,但是,在任何给定时间,CPU 中都只有一个;如果用户空间代码正在运行,则用于异常或中断的内核堆栈指针由任务状态段指定,如果内核代码正在运行,则用户堆栈指针保存在位于内核堆栈上的上下文结构中.

In Linux, each task (userspace or kernel thread) has a kernel stack of either 8kb or 4kb, depending on kernel configuration. There are indeed separate stack pointers, however, only one is present in the CPU at any given time; if userspace code is running, the kernel stack pointer to be used on exceptions or interrupts is specified by the task-state segment, and if kernel code is running, the user stack pointer is saved in the context structure located on the kernel stack.

这篇关于每个进程是否存在内核堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆