Multi-Threading has been a short board, sorting out the relevant knowledge to facilitate inquiries
Critical area (Critical section)
A critical section is a piece of code that is accessed exclusively by threads. At any point, if a thread is accessing the snippet, all other threads that are trying to access it will be suspended until the thread that is accessed leaves the snippet to enter, ensuring thread safety. applies to control data access . Because of its thread ownership, it can be used for inter-thread mutexes and cannot be used for synchronization.
Related functions
InitializeCriticalSection Initializing critical section objects
void WINAPI initializecriticalsection ( _out_ lpcritical_section lpcriticalsection);
EnterCriticalSection Waiting for critical section object ownership
void WINAPI entercriticalsection ( _inout_ lpcritical_section lpcriticalsection);
LeaveCriticalSection Releasing a critical section object ownership
void WINAPI leavecriticalsection ( _inout_ lpcritical_section lpcriticalsection);
Note: After entercriticalsection execution, it must be ensured that the matching leavecriticalsection can be executed, otherwise the shared resources protected by the critical section will never be freed.
DeleteCriticalSection Destroying critical Area objects
void WINAPI deletecriticalsection ( _inout_ lpcritical_section lpcriticalsection);
Critical section criticalsection of multi-threaded correlation------