INtime SDK Help
EnterCriticalSection (iwin32)
INtime SDK v6 > About INtime > Alternate APIs > iwin32 API > iwin32 API > EnterCriticalSection (iwin32)

Waits for a critical section to be free and then owns it. There is no timeout (see also TryEnterCriticalSection).

VOID EnterCriticalSection(
    LPCRITICAL_SECTION lpCriticalSection
);

Parameters

lpCriticalSection
Pointer to the critical section object.

Remarks

You cannot call this function from a pure INtime thread.

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

To enable mutually exclusive access to a shared resource, each thread calls EnterCriticalSection to request ownership of the critical section before executing any section of code that accesses the protected resource. EnterCriticalSection blocks until the thread can take ownership of the critical section. When it finishes executing the protected code, the thread uses LeaveCriticalSection to relinquish ownership, enabling another thread to become owner and access the protected resource. The thread must call LeaveCriticalSection once for each time it entered the critical section. The thread enters the critical section each time EnterCriticalSection succeeds.

After a thread owns a critical section, it can make additional calls to EnterCriticalSection without blocking its execution. This prevents a thread from deadlocking itself while waiting for a critical section it already owns.

Any process thread can use DeleteCriticalSection to release the system resources allocated when the critical section object was initialized. After calling this function, the critical section object cannot be used for synchronization.

If a thread terminates while it owns a critical section, the critical section's state is undefined.

If a critical section is deleted while still owned, the state of threads waiting for ownership of the deleted critical section is undefined.

If multiple threads call EnterCriticalSection and the critical section is currently owned by a different thread, the highest priority thread among the calling threads gets the critical section first after the current thread leaves the critical section. If all calling threads have the same priority, a first-in, first-out (FIFO) basis is used after the current thread leaves the critical section.

Return Values

None.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/winbase.h windows.h iwin32.lib

Note

This function operates in the real-time portion of your application.

See Also

DeleteCriticalSection, InitializeCriticalSection, LeaveCriticalSection, TryEnterCriticalSection, iwin32 API, iwin32 Overview