title: Is Critical Section always faster?
body: <p>I was debugging a multi-threaded application and found the internal structure of <code>CRITICAL_SECTION</code>. I found data member <code>LockSemaphore</code> of CRITICAL_SECTION an interesting one. </p>
  
  <p>It looks like <code>LockSemaphore</code> is an auto-reset event (not a semaphore as the name suggests) and operating system creates this event silently when first time a thread waits on <code>Critcal Section</code> which is locked by some other thread. </p>
  
  <p>Now, I am wondering is Critical Section always faster? Event is a kernel object and each Critical section object is associated with event object then how <code>Critical Section</code> can be faster compared to other kernel objects like Mutex? Also, how does internal event object actually affects the performance of Critical section ? </p>
  
  <p>Here is the structure of the <code>CRITICAL_SECTION</code>:</p>
  
  <pre><code>struct RTL_CRITICAL_SECTION
  {
      PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
      LONG LockCount;
      LONG RecursionCount;
      HANDLE OwningThread;
      HANDLE LockSemaphore;
      ULONG_PTR SpinCount;
  };
  </code></pre>