What is the difference between kernel stack and user stack?

前端 未结 7 510
忘了有多久
忘了有多久 2021-01-31 06:25

What is the need of using two different stacks in same program? How does trap change the current stack of program from user stack to kernel stack? How does it come back to user

7条回答
  •  不思量自难忘°
    2021-01-31 07:03

    what is the need of using two different stacks in same program

    I've never heard of both a kernel and user stack in terms of a single process, though it may be extremely common. It's discussed here.

    The kernel stack must be isolated from the user mode stack. Otherwise, user mode code could corrupt the kernel stack, causing a kernel crash.

    how does trap changes the current stack of program from user stack to kernel stack

    You may want to look for something like the Intel Software Developer's Manuals.

    does each process has kernel and user stack

    I assume this varies with operating system design, though perhaps it's fairly universal. The links I provided above indicate that Linux uses two (or more) stacks per process. I haven't heard of Windows using a per-process kernel-mode stack.

提交回复
热议问题