What does Win32 CRITICAL_SECTION contain?

What data contains Win32 CRITICAL_SECTION and how important is it?

This is an undocumented and supposedly specific performance, but I'm curious to know

+4
source share
3 answers

This is from my installation of the 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 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; 
+5
source

Why don't you check the header files?
Check out WINNT.H and find out what you learn :)

(assuming you have Windows C ++ files)

Typically, a structure contains:

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

Edit: a command of type sizeof(CRITICAL_SECTION) will show the size.

+4
source

Here you can find a detailed description of the CRITICAL_SECTION structure in this MSDN journal article:

Break without blocking code in critical sections in Windows


Update: the link above does not work. Here is the Archive.org link that is currently working.

+1
source

Source: https://habr.com/ru/post/1302487/


All Articles