Two kinds of instructions: privileged instructions and non-privileged instructions
Two processor states: kernel state (core state/pipeline state), user state (eye state)
Two types of programs: kernel program and application program
Program execution:
C language code-compiler translation->machine instructions (binary)
Applications, running on the operating system;
The kernel program makes up the kernel of the operating system - the part closest to the hardware.
Kernel mode can execute privileged instructions, while user mode can only execute unprivileged instructions.
There is a register in the CPU: the program status word register (PSW), in which a binary bit of 1 represents the kernel state and 0 represents the user state.
Switching between kernel mode and user mode
When the computer is just booted into the kernel mode, the user starts an application and uses a privileged instruction to set the PSW flag to "user mode ", and the program runs on the CPU.
When the CPU is in user mode and finds a privileged instruction , an interrupt signal is triggered . The CPU changes to kernel mode, stops running the current application program, and switches to the kernel program that handles the interrupt signal .