operating-systemkernel

Switching from user mode to kernel mode


In my operating systems class, I'm asked whether switching from user to kernel mode is privileged. This is not OS-specific. At first I thought yes, but it seems like a big Catch 22. I referred to my textbook:

The hardware allows privileged instructions to be executed only in kernel mode. ...

The instruction to switch to kernel mode is an example of a privileged instruction.

Gagne, Greg; Abraham Silberschatz; Peter B. Galvin (2010-01-26). Operating System Concepts (p. 22). Wiley Higher Ed. Kindle Edition.

So we start in user mode. To switch to kernel mode requires a privileged instruction. A privileged instruction must be done in kernel mode, therefore we must switch to kernel mode to enable switching to kernel mode.

I'm thinking the system does not allow a user to switch itself to kernel mode directly, but that it is done by the kernel when the user seeks to execute another privileged instruction. Is that correct?


Solution

  • That is a typo introduced in the 8th edition and kept in the 9th. In the seventh edition, page 19, it says instead:

    "The instruction to switch to user mode is an example of a privileged instruction."

    Which clearly makes a lot more sense.