About Linux kernel architecture [turn]

1.Linux kernel Introduction

Let us now from a higher height to look at architecture GNU / Linux operating system. You can choose from two levels up to consider the operating system, as shown in Figure 1.

The basic architecture of FIG 1. GNU / Linux operating system

At the top is the user (or application) space. This is where the user application execution. Under the user space is the kernel space, Linux kernel it is located here.

GNU C Library (glibc) is here. It provides the connection kernel system call interface, also provides a mechanism for conversion between user space and kernel applications. This is important, because the application kernel and user space using different protected address space. Each user space process uses its own virtual address space, the kernel occupies a single address space.

Linux kernel can be further divided into 3 layers. The top is the system call interface, which implements some basic functions such as read and write. Under the system call interface is the kernel code can be more accurately defined as the architecture-independent kernel code. These codes are all processor architectures supported by Linux are generic. Under these codes is dependent on the architecture of the code, commonly referred to as constituting a part of BSP (Board Support Package) is. The code of these codes is used as the platform for a given specific processor architecture.

In the Linux kernel, including:

  • Process management (process management)
  • Timer (timer)
  • Management Interrupt (interrupt management)
  • Memory management (memory management)
  • Management module (module management)
  • Virtual file system interface (VFS layer)
  • File system (file system)
  • Device driver (device driver)
  • Interprocess communication (inter-process communication)
  • Network management (network management)
  • The system starts to realize (system init) and other operating system functions.

2.Linux major subsystems of the kernel

Now use Figure 2 illustrates the classification of the major components of the Linux kernel.

Figure 2 a perspective view of a system configuration of the Linux kernel

What is the kernel?

Kernel is actually just a resource manager. Regardless of managed resources processes, memory or hardware, the kernel is responsible for managing and ruled that multiple competing users access to resources (both kernel space also includes user space)

System call interface

SCI layer provides a mechanism to perform certain function calls from user space to kernel. As discussed earlier, this interface depends on the architecture, even in the same processor family. SCI is actually a very useful function call multiplexing and demultiplexing service. You can find in ./linux/kernel achieve SCI and find the architecture-dependent part in ./linux/arch in. For more information about this component can be found in the Resources section.

Process Management

Process management is focused on the implementation process. In the kernel, the process is called a thread, represents a separate processor virtualization (threaded code, data, stack and CPU registers). In user space, usually use the term process, but Linux implementation does not distinguish between these two concepts (processes and threads). The kernel provides an application programming interface (API) through the SCI to create a new process (fork, exec, or Portable Operating System Interface [POSIX] functions), stop the process (kill, exit), and communicate and synchronize between them (signal, or POSIX mechanisms).

Process Manager also includes shared between the CPU's processing needs of active processes. Kernel implements a novel scheduling algorithm, no matter how many threads, this algorithm can operate in a competitive CPU within a fixed time. This algorithm is called the O (1) scheduler, the name it indicates scheduled time using a plurality of threads and scheduling time a thread used is the same. O (1) scheduler may also support multiple processors (or referred to as a symmetric multi-processor SMP). You can find the process management sources in ./linux/kernel can be found depends on the architecture of the source code ./linux/arch. In the Resources section to learn more about this algorithm.

Memory Management

Another important resource is managed by the kernel memory. For efficiency, if the virtual memory hardware management, memory is managed (for most architectures for both 4KB) in accordance with the so-called page mode memory. Linux includes management of available memory, and the way physical and virtual hardware mapping mechanism used.

But memory management may want to manage more than 4KB buffer. Linux provides an abstraction of 4KB buffers, such as slab allocator. This mode uses 4KB buffer memory management as the base, and then from the distribution structure, and track usage of memory pages, such as which pages are full of memory, which is not fully use the page, which page is blank. This allows the model needs to be adjusted dynamically according to system memory usage.

To support multiple users use the memory, where the available memory is consumed light sometimes occurs. For this reason, the page can be removed and placed in memory disk. This process is called exchange, because the pages are swapped from memory to the hard disk. Memory management source code can be found in ./linux/mm in.

Virtual File System

Virtual File System (VFS) in the Linux kernel is a very useful one aspect, because it provides a common interface abstraction for file systems. VFS provides a switching layer (see Figure 3) between the SCI and the file system supported by the kernel.

FIG 3. VFS between the user and the file system provides a switching layer

In the top of the VFS is an abstraction of a common API, such as open, close, read and write functions and the like. Here is the VFS file system abstraction, which defines the implementation of the upper functions. They are given file system (over 50) of the plug-ins. File system source code can be found in ./linux/fs in.

Under the file system layer is the buffer cache, it provides a common set of functions (independent of the specific file system) is a file system layer. The buffer layer is formed by a data retention period (or pre-read data then you need to be so can be used) to optimize the access to the physical device. Under the buffer cache is a device driver that implements the interface for the particular physical device.

Network Stack

Network stack follows a layered architecture simulation in the design of the protocol itself. Recall, Internet Protocol (IP) is a transport protocol (commonly referred to as the Transmission Control Protocol, or TCP) below the core network layer protocol. TCP socket layer above is that it is invoked by SCI.

socket layer is the network subsystem standard API, which provides a user interface for a variety of network protocols. Access from the original frames to IP protocol data units (PDUs), then TCP and User Datagram Protocol (UDP), socket layer provides a standardized way to manage connections and move data between each endpoint. Kernel source code can be found in the network in ./linux/net.

Device Drivers

Linux kernel code in a large number of device drivers that can run a particular hardware device. Linux source tree provides a drivers subdirectory, the directory further divided into a variety of support equipment, such as Bluetooth, I2C, serial and so on. Code device drivers can be found in ./linux/drivers in.

Code is architecture-dependent

Although Linux is largely independent of the architecture it is running, but some elements of the architecture must be considered in order to operate properly and achieve greater efficiency. ./linux/arch subdirectory defined architecture-dependent portions of the source code of the kernel, which contains various architecture-specific subdirectory (together form BSP). For a typical desktop system, using the i386 directory. Each architecture subdirectory contains many other subdirectories, each will focus on a particular aspect of the kernel, such as boot, kernel, memory management. The architecture-dependent code can be found in the ./linux/arch.

From: http: //www.xxlinux.com/linux/article/development/kernel/20091126/17756.html

Reproduced in: https: //www.cnblogs.com/moiyer/archive/2010/04/19/1952679.html

Guess you like

Origin blog.csdn.net/weixin_34343689/article/details/94693049