In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
How to analyze the kernel of Linux system architecture, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Overview
Linux system generally consists of four main parts, kernel, shell, file system and application. Together, the kernel, shell, and the file system form the basic operating system structure that allows users to run programs, manage files, and use the system. Because there is a lot of content, so here is a brief introduction to the classification of kernels.
01.linux kernel
The kernel is the core of the operating system, which has many basic functions. It is responsible for managing the process, memory, device drivers, files and network system of the system, and determines the performance and stability of the system.
The Linux kernel consists of the following parts: memory management, process management, device driver, file system and network management.
System call interface: the SCI layer provides some mechanism to perform function calls from user space to the kernel. This interface depends on architecture, even within the same processor family. SCI is actually a very useful function call multiplexing and demultiplexing service. You can find the implementation of SCI in. / linux/kernel and the architecture-dependent parts in. / linux/arch.
02. Memory management
For any computer, its memory and other resources are limited. In order to make the limited physical memory meet the large memory demand of applications, Linux adopts a memory management method called "virtual memory". Linux divides memory into easy-to-handle "memory pages" (4KB for most architectures). Linux includes ways to manage available memory, as well as hardware mechanisms used for physical and virtual mapping.
But memory management doesn't just manage 4KB buffers. Linux provides abstractions for 4KB buffers, such as the slab allocator. This memory management model uses 4KB buffers as the cardinality, allocates structures from them, and tracks memory page usage, such as which pages are full, which pages are not fully used, and which pages are empty. This allows the mode to dynamically adjust memory usage according to system needs.
In order to support multiple users to use memory, there are sometimes situations where available memory is consumed. For this reason, pages can be moved out of memory and placed on disk. This process is called swapping because pages are swapped from memory to the hard disk.
03. Process management
A process is actually a running entity of a particular application. In a Linux system, multiple processes can be run at the same time, and Linux can realize "multitasking" by running these processes in turn in a short interval of time. This short time interval is called "time slice", the method of letting the process run in turn is called "process scheduling", and the program that completes the scheduling is called the scheduler.
Process scheduling controls the process's access to CPU. When you need to select the next process to run, it is up to the scheduler to select the process that is most worth running. A runnable process is actually a process that only waits for CPU resources, and if a process is waiting for other resources, it is not runnable. Linux uses a relatively simple priority-based process scheduling algorithm to select new processes.
Through the multitasking mechanism, each process can be regarded as monopolizing the computer, thus simplifying the writing of the program. Each process has its own separate address space and can only be accessed by this process, so that the operating system avoids mutual interference between processes and the harm that "bad" programs may cause to the system. In order to accomplish a particular task, it is sometimes necessary to combine the functions of two programs, such as one program outputs text and the other program sorts the text. To this end, the operating system also provides an inter-process communication mechanism to help accomplish such tasks. The common inter-process communication mechanisms in Linux are signals, pipes, shared memory, semaphores, sockets and so on.
The kernel provides an application programming interface (API) through SCI to create a new process (fork, exec, or Portable Operating System Interface [POS Ⅸ] function), stop processes (kill, exit), and communicate and synchronize between them (signal or POS Ⅸ mechanism).
04. File system
Individual file systems in Linux operating systems are not identified by drive letters or drive names (such as A: or C:, etc.). Instead, like the UNIX operating system, the Linux operating system combines independent file systems into a hierarchical tree structure that is represented by a single entity.
An important feature of the Linux operating system is that it supports many different types of file systems. The most commonly used file system in Linux is Ext4, which is also Linux's home-grown file system. However, Linux can also support different types of file systems, such as FAT, VFAT, FAT32, MINIX, etc., so that it can easily exchange data with other operating systems. Because Linux supports many different file systems and organizes them into a unified virtual file system.
Virtual file system (VirtualFileSystem,VFS): hides the specific details of various hardware, separates the file system operation from the specific implementation details of different file systems, and provides a unified interface for all devices. VFS provides dozens of different file systems. Virtual file system can be divided into logical file system and device driver. Logical file system refers to the file system supported by Linux, such as ext4,fat, and device driver refers to the device driver module written for each kind of hardware controller.
Virtual file system (VFS) is a very useful aspect of the Linux kernel because it provides a common interface abstraction for file systems. VFS provides a switching layer between SCI and the file systems supported by the kernel. That is, VFS provides a switching layer between the user and the file system.
VFS provides a switching layer between the user and the file system:
Above VFS is a generic API abstraction of functions such as open, close, read, and write. Below VFS is the file system abstraction, which defines how the upper-level functions are implemented. They are plug-ins for a given file system (more than 50). The source code for the file system can be found in. / linux/fs.
Below the file system layer is the buffer cache, which provides a common set of functions for the file system layer (independent of the specific file system). This cache layer optimizes access to physical devices by keeping the data for a period of time (or then reading the data in advance to be available when needed). Beneath the buffer cache is the device driver, which implements the interface to a specific physical device.
Therefore, users and processes do not need to know the file system type on which the files reside, but only need to use them like files in the Ext4 file system.
05. Device driver
Device drivers are the main part of the Linux kernel. Like other parts of the operating system, device drivers run in a highly privileged processor environment, so they can operate directly on the hardware, but because of this, any error in the device driver can lead to a crash of the operating system. The device driver actually controls the interaction between the operating system and hardware devices. The device driver provides a set of abstract interfaces that can be understood by the operating system to complete the interaction between the operating system and the operating system, while the specific operation details related to the hardware are completed by the device driver.
Generally speaking, the device driver is related to the control chip of the device. For example, if your computer's hard disk is a SCSI hard drive, you need to use a SCSI driver instead of an IDE driver.
06. Network Interface (NET)
It provides access to various network standards and support for all kinds of network hardware. Network interface can be divided into network protocol and network driver. The network protocol part is responsible for implementing every possible network transport protocol.
As we all know, TCP/IP is not only the standard protocol of Internet, but also the de facto industrial standard. The network implementation of Linux supports BSD sockets and all TCP/IP protocols. The network part of Linux kernel consists of BSD socket, network protocol layer and network device driver.
The network device driver is responsible for communicating with the hardware device, and every possible hardware device has a corresponding device driver.
After reading the above, have you mastered how to parse the kernel in the Linux system architecture? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.