Kernel and operating system:
The kernel is the core part of the operating system. It includes the core process of the system operation, which determines the system performance. The operating system starts the kernel and is loaded into RAM;
Operating system interaction and running applications with underlying hardware devicesProgramProvides an execution environment.
Comparison between Linux kernel and micro kernel:
Microkernel: The kernel only needs a small function set, usually including several synchronization primitives, a simple scheduler and inter-process communication mechanism.
Several system processes running on the microkernel implement system-level functions: memory allocation, device drivers ...... Completely modular process. Any operation
The system layer is an independent program module,Define clear software interfaces to interact with other layers through modular methods. The kernel does not need to be executed.
The system process can be called up or canceled.The microkernel is easy to port and make full use of RAM, but high overhead efficiency is a problem.
Macro Kernel:Linux Kernel: Single block structure. All KernelCode, Including all subsystems (such as memory management, file systems, device drivers)
Are packaged into a file. Each function in the kernel can access all other parts of the kernel. The module features depend on the design between the kernel and the user layer.
Sophisticated communication methods, which enable hot swapping and dynamic loading of modules.
Each kernel layer is inherited into the entire kernel program and represents the current process running in the kernel state.
Modularization (non-process)-allows dynamic installation in the running state. A module is a target file whose code is linked to or unbound from the kernel during runtime.
Target codeIs a group of functions used to implement file systems, drivers ...... These modules, like other static link kernel functions, representCurrent Process
When executed in kernel mode, direct function calls avoid overhead of process switching message passing, which may be more efficient.
LinuxThe user program has two statuses:
User and kernel; Switch to kernel:
L Process System Call
L CPU exception
L interrupt
L The kernel thread is executed.
Multi-user system:
Applications of multiple users can be executed concurrently and independently. each user has independent space. User Group, root user.
LinuxProcess:
Process:
L basic abstraction of the operating system.
L a process is an instance when the program is executed; the execution context of a running program.
L several processes can execute the same program concurrently, while the same process can execute several programs in sequence.
L it has an independent address space. Multiple processes can be executed simultaneously.
Processes are managed by the kernel. Each process is represented by a process descriptor, which contains the current state information of the process.
When the kernel suspends the execution of a process, the content of several processor registers is stored in the process descriptor. These registers include:
L program counter PC and stack pointer SP register
L General registers
L floating point register
L processing control register containing CPU status information
L memory management registers used by the tracing process to Access RAM
When the kernel resumes the execution process, it installs the appropriate fields in the process descriptor in the CPU register and points to the place where the program is executed according to the program counter.
LinuxRe-import the kernel:
Reentrant to the kernel:
Reentrant function: use local variables
Synchronization Mechanism: semaphores, locks, and Guanzhong disconnections
Process Execution status switching: The process switches between user and kernel states. Linux is a preemptible kernel.
Process address space: each process runs in a seemingly address space
Synchronization and critical section: kernel data operation access.
Inter-process communication IPC: semaphore, message queue, and shared memory
Process Management: fork and _ exit, exec (), child process and parent process
LinuxFile System:
A file system organizes data and metadata on storage devices in a tree structure.
File Type:
Different files
Directory
Symbolic Link
Block-based device files (related to device drivers)
Character-oriented device files (device drivers)
Pipe and named pipe (inter-process communication)
Socket (inter-process communication)
File Access permission and Access Mode
File descriptor and index node: records the information and data of a file.
File Operation System Call: open, read, write ......
Memory Management:
Virtual Memory: the logical layer between application memory requests and hardware memory units.
Access the Memory RAM: some of them are used for Kernel images and other virtual memory processing.
Kernel memory distributor: KMA processes memory request Subsystem
L fast
L reduce memory waste
L reduce memory fragments
L cooperation with other memory management (page)
L Memory AllocationAlgorithm
Process Virtual space address processing: the virtual address space allocated to the process by the kernel is composed of the following memory areas:
LExecutable code of the program
L program initialization data
L program uninitialized data
L initialize the program Stack
L executable code and data of the required shared library
L memory heap requested by the program dynamically
Cache:
Device Driver:
The kernel interacts with the I/O device through the device driver. The device driver is in the kernel and the user program accesses the device through the kernel.