Why do we have two stacks per process i.e. one user mode and other kernel
mode?
As soon as process enters into kernel mode it starts using kernel mode
stack, but as soon as it comes out of kernel mode stack there is nothing in
the kernel mode stack. So cannot we simply have a single stack i.e. just
user mode stack which can also be used for kernel mode execution of process
after all there wont be any data related to kernel (all would have been
popped off) in the stack when we are back in user mode?

If you say that its just the stack pointer which is adjusted during pushes
and pops and the stack content remains intact and user can try to
increment/decrement stack pointer in order to access kernel data (which is
stale however) then instead of having two stacks (kernel and user) cannot we
simply zero out the stack area used by kernel before returing to user mode?
and can we save memory by having just one stack?

Best regards
- A
http://linuxexplained.blogspot.com

Reply via email to