Kernel and operating system:
Kernel is the core part of the operating system, including the core process of the system operation, determine the performance of the system, the operating system boot kernel is loaded into RAM;
The operating system interacts with the underlying hardware device and provides an execution environment for running the application.
Linux kernel vs. microkernel comparison:
Microkernel: The kernel requires only a small set of functions, usually consisting of several synchronization primitives, a simple scheduler, and interprocess communication mechanisms.
Several system processes running on the microkernel implement system-level functionality: Memory allocation, device drivers ... Fully modular process. Any action
The system layer is a stand-alone program module that uses a modular approach to define clearly defined software interfaces to interact with other layers. The kernel does not need to execute
System processes can be recalled or revoked. Micro-cores are easy to port and make full use of RAM, but overhead efficiency is a problem.
Macro kernel: Linux kernel: Single block structure. All of the kernel's code, including all subsystems (such as memory management, file systems, device drivers)
are packaged into a single file. Each function in the kernel can access all the other parts of the kernel. Module features are dependent on the design between the kernel and the user layer
Sophisticated communication methods, which enable hot-swappable and dynamic loading of modules.
Each kernel layer is inherited to the entire kernel program and represents the current process running in the kernel state.
Modular (non-process)-Allows for dynamic installation in a running state. A module is a target file whose code is linked to the kernel at runtime or unlinked from the kernel.
The target code is usually a set of functions that are used to implement file systems, drivers ... These modules, like other statically linked kernel functions, represent the current process
In a kernel state, a direct function call avoids the overhead of a process switching message delivery, which can be more efficient.
Linux User Program two states:
User state and kernel State, user state switch to kernel state:
L Process System call
L CPU exception
L Interrupt
L kernel thread is executed
Multi-User system:
An application that can execute multiple users concurrently and independently, and each user has a separate space. User group, root user.
Linux Process:
Process processes:
L Basic abstraction of the operating system.
The process is an instance of the execution of a program, and the execution context of a running program.
L Several processes can execute the same program concurrently, while the same process can execute several programs sequentially.
L has a separate address space, and multiple processes can execute concurrently.
Processes are managed by the kernel; Each process is represented by a process descriptor that contains the current state information for the process.
When the kernel pauses the execution of a process, it stores the contents of several related processor registers in the process descriptor. These registers include:
L Program counter PC and stack pointer SP Register
L Universal Register
L Float Register
L Processing control register containing CPU status information
L Track memory Management Register of process access to RAM
When the kernel resumes executing the process: the appropriate field in the process descriptor is loaded in the CPU register, and the program counter points to where the program executes.
Linux To re-enter the kernel:
The kernel can be re-entered:
reentrant functions: Using local variables
Implement synchronization mechanism: Semaphore, lock, off interrupt
Process Execution state switching: process transitions between user and kernel state, Linux is preemptive kernel
Process address space: each process runs in a seemingly address space
Synchronization and Critical sections: kernel data manipulation access.
interprocess communication IPC: Semaphore, Message queue, shared memory
Process management: Fork and _exit,exec (), child process and parent process
Linux File System:
A file system is a mechanism for organizing data and metadata on a storage device, organized in a tree-shaped structure.
File type: the
Different files
Directory
Symbolic Links
Block-oriented device files (device-driven related)
Character-oriented device files (device-driven related)
Piping (pipe) and named pipes (named pipe) (interprocess communication related)
Socket (inter-process communication related)
File access permissions and Access modes
File descriptors and Index nodes: Records information data for a file.
System calls to file operations: Open, read, write ...
Memory Management:
Virtual Memory: The logical layer between the application memory request and the hardware deposit element.
Access memory RAM: Part for kernel image, remaining virtual memory processing
Kernel memory Allocator: KMA handles memory request subsystem
L Fast Speed
l Reduce memory waste
• Reduce Memory fragmentation
L Cooperation with other memory management (page box)
L Memory allocation algorithm
Process virtual Space Address processing: the virtual address space allocated to the process by the kernel consists of the following memory areas:
L Executable code of the program
L Initialization data of the program
L Program Uninitialized data
L initialize the stack of programs
L Required executable code and data for shared libraries
L Memory heap for program dynamic requests
Cache:
Device drivers:
The kernel interacts with the I/O device through the device driver and the device driver is inside the kernel, and the user program accesses the device through the core.
Notes Linux kernel Learning (one) inside nuclear introduction