Joontaek Oh
Joontaek Oh

Reputation: 152

How do kernel switch the kernel stack and user stack?

How do kernel switch the kernel stack and user stack?

I'm viewing interrupt handling in linux kernel.

I know that process only use kernel stack in kernel mode.

But, How it bring the kernel stack pointer when interrupt is occurred?

I didn't saw that kernel save its stack pointer to some register in the interrupt exit code.

Upvotes: 0

Views: 832

Answers (1)

Joontaek Oh
Joontaek Oh

Reputation: 152

The TSS have a pointer to kernel stack.

When the INT n is called, the CPU read TSS by referring the GDT.

The TSS have kernel stack pointer and it is set when the thread is created.

The CPU read kernel stack pointer and set esp to kernel stack pointer and compose interrupt frame in kernel stack.

Upvotes: 1

Related Questions