Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know that there are two types of stack in Linux : user stack when process running in user mode and switch to Kernel Stack during interrupts or when system call in made. The interruptions, more precisely, the interruption procedures, are the bridges between this two modes, kernel (0) and user (3). The interrupt vector table let the processor loads the right instruction address in the PC register, but how is the stack pointer register changed when it switches to kernel mode?

Are there separate stack pointers for each mode say user and kernel.
And during interrupt , is the interrupted tasks kernel stack is used for interrupt processing(i mean ISR)?. If there are two different stack pointers for user and kernel mode and how kernel intimate the cpu of the current process's kernel stack pointer.How this differnet kernel stacks are used in context switching? can some one elaborate or point out some articles on this topic?

Thanks in advance.
Posted
Comments
PIEBALDconsult 22-Nov-15 12:57pm    
Yes.
Sergey Alexandrovich Kryukov 22-Nov-15 13:22pm    
It depends on CPU. In x86 family of architectures (you did not share with us which CPU architecture you use), as well as all architectures stemming from i386, the switch of stack selector-offset is implemented as a part of context-switch commands (jump, call...) Indeed, through the descriptor of task selector the CPU can "see" the preserved value of stack pointer... Yes, I think you are thinking in right direction; there are separate stacks, so stack pointer "jumps" between the two; how the "thunk" between two kernel rings is implemented depends on OS...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900