Man I’m all wet now… Back to age 5 or below. Read the msdn document.
A SynchronizationEvent is also called an autoreset or autoclearing event. When such an event is set, a single waiting thread becomes eligible for execution. The kernel automatically resets the event to the not-signaled state each time a wait is satisfied. A driver might use a synchronization event to protect a shared resource that is used in synchronizing the operations of several threads. Synchronization events are rarely used in a typical driver.
If the above statement is true, then I’ve no idea how there can be no unserviced work item, I was trying to get to.
Once again, the producer can produce multiple consecutive work items, before any of the consumer gets a chance to serve. Now as per the document, it is going to make only one thread runable. I will find the first work item, and will compare the counter ( that is the remaining work item not yet served) with the NbOfConsumerThread. Since the counter is less than NbOfConsumerThread, it will exit out of processing only to go back to Wait ( at the top of the loop ). But now there is no more signaling the event from the producer …
So I’m still holding my claim – You will have work item put into the list by producer and not served…
Am I wrong ? Can anyone please find flaws in my logic???
-pro
On Dec 14, 2010, at 8:40 PM, Prokash Sinha wrote:
On Dec 14, 2010, at 5:11 PM, xxxxx@hotmail.com wrote:
>> Right, all of them would wake up, correct…
>
> Well, probably not all of them - after all, the number of outstanding items may be less that that of available workers…
>
It is possible that all the consumer threads are waiting for the event ( only one event object). Once the event is in signaled state. OS will satisfy all of them, meaning now they are runnable…
Example: at the start ( no work item), every consumer is waiting. Now let’s say just one work item posted by producer, and the event is in signal state. Every waiting thread will have their wait satisfied, right? So whoever get the spinlock first will get the work item, after that all the other threads will find no work item after getting hold of the spinlock. Now there is no work, and count < NbCustomerThreads, each one will go back to wait on the event object, then again one work item — this is “thundering herd”. As I said, it is for scalability. Perhaps I’ve been dealing with too many vCPUs 
-pro
>> And we know it has the same thundering herd,
>
> It depends on what you mean by “thundering herd”…
>
> What makes it different from Max’s approach is that there are no idle invocations - if thread gets released it can be 100% sure that it will find at least one item to process (although it may contend for a spinlock). In Max’s implementation, N threads wake up and contend for a spinlock…and N-1 of them may go back to sleep without having done anything useful. This is particularly true if the load is low. This is what I would call
> “thundering herd”. However, I don’t think this term applies to a situation when few workers may have to contend for a spinlock once in a while…
>
>
> Anton Bassov
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer