InitializeCriticalSection

InitializeCriticalSection initializes a critical section object.

Syntax

VOID InitializeCriticalSection(
    LPCRITICAL_SECTION lpCriticalSection
);

Parameters

lpCriticalSection

A pointer to the critical section object.

Return Value

This function does not return a value.

Remarks

The threads of a single process can use a critical section object for mutual-exclusion synchronization. The process is responsible for allocating the memory used by a critical section object, which it can do by declaring a variable of type CRITICAL_SECTION. Before using a critical section, some thread of the process must call InitializeCriticalSection to initialize the object.

Once a critical-section object has been initialized, the threads of the process can specify the object in EnterCriticalSection or LeaveCriticalSection to provide mutually exclusive access to a shared resource. For similar synchronization between the threads of different processes, use a mutex object.

A critical-section object cannot be moved or copied. The process must also not modify the object, but must treat it as logically opaque.

Requirements

Minimum Supported Version RTX64 2013
Header windows.h
Library Rtx_Rtss.lib

See Also:

TryEnterCriticalSection

DeleteCriticalSection

EnterCriticalSection

LeaveCriticalSection

RtCreateMutex