3
votes

What does the following phrase mean: "the kernel executes in the process context"?

Does it mean that if CPU is executing some process and then some interrupt occurs (system call, key press, etc.), the CPU will keep the page table for the currently running process loaded and then it will execute the interrupt handler which resides in the process's kernel space?

If this is what it means, then it seems like the interrupt handler is executed in the process context, so what does interrupt context means?

1

1 Answers

7
votes

Process context is its current state. We need to save the context of the current running process so it can be resumed after the interrupt is handled.

Process context is basically its current state (what is in its registers).

esp
ss
eip
cs
and more.

We need to save the instruction pointer (EIP) and the CS (Code Segment) so that after the interrupt is handled we can continue running from where we were stopped.


The interrupt handler code resides in Kernel memory. Once an interrupt occur, we immediately switch from user mode to kernel mode. The state of the current running process is saved, part of it on user-stack and the other part on kernel-stack (depending on architecture). Assuming it's x86 then the interrupt handler is run by loading the appropriate ss, cs, esp and eip from TSS and Interrupt descriptor table.