简体   繁体   中英

What is “process context” exactly, and how does it relates to “interrupt context”?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM