


Detailed explanation of Linux user space and kernel space
Recommended: "Linux Video Tutorial"
1. Introduction
- Linux operating system and driver operation In kernel space, applications run in user space. The two cannot simply use pointers to transfer data. Because of the virtual memory mechanism used by Linux, user space data may be swapped out. When the kernel space uses user space pointers, the corresponding data may not be in memory. The memory mapping of user space adopts segment page type, while the kernel space has its own rules; this article aims to explore the address mapping of kernel space.
- os allocates an independent, continuous, virtual address memory space to each process. The size is generally 4G (32-bit operating system, that is, 2 to the 32nd power), in which the high address value is The memory space is allocated to os, linux os occupies 1G, and window os occupies 2G; the remaining memory address space is allocated to processes.
- Usually the 32-bit Linux kernel virtual address space is divided into 0~3G as user space and 3~4G as kernel space (note that the linear address that the kernel can use is only 1G). Note that this is the 32-bit kernel address space division, and the 64-bit kernel address space division is different.
- Process addressing space 0~4G
- The process is in user mode Only 0~3G can be accessed, and 3G~4G can only be accessed when entering the kernel state
- The process enters the kernel state through system calls
- The 3G~4G part of the virtual space of each process is the same
- The process entering the kernel state from user mode will not cause changes in CR3 but will cause changes in the stack
2. Linux kernel high-end memory
1. Origin
When the kernel module code or thread accesses memory, the memory addresses in the code are all logical addresses, and corresponding to the real physical memory address, the addressone-to-one is required Mapping, for example, the physical address corresponding to logical address 0xc0000003 is 0×3, the physical address corresponding to 0xc0000004 is 0×4,…, the relationship between logical address and physical address is
Physical address = Logical address – 0xC0000000 : This is the address translation relationship of the kernel address space. Note that the virtual address of the kernel is at the "high end", but the physical memory address mapped by ta is at the low end.
Logical address | Physical memory address |
0xc0000000 | 0×0 |
0×1 | |
0×2 | |
0×3 | |
… | |
0×20000000 | |
… | |
0xffffffff | 0×40000000 ?? |
Logical address | Physical memory address |
0xF8700000 | 0×80000000 |
0xF8700001 | 0×80000001 |
0xF8700002 | 0×80000002 |
… | |
0x800FFFFF |
The above is the detailed content of Detailed explanation of Linux user space and kernel space. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

How to back up VS Code configurations and extensions? Manually backup the settings file: Copy the key JSON files (settings.json, keybindings.json, extensions.json) to a safe location. Take advantage of VS Code synchronization: enable synchronization with your GitHub account to automatically back up all relevant settings and extensions. Use third-party tools: Back up configurations with reliable tools and provide richer features such as version control and incremental backups.
