Skip to content

关于 Lab 4 中「内核栈」和「运行栈」的命名问题 #104

@losfair

Description

@losfair

Lab 4 的第二节「线程和进程」中,用「运行栈」指代线程在内核态运行时使用的栈;第六节中,用「内核栈」指代中断处理所用的栈。

这对名称有些令人困惑。若与线程的「用户态」对应的是线程的「内核态」,则与「用户栈」相对应的名称可能也是「内核栈」更合适一点。

若参考 Linux 的文档:

Like all other architectures, x86_64 has a kernel stack for every active thread. These thread stacks are THREAD_SIZE (2*PAGE_SIZE) big. These stacks contain useful data as long as a thread is alive or a zombie. While the thread is in user space the kernel stack is empty except for the thread_info structure at the bottom.

In addition to the per thread stacks, there are specialized stacks associated with each CPU. These stacks are only used while the kernel is in control on that CPU; when a CPU returns to user space the specialized stacks contain no useful data. The main CPU stacks are:

  • Interrupt stack. IRQ_STACK_SIZE

则线程在内核态运行时使用的栈似乎应被命名为「内核栈」 (kernel stack) ,而中断处理时使用的栈则应被命名为「中断栈」 (interrupt stack) .

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions