nitin_cherian
nitin_cherian

Reputation: 6655

Does there exist Kernel stack for each process ?

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?

Upvotes: 9

Views: 1705

Answers (2)

winner.hong
winner.hong

Reputation: 1

Each user space thread(not just process) has its user space stack and kernel space stack. The kernel space has one stack percpu and the ISR has its seperate stack too.

Upvotes: 0

bdonlan
bdonlan

Reputation: 231143

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.

Upvotes: 16

Related Questions