What are critical sections in threads

I read about mutecs, semaphores, and critical sections. I understand that a mutex synchronizes a resource, so that only one thread accesses it at a time when the semaphore allows a specific thread thread to access the resource, but what do critical sections do?

+5
source share
1 answer

Under normal use, a critical section is a section of code that must be executed sequentially - that is, only one thread can execute this code at any given time. You usually do this by protecting the code with a mutex semaphore.

Windows ( ), , (.. , , ).

. . , . Mutex , , , .

+13

All Articles