

Critical section refers to what shared variables are accessed in concurrent processes
The critical section refers to the program segment that accesses shared variables in concurrent processes. A critical section refers to a program fragment that accesses shared resources, and these shared resources cannot be accessed by multiple threads at the same time. Only one process is allowed to enter the critical section at a time, and other processes are not allowed to enter after entering.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
The critical section refers to the program segment that accesses shared variables in concurrent processes.
Introduction to Critical Sections
A critical section refers to a program fragment that accesses shared resources (such as shared devices or shared memory), and these shared Resources cannot be accessed by multiple threads at the same time. When a thread enters a critical section, other threads or processes must wait (for example: bounded waiting waiting method). Some synchronization mechanisms must be implemented at the entry and exit points of the critical section to ensure that these shared resources are used. Mutex is used, for example: semaphore. Devices that can only be accessed by a single thread, such as printers.
The section of code in each process that accesses critical resources is called the critical section (critical resources are shared resources that are only allowed to be used by one process at a time). Only one process is allowed to enter the critical section at a time, and other processes are not allowed to enter after entering. Whether it is a hardware critical resource or a software critical resource, multiple processes must access it mutually.
Critical sections involving the same critical resource in multiple processes are called related critical sections. .
The scheduling principle for processes entering the critical section is:
1. If there are several processes requesting to enter the idle critical section, only one process is allowed to enter at a time.
2. At any time, there cannot be more than one process in the critical section. If a process has entered its own critical section, all other processes trying to enter the critical section must wait.
3. The process entering the critical section must exit within a limited time so that other processes can enter their critical section in time.
4. If the process cannot enter its own critical section, it should give up the CPU to avoid the "busy waiting" phenomenon of the process.
Related recommendations: "Programming Video"
The above is the detailed content of Critical section refers to what shared variables are accessed in concurrent processes. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











1. Ao3 mirror URL Quark☜☜☜☜☜☜☜☜ Click to enter. 2. Ao3 mirror address quark entrance ☜☜☜☜☜☜☜ Click to enter. 3. AO3 (Archives Our Own) is a non-profit fan and fan-fiction archive website launched on October 29, 2008. 4. AO3 is a website founded by fans and run by fans, dedicated to protecting the works created by fans and providing a censorship-free environment for fan novel writers.

1. Ao3 official website quark entrance☜☜☜☜☜☜Click to save. 2. Ao3 Quark entrance official website☜☜☜☜☜☜☜Click to save. 【ao3】1. AO3 (Archive of Our Own) is a huge online archive website created by fans. 2. It mainly contains fan works, covering a wide variety of media, from books and movies to TV series and games, almost everything is included. 3. AO3 has rich content and diverse types, which can meet the needs of different readers.