Export (0) Print
Expand All
2 out of 3 rated this helpful - Rate this topic

InitializeCriticalSection

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function initializes a critical section object.


void InitializeCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection
);
lpCriticalSection

[in] Pointer to the critical section object.

The threads of a single process can use a critical section object for mutual-exclusion synchronization. Although there is no guarantee about the order in which threads will obtain ownership of the critical section, the system will process ownership requests from all threads.

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 the InitializeCriticalSection function to initialize the object.

Once a critical section object has been initialized, the threads of the process can specify the object in the EnterCriticalSection or LeaveCriticalSection function 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. Use only the critical section functions provided by the Microsoft Win32® API to manage critical section objects.

In low-memory situations, InitializeCriticalSection can raise a STATUS_NO_MEMORY exception.

Each object type, such as memory maps, semaphores, events, message queues, mutexes, and watchdog timers, has its own separate namespace. Empty strings, "", are handled as named objects. On Windows desktop-based platforms, synchronization objects all share the same namespace.

Headerwinbase.h
LibraryCoremain.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.