3
votes

I know that a linux process have two separate stacks - one in user space and other in kernel space. But where is the stack used by ISR ? Is it shared with a process's kernel space stack ?

1
Why do you ask? From an application's point of view the only way to interact with the kernel is thru syscalls, so the kernel stack is not accessible (so "does not exist" for the application). From a kernel module's point of view, you don't care about the user-space stack (only the scheduler care).Basile Starynkevitch
It depends on the architecture.ninjalj

1 Answers

5
votes

In older times, the ISR used to be served using the current process's stack. So, when a interrupt happened, the current executing process would save all it's data on it's kernel or userspace stack and start executing the appropriate ISR function using it's own kernel stack.
But with the introduction of ISR stack, all the ISR related processing is done using a separate stack named ISR stack. ISR stack is in kernel space, as only kernel thread can execute the ISR handler of the interrupts.
The user space does not know and frankly does not care about whether the interrupt is served in current process's kernel stack or a separate ISR stack. As interrupts comes per cpu, therefore ISR stack has to be per cpu.

answering your original question : if ISR stack existes, it is completely different from process kernel stack. Otherwise, the process kernel stack is used for processing the interrupt.

Existence of ISR stack is also architecture depended.