rCore-Tutorial icon indicating copy to clipboard operation
rCore-Tutorial copied to clipboard

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

Open losfair opened this issue 5 years ago • 2 comments

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) .

losfair avatar Jul 24 '20 04:07 losfair

我们教学操作系统的实现中没有实现和 Linux 系统一样的结构,线程只有自己的运行栈(指导中有时会称为“用户栈”,其实应该改为“运行栈”),同时有一个公用的(相当于对于唯一的一个 CPU 有一个)中断栈(指导中称为“内核栈”,其实应该改为“中断栈”)。这里没有对应于 Linux 系统内核栈的结构

我觉得就将名称改为“运行栈”和“中断栈”更加清楚

Tuyixiang avatar Jul 25 '20 10:07 Tuyixiang

👍 赞成使用「运行栈」与「中断栈」

losfair avatar Jul 25 '20 14:07 losfair