Linux Kernel re-import Analysis

Source: Internet
Author: User
Linux operating system kernel re-import analysis-general Linux technology-Linux programming and kernel information, the following is a detailed description. I did some analysis on Linux kernel re-import.

First, we need to define a range (code segment, function) before we can discuss re-import.

For example, use function A and function B as A range. When running A is interrupted, call B and B are finished and return A. B enters.

If A = B, then A re-enters A, or two instances of A are running.

The primary cause of the re-import is that these two A instances can access some of the heap variables almost simultaneously, causing inconsistency. There are several solutions to this problem:

Simply do not allow A function (A code segment) to be re-imported, that is, if A is running, when A is interrupted, call A and find that A is already running, return, no longer run this new. bottom half adopts this method.

Or lock some critical zones.

Or you can simply close the connection.

The first defined range of kernel re-entry is the entire kernel-level code segment.

Therefore, kernel re-entry can be said to occur frequently, such as when the interruption occurs.

There are two kernel reconnection situations:

1. When a process-independent interrupt occurs, the CPU is already running in the kernel, that is, the interrupt nesting. Generally, the Kernel performs some protection, such as Guanzhong disconnection and lock critical zones. However, this interruption is characterized by a later stack mode. Therefore, it is sufficient to use a stack.

2. process-related switchover. If the switch is always performed only when the kernel returns to the user-level code segment, the re-entry does not exist in this sense. You can use a kernel stack. Another possibility is to switch in the kernel. Because process execution is not in FIFO mode, each process has a kernel stack.

Another problem is that process-independent interruptions generally access data that is not related to the process, so there is less data to be protected. In this type of re-import, the kernel instances of several processes will access the common data related to the process, which may lead to inconsistency. In this case, there will be more critical areas, So locking may be troublesome, linux uses a non-transparent switch, that is, the kernel part of the current process must voluntarily give up the CPU to switch. In this way, kernel synchronization is relatively simple. Therefore, the Linux kernel should be reentrant under certain conditions, rather than preemptible.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.