Originally Posted by
richardforc
3. Why mutex initialization creating new handle?
Because that's how you interact with kernel objects on Windows. If you're asking why you get a handle rather than a mutex object to interact with then lookup the benefits of Handle-Body idiom or pimpl which equates to the same thing.
Why critical section initialization not creating events?
It does
Code:
// from 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;
typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
The LockSemaphore member is an event that is waited on if the lock is held by another thread. For more information: Critical sections under Windows