What is the difference between Operating system processing modes and CPU processing modes?

2.4k Views Asked by At

A process has two modes: User mode and supervisor mode. Also CPU has different privilege levels to run. Are these two concepts the same? In Linux Kernel Projects By Gary Nutt, it is mentioned that to make a system call, a process must first acquire the supervisory mode. Is this mode the same as when the CPU runs in privileged mode at the startup(when BIOS procedures run e.g. POST or loading of MBR) and when it calls low level BIOS routines? Or the CPU is still running in the user mode when these system calls occur? Also, if the second is true, is there any way to run the CPU in privileged mode by the user... I heard int 0x80 does it, but again, I reach the same doubt as to whether it makes the OS run in privileged mode or the CPU...

Any links related to the same would also be greatly appreciated... Kindly tell which is true? Thank you in advance...

2

There are 2 best solutions below

1
On

The OS mode is modeled on machines that have a hardware mode, and may well use the hardware support, but not necessarily. The issue is that some CPUs don't have a "supervisor" mode, so the OS has to somehow simulate it.

This Wikipedia article is reasonably good.

Update

Strictly, there's no such thing in Linux as "supervisor mode" -- what you have is kernel mode. And yes, at least part of an interrupt handler, and a system call, will be in kernel mode.

This is a good article on how it happens. And this is another SO question that has some good information.

I think we're running into terminology problems. There is the operating system's kernel mode, which is entered in an x80 system with interrupt x80 (nice coincidence that). But there are also privileged operations that must be in hardware supervisor mode. This is a long description of how that's done in the x86.

0
On

They are the same: “kernel mode” is the same as the processor's “supervisor mode” (Ring 0 on x86), and “user mode” is the processor's mode with least privileges (Ring 3 on x86). Note that on x86, two additional privilege levels exist (Rings 1 & 2), but neither Windows nor Linux use them.

See the article about “Rings” on Wikipedia.

Memory protection, isolation among processes, etc. is achieved thanks to hardware support, i.e. these “privilege levels” (Rings). For instance, a user process may not change memory page tables, contrary to the kernel.