Introduction to the Overall Architecture of the Linux Kernel

Source: Internet
Author: User
Keywords linux linux kernel linux kernel architecture
1 Introduction
This article will take the core functions of the kernel as a starting point to describe the overall architecture of the Linux kernel and the main software subsystems under the architecture. After that, the directory structure of Linux kernel source files will be introduced and correspond to each software subsystem.

Note: This article and other "Linux Kernel Analysis" articles are based on the following conventions:
a) The kernel version is Linux 3.10.29 (this version is a long term version and will be maintained by the Linux community for at least 2 years), which can be obtained from the following link: https://www.kernel.org/pub/linux /kernel/v3.x/linux-3.10.29.tar.xz
b) In view of the fact that most embedded systems use ARM processors, the contents of the system structure are all analyzed based on ARM

2. The core functions of the Linux kernel
The Linux kernel is only part of the Linux operating system. On the bottom, it manages all the hardware devices of the system; on the top, it provides interfaces to Library Routine (such as C library) or other applications through system calls.


Therefore, its core function is to manage hardware equipment and use it by application programs. The standard components of a modern computer (whether it is a PC or an embedded system) are CPU, Memory (memory and external storage), input and output devices, network devices and other peripheral devices. So in order to manage these devices, the Linux kernel proposes the following architecture.

3. The overall architecture of the Linux kernel
3.1 Overall architecture and sub-system division
According to the core functions of the kernel, the Linux kernel proposes 5 subsystems, which are responsible for the following functions:

1. Process Scheduler, also known as process management and process scheduling. Responsible for managing CPU resources so that each process can access the CPU in a fair manner as possible.

2. Memory Manager, memory management. Responsible for managing Memory (memory) resources so that each process can safely share the machine's memory resources. In addition, the memory management will provide a virtual memory mechanism, which allows the process to use more memory than the system's available Memory, and the unused memory will be stored in the external non-volatile memory through the file system and retrieved when needed. In memory.

3. VFS (Virtual File System), virtual file system. The Linux kernel abstracts external devices with different functions, such as Disk devices (hard disks, disks, NAND Flash, Nor Flash, etc.), input and output devices, display devices, etc., into a unified file operation interface (open, close, read, write, etc.) to visit. This is the embodiment of the Linux system "everything is a file" (in fact, Linux does not do it thoroughly, because the CPU, memory, network, etc. are not files yet. If you really need everything to be a file, you have to look at what Bell Labs is developing "Plan 9").

4. Network, the network subsystem. Responsible for managing the network equipment of the system and realizing various network standards.

5. IPC (Inter-Process Communication), inter-process communication. IPC does not manage any hardware, it is mainly responsible for the communication between processes in the Linux system.

3.2 Process Scheduler
Process scheduling is the most important subsystem in the Linux kernel, which mainly provides access control to the CPU. Because in a computer, CPU resources are limited, and many applications use CPU resources, so a "process scheduling subsystem" is needed to schedule and manage the CPU.

The process scheduling subsystem includes 4 sub-modules, their functions are as follows:

scheduler

1. Scheduling Policy, a strategy for implementing process scheduling, which determines which process (or several) will own the CPU.

2. Architecture-specific Schedulers, the parts related to the architecture, used to abstract the control of different CPUs into a unified interface. These controls are mainly used in suspend and resume processes, involving CPU register access, assembly instruction operations, etc.

3. Architecture-independent Scheduler, the part that is independent of the architecture. It will communicate with the "Scheduling Policy Module" to decide which process to execute next, and then resume the process specified by the "Architecture-specific Schedulers Module".

4. System Call Interface, system call interface. The process scheduling subsystem opens up the interface that needs to be provided to the user space through the system call interface, while shielding the details that do not need to be concerned by the user space program.

3.3 Memory Management (Memory Manager, MM)
Memory management is also the most important subsystem in the Linux kernel, which mainly provides access control to memory resources. The Linux system will establish a mapping relationship between the physical memory of the hardware and the memory used by the process (called virtual memory). This mapping is based on the process, so different processes can use the same virtual memory, and these are the same The virtual memory can be mapped to different physical memory.

The memory management subsystem includes 3 sub-modules, their functions are as follows:

1. Architecture Specific Managers, related parts of the architecture. Provides a virtual interface for accessing hardware memory.

2. Architecture Independent Manager, the independent part of the architecture. Provides all memory management mechanisms, including: memory mapping in units of processes; Swapping of virtual memory.

3. System Call Interface, system call interface. Through this interface, functions such as memory allocation and release, and file map are provided to user space program applications.

3.4 Virtual Filesystem (Virtual Filesystem, VFS)
A file system in the traditional sense is a method of storing and organizing computer data. It uses easy-to-understand and user-friendly methods (file and directory structure) to abstract the cold data blocks on computer disks, hard disks and other devices, making it easy to find and access them. Therefore, the essence of the file system is "the method of storing and organizing data", and the manifestation of the file system is "reading data from a certain device and writing data to a certain device".

With the advancement of computer technology, the methods of storing and organizing data are also constantly improving, resulting in many types of file systems, such as FAT, FAT32, NTFS, EXT2, EXT3, and so on. In order to be compatible, the operating system or kernel must support multiple types of file systems in the same form, which extends the concept of virtual file system (VFS). The function of VFS is to manage various file systems, shield their differences, and provide user programs with an interface for accessing files in a unified way.

We can read or write data from devices such as disks, hard drives, and NAND Flash. Therefore, the original file system was built on these devices. This concept can also be extended to other hardware devices, such as memory, display (LCD), keyboard, serial port and so on. Our access control to hardware devices can also be summarized as reading or writing data, so it can be accessed with a unified file operation interface. The Linux kernel does this. In addition to the traditional disk file system, it also abstracts the device file system, memory file system, and so on. These logics are all implemented by the VFS subsystem.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.