In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what subsystems are there in the kernel of linux". In the daily operation, I believe many people have doubts about which subsystems in the kernel of linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what subsystems in the kernel of linux". Next, please follow the editor to study!
There are five subsystems in the linux kernel: 1, process scheduling control system (SCHED); 2, memory management system (MM), the main function is to control multiple processes to share the main memory area safely; 3, virtual file system (VFS); 4, network interface (NET); 5, inter-process communication (IPC).
The operating environment of this tutorial: Ubuntu 16.04 system, Dell G3 computer.
Kernel:
In computer science, it is a computer program used to manage the data I / O (input and output) requirements issued by software. Translating these requirements into instructions for data processing and handing them to the CPU and other electronic components in the computer is the most basic part of the modern operating system. It is a part of the software that provides many applications with secure access to computer hardware, which is limited, and it is up to the kernel to determine when and how long a program will operate on a certain part of the hardware. Operating directly on the hardware is very complex. So the kernel usually provides a way of hardware abstraction to accomplish these operations. Through the inter-process communication mechanism and system calls, the application process can indirectly control the required hardware resources (especially processors and IO devices).
What are the subsystems of the linux kernel
The Linux kernel is mainly composed of five subsystems: process scheduling (SCHED), memory management (MM), virtual file system (VFS), network interface (NET) and interprocess communication (IPC), as shown in the following figure.
1. Process scheduling
Process scheduling controls the access of multiple processes to CPU, so that multiple processes can be executed "microscopically serial and macroscopically parallel" in CPU. Process scheduling is at the center of the system, and other subsystems in the kernel depend on it because each subsystem needs to suspend or resume the process.
As shown in the following figure, the process of Linux switches between several states.
Linux process state transition
In device driver programming, when the requested resources can not be met, the driver will generally schedule the execution of other processes and put the process into a sleep state until the requested resources are released. Sleep is divided into interruptible sleep and uninterruptible sleep. The difference between interruptible sleep and uninterruptible sleep is that interruptible sleep wakes up when it receives a signal.
Processes that are completely in TASK_UNINTERRUPTIBLE state cannot even be "killed", so the kernel after Linux 2.6.26 also has a TASK_KILLABLE state, which equals "TASK_WAKEKILL | TASK_UNINTERRUPTIBLE" and can respond to deadly signals.
In the Linux kernel, a task_struct structure (include/linux/sched.h) is used to describe a process, which contains pointers that describe the process's memory resources, file system resources, file resources, tty resources, signal processing, and so on. Linux's threads are implemented in a lightweight process model, and when a thread is created in user space through pthread_create () API, the kernel essentially creates a new task_struct and points all the resource pointers of the new task_struct to the resource pointers of the task_struct that created it.
The vast majority of processes (and multiple threads in the process) are created by user-space applications, and when they have the need for underlying resources and hardware access, they enter kernel space through system calls. Sometimes, in kernel programming, if you need several tasks to execute concurrently, you can start kernel threads that have no user space. The function to start the kernel thread is: pid_t kernel_thread (int (* fn) (void *), void * arg, unsigned long flags)
2. Memory management
The main role of memory management is to control multiple processes to safely share the main memory area. When CPU provides a memory management unit (MMU), Linux memory management completes the conversion from virtual memory to physical memory for each process. Linux 2.6introduces support for no MMU CPU.
As shown in the figure, generally speaking, each process of Linux on a 32-bit processor has the memory space of 4GB, 0~3GB belongs to user space, and 3~4GB belongs to kernel space. Kernel space has different ways of dealing with conventional memory, Igamo device memory, and high-end memory. The specific limits of kernel space and user space can be adjusted, and under the kernel configuration option Kernel Features → Memory split, you can set the limit to 2GB or 3GB.
Linux process address space
As shown in the figure above, the overall memory management of the Linux kernel is relatively large, including the underlying Buddy (partner) algorithm, which is used to manage the footprint of each page, the slab allocator of kernel space and the secondary management of the C library of user space. In addition, the kernel also provides support for page caching, caching the disk with memory, and per backing device info flusher threads are used to flush back dirty pages to the disk. Kswapd (swap process) is the kernel thread used for page collection (including file-backed pages and anonymous pages) in Linux. It uses the least recently used (LRU) algorithm for memory collection.
3. Virtual file system
As shown in the figure
Linux virtual file system
The Linux virtual file system hides the details of all kinds of hardware and provides a unified interface for all devices. Moreover, it is independent of each specific file system and is an abstraction of various file systems. It provides unified vfs_read (), vfs_write () and other interfaces for upper applications, and calls the member functions of the file_operations structure implemented in the specific underlying file system or device driver.
4. Network interface
The network interface provides access to various network standards and support for all kinds of network hardware. As shown in figure 3.8, the network interface in Linux can be divided into network protocol and network driver, the network protocol part is responsible for implementing every possible network transmission protocol, the network device driver is responsible for communicating with hardware devices, and each possible hardware device has a corresponding device driver.
Linux network architecture
Linux kernel supports many kinds of protocol stacks, such as Internet, UNIX, CAN, NFC, Bluetooth, WiMAX, IrDA and so on. The upper application programs use socket interface.
5. Interprocess communication
Inter-process communication supports inter-process communication. Linux supports a variety of communication mechanisms between processes, including semaphores, shared memory, message queues, pipes, UNIX domain sockets and so on. These mechanisms can assist multiple processes, multi-resource mutually exclusive access, inter-process synchronization and message delivery. In practical Linux applications, people tend to use UNIX domain sockets rather than message queues in System V IPC. Android kernel adds Binder inter-process communication mode.
The dependencies between the five components of the Linux kernel are as follows:
The relationship between process scheduling and memory management: the two subsystems depend on each other. In a multi-program environment, a process must be created for a program to run, and the first thing to create a process is to load the program and data into memory.
The relationship between inter-process communication and memory management: the inter-process communication subsystem relies on memory management to support shared memory communication mechanism, which allows two processes to access common memory areas in addition to their own private space.
The relationship between the virtual file system and the network interface: the virtual file system supports the network file system (NFS) using the network interface, and also supports RAMDISK devices using memory management.
The relationship between memory management and virtual file system: memory management uses virtual file system to support exchange, and the exchange process is scheduled periodically by the scheduler, which is the reason why memory management depends on process scheduling. When the memory map accessed by a process is swapped out, memory management issues a request to the virtual file system while suspending the currently running process.
In addition to these dependencies, all subsystems in the kernel depend on some common resources. These resources include API used by all subsystems, such as functions for allocating and releasing memory space, functions for outputting warning or error messages, and debugging interfaces provided by the system.
At this point, the study of "what subsystems are there in the kernel of linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.