components of the Linux system
Kernel + root file system from the operational state point of view
From a static point of view, partitioning the disk partition + related files
Kernel call
The first way: The calling kernel is too complex, so some kernel developers create library files to invoke the kernel program by calling the library file. Then the shell is the user interface (user program) that invokes the library
The second way: The program developer is very bull B, he wrote the program to invoke the kernel program directly in order to pursue efficiency.
Kernel design Genre
1. Single Core Design
Integrate all functions with the same program. Easy to use, but a function out of the problem will affect the entire program. Linux is an example
2, micro-core design
Each feature is implemented using a separate subsystem. Management is more complex, but the effect of each function is small. But the compatibility between the various cores is troublesome. Windows Solaris is an example
Linux kernel Features
1, support Modular,. KO (Kernel object)
2. Support the dynamic State or uninstallation of the modular runtime
Linux kernel composition
Core files
Vmlinuz-3.10.0-693xxxx is the kernel file.
Module files
This is the corresponding kernel module file, if the administrator installed more than one kernel version, then in this directory there will be more than one module file
This is the content in the module file.
In the kernel directory, there are some files that the system must have, such as some driver files
RAMDisk file (optional)
Now assume that the kernel program is already in memory (how to load the first not discussed), then the first thing in the kernel is to load the root file system (loading the init file, open various processes), loading the root file system needs to hang in the partition, mount the partition requires hard disk drive, hard drive in the root file system. This contradicts the simple case that mounting the root filesystem needs to be driven, and the drive is in the root file system.
What to do? Using a portion of the memory as a disk, there is a pseudo-root file system that mounts the actual root partition and reads the init file. When the real root filesystem is online, the pseudo-root file system fails. This pseudo-root file system is the first time the operating system is installed, the system is generated according to the actual disk.
Pseudo file system is not required under certain conditions, if the kernel is compiled to know the actual disk drive, then you can directly compile the disk drive into the kernel.
This is the RAMDisk file, before CentOS6 the file is initrd file, the CentOS6 is converted to RAMDisk file, because the disk to memory must have a cache, but the actual data in memory, do not need buffer.
Functions implemented by the kernel
1. Process Management
Process scheduling
Creation of processes
Process Destruction
2. Memory Management
interprocess communication is referred to as IPC, communication mechanism is 1, Message Queue 2, Semerphor 3, SHM (Shared memory)
Socket is a mechanism for two host interprocess communication
3. Network protocol stack
Communication between the various host processes requires a network protocol, and this common service needs to be implemented in the kernel.
4. File system
The system environment in operation is divided into two tiers: 1, kernel space 2, user space
Various applications are running in the user space
Kernel code is running in kernel space, and this code generally requires privileged operation.
Then, if the user's application needs to use hardware resources, the code of the user space calls the kernel space code, and the kernel completes the hardware resource operation.
5. Driver
6. Safety function
boot partition (/boot)
The storage space used to store kernel code. There is no root file system before the kernel program is started, and the root file system is not recognized until the kernel is booted. Recommended boot partition with normal partition
Root file System (ROOTFS)
Must conform to the FHS structure (specific directory structure, such as containing/bin/sbin/proc) and other directories. Where the init file is the most important file, because Init is the parent process that initiates other processes, all processes originate from the Init
So the root file system is just a name, the root filesystem itself does not exist, if a filesystem structure conforms to the FHS structure, and contains a specific directory, then this file system is called the root file system. (in the experiment of installing grub on the second hard disk of this machine and doing a brief execution of the command, this phenomenon is very obvious, in the root file system, only the corresponding directory, each directory does not have a corresponding file, but still can run the system.) )
Now there is a burning brain problem, the kernel code in the/boot directory, only the kernel boot to identify the root (in short, the use of the kernel requires a root file system, but hanging in the root filesystem requires the kernel), then when booting the system, how to find the/boot directory? So you need a program to put kernel code into memory before the kernel program starts.
Basic concepts of the startup process of the Linux kernel