Home  >  Article  >  Operation and Maintenance  >  What are the five major modules of the Linux kernel?

What are the five major modules of the Linux kernel?

王林
王林forward
2020-09-29 16:18:443894browse

What are the five major modules of the Linux kernel?

1. Process scheduling module

(Recommended tutorial: linux tutorial)

Linux uses processes as system resource allocation The basic unit adopts a dynamic priority process advanced algorithm to ensure the rationality of each process using the processor. The process scheduling module mainly manages and controls the processor used by the process.

[Process Creation]:

When programming in the Linux environment, the fork()/vfork() function is generally used (fork is to create a child process and copy the memory data of the parent process to In the child process; vfork creates a child process and uses it with the memory data share of the parent process) to create a new process. Of course, that is a function in user space. It will call the clone() system call in the kernel. The clone() function continues to call do_fork() to complete the process creation.

fork()/vfork()/_clone--->clone()--->do_fork()--->copy_process()

[Process Cancellation]:

After the process terminates, the kernel needs to be notified so that the kernel can release the resources owned by the process, including memory, open files and other resources, such as semaphores. The general way to terminate a process is to call the exit() library function, which releases the resources allocated by the C function library, executes each function registered by the programmer, and ends the system call that reclaims the process from the system.

[Process Switching]:

Process switching is also called task switching and context switching. It is the behavior where, in order to control the execution of a process, the kernel suspends the process currently running on the CPU and resumes the execution of some previously suspended process.

In essence, each process switch consists of two parts:

Switch the page global directory to install a new address space; switch the kernel mode stack and hardware context, because the hardware context provides All the information needed by the kernel to execute the new process, including CPU registers, is mainly completed by the switch_to() function.

[Process Scheduling]:

In modern Linux, the scheduling algorithm can select a process to run within a fixed time (independent of the number of runnable processes). First of all, we must know that processes can be divided into real-time processes and ordinary processes. Each LInux process is always scheduled according to the following scheduling types: first-in-first-out real-time process, time slice rotation real-time process, and ordinary time-sharing process. Scheduling algorithms differ significantly depending on whether the process is a normal process or a real-time process.

2. Inter-process communication module

Inter-process communication is mainly used to control synchronization, data sharing and exchange between different processes in user space. Since different user processes have different process spaces, communication between processes must be achieved with the help of kernel relay. Normally, a process is suspended while it is waiting for a hardware operation to complete. When the hardware operation is completed, the process is resumed, and what coordinates this process is the inter-process communication mechanism.

The inter-process communication module ensures that Linux supports a variety of inter-process communication mechanisms, including pipes, named pipes, message queues, semaphores, and shared memory.

3. Memory management module

Linux’s memory management module uses an advanced virtual storage mechanism to realize storage management of multiple processes. It provides very reliable storage protection measures and grants different permissions to processes. Users cannot directly access the system's programs and data, ensuring the security of the system. At the same time, each user process is assigned an independent virtual address space.

4. File system module

Linux’s file system module uses advanced virtual file system (VFS) technology to shield the differences between various file systems and provide a better way to handle various file systems. Provides a unified interface and supports more than 90 different physical file systems. At the same time, Linux treats various hardware devices as special files and manages the devices in the same way as files, which is very convenient and effective.

5. Network interface module

Linux has the most powerful network functions. The network interface module implements network communication between computers through the socket mechanism, and uses the network layer model to provide support for multiple network protocols and network hardware devices.

The network interface provides implementation of various network standards and support for various network hardware. Network interfaces are generally divided into network protocols and network drivers. The network protocol part is responsible for implementing every possible network transport protocol. Network device drivers are mainly responsible for communicating with hardware devices. Every possible network hardware device has a corresponding device driver.

The above is the detailed content of What are the five major modules of the Linux kernel?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete