Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the Win32 CRITICAL_SECTION contain?

What data does the Win32 CRITICAL_SECTION contain, and how big is it?

This is undocumented and presumably implementation specific, but I'm curious to know

like image 944
Daniel Fortunov Avatar asked Feb 26 '10 13:02

Daniel Fortunov


2 Answers

This is from my installation of Windows Vista SDK:

WinNT.h:

typedef struct _RTL_CRITICAL_SECTION {
    PRTL_CRITICAL_SECTION_DEBUG DebugInfo;

    //
    //  The following three fields control entering and exiting the critical
    //  section for the resource
    //

    LONG LockCount;
    LONG RecursionCount;
    HANDLE OwningThread;        // from the thread's ClientId->UniqueThread
    HANDLE LockSemaphore;
    ULONG_PTR SpinCount;        // force size on 64-bit systems when packed
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;

WinBase.h:

typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
like image 191
Rômulo Ceccon Avatar answered Sep 28 '22 08:09

Rômulo Ceccon


Why don't you check the headers files?
Check out WINNT.H and see what you'll find out :)

(assuming that you have Windows C++ files)

Usually the structure contains:

LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
HANDLE LockSemaphore;
DWORD SpinCount;

Edit: a command like sizeof(CRITICAL_SECTION) will reveal the size.

like image 21
Nick Dandoulakis Avatar answered Sep 28 '22 06:09

Nick Dandoulakis