Article Title: Linux kernel algorithms. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Linux Scheduling
I/O-consuming and processor-consuming processes (to ensure timely IO response and efficient CPU utilization) Load Balancing: Each CPU has a process queue, the load balancing program is run when the load difference between the CPU and the CPU is greater than 25%. (Take the process with the highest priority and the least CPU affinity from the busiest CPU to the CPU process queue with the least load ).
Why the process with the highest priority?
The high-priority processes are evenly allocated to each CPU so that the system performance can reach the highest level. CPU affinity: this is mainly because of high-speed cache or other reasons. For example, a process can only run on a CPU.
2. The difference between the interrupt handler and the thread.
1. Do not sleep during interruption.
2. the interrupt context has a strict time limit because it interrupts the running thread.
3. the interrupt processing program does not have its own stack. It shares the stack of the interrupted thread. Therefore, when assigning a task stack, pay attention to a larger value than the actual requirement to prevent interruption, an overflow occurs when the program is interrupted to use the stack.
3. spin lock: The main feature, unlike waiting for a semaphore, is that the process does not sleep when the desired resource is not available.
4. Introduce the read/write spin lock. Read/write spin locks reduce the granularity of locks.
5. slab layer: optimizes the dynamic memory allocation (allocate and release dynamic memory of the same size in a continuous memory zone, so that no memory fragments are generated, because each allocation happens to be a unit, each release happens to be a unit, for example, it is used in the dynamic allocation and release of process control blocks ).
6. Disk block I/O operations: the Linux elevator algorithm is used to sort disk block I/O requests by track during disk underlying operations to reduce the head tracing time and optimize disk I/O operations.
7. Use Page cache and page write-back to optimize the file system.