What Is an Account Stated?

User mode refers to two similar concepts in computer architecture. In the design of the CPU, the user state refers to the unprivileged state. In this state, the code executed is limited by the hardware and cannot perform certain operations, such as writing to the storage space of other processes, to prevent security risks to the operating system. In the design of the operating system, user mode is also similar, referring to the unprivileged execution state. The kernel prohibits code in this state from performing potentially dangerous operations, such as writing system configuration files, killing other user processes, and restarting the system.

User mode refers to two similar concepts in computer architecture. In the design of the CPU, the user state refers to the unprivileged state. In this state, the code executed is limited by the hardware and cannot perform certain operations, such as writing to the storage space of other processes, to prevent security risks to the operating system. In the design of the operating system, user mode is also similar, referring to the unprivileged execution state. The kernel prohibits code in this state from performing potentially dangerous operations, such as writing system configuration files, killing other user processes, and restarting the system.
Chinese name
User mode
Foreign name
user mode
Concept
Computer architecture refers to two similar concepts
CPU design
Unprivileged state
Core state
ring 0
Related
Kernel state

User mode profile

User mode refers to two similar concepts in computer architecture.
User mode and kernel mode
In the design of the CPU, the user state refers to the unprivileged state. In this state, the code executed is limited by the hardware and cannot perform certain operations, such as writing to the storage space of other processes, to prevent security risks to the operating system. In the design of the operating system, user mode is also similar, referring to the unprivileged execution state. The kernel prohibits code in this state from performing potentially dangerous operations, such as writing system configuration files, killing other user processes, and restarting the system.
User mode in CPU design
User mode does not allow programs to perform operations in the processor that require privileged states to avoid operating system crashes. Each process runs in its own user space and does not allow access to the user space of other programs.
The x86 structure has four levels, the highest level is ring 0, which is the core state. The lowest level is ring 3, which is user mode. Ring 1 and Ring 2 are designed for driver use, but are rarely used.
User mode in operating system design
The user mode in the operating system refers to the general level in the permission level, as opposed to the privilege level of the administrator or superuser (in Unix-like systems, named "root" or "superuser"). Each process started in user mode is given specific permissions by the system according to the user who runs the process.
The user mode of the operating system usually runs the code in the corresponding CPU user mode, so as to implement the control of illegal programs on the hardware. Compared with the CPU level, the operating system allows user mode to have more complicated permission settings. For example, in the default Unix system, code running in user mode is not allowed to pretend to be a common service by listening to port numbers below 1024, and code running by superusers is entitled to do so.

linux User mode linux user mode

User mode and user mode

When a task (process) executes a system call and is trapped in the kernel code for execution, we call the process in the kernel running state (or simply the kernel state). The processor is now executing in the most privileged (level 0) kernel code. When the process is in kernel mode, the executed kernel code uses the kernel stack of the current process. Each process has its own kernel stack.
When the process is executing the user's own code, it is said to be in the user-run state (user mode). That is, the processor is running in the lowest privileged (level 3) user code. When the user program is being executed and suddenly interrupted by the interrupt program, the user program can also be symbolically referred to as being in the kernel state of the process. Because the interrupt handler will use the kernel stack of the current process. This is somewhat similar to the state of a process in kernel mode.
In short:
1, enter the core state when using system calls. Linux's operation of hardware can only be in kernel mode, which can be controlled by writing drivers. Operating the hardware in user mode will cause a core dump.
2. Pay attention to distinguishing system calls from general functions. System calls are provided by the kernel, such as read (), write (), open (), and so on. The general functions are provided by the function library in the software package, such as sin (), cos (), etc. There is no difference in syntax.
3. In general: system calls run in core mode, and functions run in user mode. However, there are some functions that use system calls internally (such as fopen). Such functions enter core mode when calling system calls, and run in user mode at other times.

User mode context

The processor is always in one of the following states:
1. Kernel mode, running in the process context, the kernel runs in kernel space on behalf of the process;
2, kernel mode, running in interrupt context, the kernel represents hardware running in kernel space;
3. User mode, running in user space.
User space applications enter kernel space through system calls. At this time, the user space process needs to pass many variables and parameter values to the kernel. When the kernel mode is running, it also needs to save some register values and variables of the user process. The so-called "process context" can be seen as the parameters passed by the user process to the kernel, the set of variables and register values to be saved by the kernel, and the environment at that time.
Through the trigger signal, the hardware causes the kernel to call the interrupt handler to enter the kernel space. In this process, some variables and parameters of the hardware are also passed to the kernel, and the kernel performs interrupt processing through these parameters. The so-called "interrupt context" can actually be regarded as these parameters passed by the hardware and some other environments that the kernel needs to save (mainly the process environment where execution is currently interrupted). [1]

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?