thread synchronization mechanism

Now the popular control mechanism of process thread synchronization and mutual exclusion is actually realized by the most primitive and basic four methods (critical section, mutex, semaphore, event).

1) Critical section : Access common resources or a piece of code through serialization of multiple threads, which is fast and suitable for controlling data access.

2) Mutex : It is designed to coordinate individual access to a shared resource. Only threads with a mutex have permission to access the public resources of the system. Because there is only one mutex, it can ensure that the resource will not be accessed at the same time. Access by multiple threads. Mutual exclusion can not only realize the safe sharing of common resources of the same application, but also realize the safe sharing of common resources of different applications.

3) Semaphore : designed to control a resource with a limited number of users. It allows multiple threads to access the same resource at the same time, but generally needs to limit the maximum number of threads that access this resource at the same time.

4) Event : used to notify the thread that some events have occurred, thus starting the start of subsequent tasks.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324812025&siteId=291194637