Differences between inter-process switching and thread switching

Source: Internet
Author: User

Process switching in two steps 1. Switch the page directory to use the new address space
2. Switch between the kernel stack and the hardware context.

For Linux, the most important difference between threads and processes is the address space.
For thread switching, the 1th step is not required, and the 2nd is the process and thread switching. So obviously process switching costs a lot


One of the main differences between thread context switching and process context switching is that the switching of virtual memory space for threads is still the same, but process switching is different. The processing of both context switches is done through the operating system kernel. The most significant performance loss associated with this switching process of the kernel is to switch the contents of the register out.

Another hidden loss is that context switching disrupts the processor's caching mechanism. Simply put, once the context is switched, all memory addresses that have been cached in the processor are invalidated for a moment. Another notable difference is that when you change the virtual memory space, the processed page table buffers (processor ' s translation lookaside buffer (TLB)) or the equivalent of the God horse thing will be all refreshed, This will cause memory access to be quite inefficient over time. However, this problem does not occur during thread switching.

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.