Operating System-process/thread internal communication-Critical Zone (Critical Regions), system-regions

Source: Internet
Author: User

Operating System-process/thread internal communication-Critical Zone (Critical Regions), system-regions

The previous article described the competition conditions between processes: multiple processes enter a shared area at the same time, resulting in data inconsistency. This article mainly describes how to solve this problem.

I. Introduction to critical section

To solve this problem, multiple processes are prevented from entering the shared area at the same time. In other words, processes need to Exclusion the shared area ). The root cause of the problem is that process B enters the shared area before process A returns from the shared area.

In most cases, variables are not shared between two processes. Shared variables are only used in some steps. In program design, you can design the shared variable access program separately, this part of the program is called the Critical Regions ). If the two processes always have only one process entering this critical area, the conditional competition between processes will be solved.

The following conditions are required to achieve the above results:

  • No two processes enter the critical zone at the same time
  • No requirement on CPU speed or quantity
  • Processes that are waiting outside the critical area Block other processes. For example, if process A is in the critical area, process B accesses the critical area, process B will be blocked outside the critical section. At this time, process B should not Block other processes.
  • No process will be permanently blocked out of the critical section.
Ii. critical section demonstration



  • Process A enters the critical area at T1.
  • T2 time, Process B tries to enter the critical area
  • Because A is in the critical area, B is Block
  • T3 time A leaves the critical area, and B enters the critical area time
  • T4 time, B leaves the critical area

What are the benefits of using the concept of critical area?

  • If process A and process B do not use shared resources for most of the time, process A and process B can be executed in parallel during this time.
  • Only access to critical areas can be parallel.
  • Allows processes to work in parallel and efficiently use shared data.
Iii. Summary
  • Abstract Critical Area
  • Exclusive to critical areas
  • How can song achieve exclusive? The next article will introduce you.

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.