title: Does a thread waiting on Windows Events need to get scheduled on CPU to wake up from sleeping?
body: <p>It is best to describe my question in an example:</p>
  
  <ol>
  <li>We create a Windows Event handle by CreateEvent, with manualReset as FALSE.</li>
  <li>We create 4 threads. Ensure that they all start running and waiting on the above event by WaitForSingleObject.</li>
  <li><p>In the main thread, in a for loop, we signal this event 4 times, by SetEvent. such as:</p>
  
  <p>for (int i = 0; i &lt; 4; ++i) ::SetEvent(event);</p></li>
  </ol>
  
  <p>My question is, can we say that all these 4 threads will certainly be waken up from waiting on this event?</p>
  
  <p>According to my understanding of Windows Event, the answer is YES. Because when the event is set, there is always a thread waiting for it.</p>
  
  <p>However, I read on MSDN that "<em>Setting an event that is already set has no effect</em>". Since the waiting threads probably do not get a chance to run while main thread setting event in the loop. Can they still be notified and reset the event to nonsignaled? If the event is not reset, the following SetEvent in the loop is obviously useless.</p>
  
  <p>Or the OS kernel knows which thread should be notified when an event is set, and reset this event immediately if there is a waiting thread. So the waiting thread does not need to be schedule to reset the event to nonsignaled?</p>
  
  <p>Any clarification or references are welcome. Thanks.</p>