CPU Switches from User mode to Kernel Mode : What exactly does it do? How does it makes this transition?
EDIT:
Even if it is architecture dependent please provide me with an answer. The architecture is up to you. Tell me for the architecture you know about.
I want to get an idea about what all things will be involved in it.
The system is in user mode when the operating system is running a user application such as handling a text editor. The transition from user mode to kernel mode occurs when the application requests the help of operating system or an interrupt or a system call occurs.
A processor in a computer running Windows has two different modes: user mode and kernel mode. The processor switches between the two modes depending on what type of code is running on the processor. Applications run in user mode, and core operating system components run in kernel mode.
When an interrupt occurs, CPU hardware switches to the kernel mode. Switching to user mode (from kernel mode) done by setting CPU mode bit (by an instruction). Privileged instructions can be executed only in kernel mode.
A context switching is a process that involves switching of the CPU from one process or task to another. In this phenomenon, the execution of the process that is present in the running state is suspended by the kernel and another process that is present in the ready state is executed by the CPU.
Note: this is mostly relevant to x86 architecture. Here's a somewhat simplified explanation.
The transition is usually caused by one of the following:
What normally happens is that system checks the Interrupt Descriptor Table (IDT). Each exception (interrupt, fault, etc.) has a number associated with it which is used to index into this table.
From this table the CPU can determine the interrupt handler to run.
As part of the transition the following changes (generally) take effect:
You're now in kernel mode.
Hope that helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With