User mode - kernel mode

Foreplay

We know that the computer is divided into three parts, hardware, operating systems and applications, and hardware cpu mind control is the kernel mode and user mode chiefs

operating system

The operating system is dealing directly with the hardware, the operating system is running in kernel mode, so you can access the entire hardware

application

Direct application and user interaction, but the application can not directly operate the hardware, applications running in user mode, but sometimes need to operate the hardware application, this time, it relates to the switching of the user mode and kernel mode

Kernel mode - user mode concept

Kernel mode (operating system gave all instructions)

When the cpu when running in kernel mode, cpu can execute all instructions of the instruction set, it is clear that all instructions contains all the features of the hardware used

User mode (instruction operation section disabled hardware)

User program running in user mode, only a subset of the cpu can perform the entire instruction set, the subset does not include the operation portion of the hardware functions, therefore, under normal circumstances, the user states on I / O and memory protection ( amount of memory the operating system is protected and can not be occupied by other procedures), of course, in user mode, the PSW is set to mode kernel mode is prohibited.

Kernel mode - user mode switch

CPU to perform a handover

Since the kernel mode and user mode are very frequent, and it is recorded in the state switching cpu registers, the most appropriate

Program Status Register - (system call)

Working software can not operate in user mode hardware, but our software such as STORM, there will be demand for hardware operations, such as reading a movie file from the disk, it must go through the process of switching from user mode to kernel mode, as here, the user must use a system call (system call), and call the system call into the operating system kernel, the TRAP instruction is switched to the user mode kernel mode, and to enable the operating system to obtain service.

note

User mode kernel mode, an execution state corresponding to the cpu, cpu command can be used in different states different

Reference links

https://www.cnblogs.com/zx125/p/11524709.html

https://www.cnblogs.com/linhaifeng/p/6523843.html

Guess you like

Origin www.cnblogs.com/zx125/p/12064385.html