Linux process preemption

Source: Internet
Author: User
The preemptible linux process is accompanied by the execution of schedule. The kernel provides a TIF_NEED_RESCHED flag to indicate whether schedule () is used for scheduling once. The preemption can be divided into user preemption and kernel preemption based on the preemption time. User preemption occurs when the kernel is about to return to the user space ....
The preemptible linux process is accompanied by the execution of schedule. The kernel provides a TIF_NEED_RESCHED flag to indicate whether schedule () is used for scheduling once. The preemption can be divided into user preemption and kernel preemption based on the preemption time. User preemption occurs when the kernel is about to return to the user space. Kernel preemption occurs when the kernel space is returned. Www.2cto.com 1. user preemption: When the kernel is about to return to the user space, check whether the process has set the TIF_NEED_RESCHED flag. If this flag is set, user preemption will occur. User preemption: when the system calls or interrupts the processing program to return to the user space. 2. kernel preemption: in a kernel that does not support kernel preemption, if the kernel process does not stop itself, it will continue to run. Unable to respond to real-time processes. Although preemptible kernel sacrifices the overhead of context switching, it obtains a larger throughput and response time. 2.6 kernel added kernel preemption, and added spin locks for some places not to be preemptible. In the thread_info structure of the process, the value of preempt_count is 0. when the process uses a spin lock, 1 is added. when a spin lock is released, 1 is reduced. if the value is 0, the kernel can be preemptible. Kernel preemption Time: 1. when the interrupt handler returns the kernel space, the kernel checks the preempt_count and TIF_NEED_RESCHED flags. if the process sets the TIF_NEED_RESCHED flag and the preempt_count is 0, kernel preemption occurs. 2. when the kernel is used for preemption again, when all the spin locks of the process are released, the release program checks the TIF_NEED_RESCHED flag. if it is set, schedule is called. 3. display when schedule is called 4. when the process in the kernel is blocked.
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.