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

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

问题描述

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

解决方案

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

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?

解决方案

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天全站免登陆