educative.io

Educative

What is the difference between user register and the kernel register?

I didn’t get the two type of register. What is the difference between user register and the kernel register and why we have a user register and kernel register?

Thanks in advance.

Hi @Mody_Awad

User registers are used at the application level. And kernel registers are used at the OS level.

When an application program runs, it has access to its own set of registers known as the user registers. Multiple applications can be running at a time in an OS using the context switching principle.
When you switch to another application, these register content is saved to memory, and registers, saved from other applications, are loaded and this application continues its execution.

As for the kernel registers, they are used to store the state of OS. Since the OS can also switch itself from one running program to another. When context switching takes place in between OS-related programs, kernel registers are used for that.