operating system - What is the difference between kernel stack and user stack? -


what need of using 2 different stacks in same program? how trap change current stack of program user stack kernel stack? how come user stack after completing system call?

does every process have kernel , user stack?

there 1 "kernel stack" per cpu. there 1 "user stack" each process, though each thread has own stack, including both user , kernel threads.

how "trapping changes stack" simple.

the cpu changes processes or "modes", result of interrupt. interrupt can occur many different reasons - fault occurs, (like error, or page-fault), or physical hardware interrupt (like device) - or timer interrupt (which occurs example when process has used of it's allotted cpu time").

either way - when interrupt called, cpu registers saved on stack - registers - including stack pointer itself.

typically "scheduler" called. scheduler chooses process run - restoring of saved registers including stack pointer, , continues execution left off (stored in return-address pointer).

this called "context switch".

i'm simplifying few things - how memory management context saved , restored, that's idea. it's saving , restoring registers in response interrupt - including "stack pointer" register.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -