Can multi-threads wait for a same event? Thread1-3 call KeWaitForSingleObject to wait the same event, thread 4 will call KeSetEvent to set the event signal, then, If the thread1-3 can be wake up at the same time?
Yes if it is a notification event. Once signaled, a notification event remains signaled until explicitly cleared. A synchronization event on the other hand will only wake up one thread and reset back to a clear state once a wait has been satisfied (and in your scenario, it is not defined which thread 1-3 will actually wake up with a sync event)
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com.cn
Sent: Thursday, April 08, 2010 10:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can multi-threads wait for a same event?
Can multi-threads wait for a same event? Thread1-3 call KeWaitForSingleObject to wait the same event, thread 4 will call KeSetEvent to set the event signal, then, If the thread1-3 can be wake up at the same time?
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
Thanks Doron Holan! It seems I need use the notification event.
As you said,it is a notification event, the thread1-3 will be wake up when thread4 signal the event.
Thread should set the event to be non-signal manually if the it is notification event(event will be set to non-signal automatically if call KeWaitForSingleObject again if it is synchronization event ).
Now, three threads share the same notification event,if the event that per-thread uses will be no-signal only one thread set it to no-signal?
I do not understand your question
d
tiny phone keyboard + fat thumbs = you do the muth
-----Original Message-----
From: xxxxx@yahoo.com.cn
Sent: Friday, April 09, 2010 12:18 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Can multi-threads wait for a same event?
As you said,it is a notification event, the thread1-3 will be wake up when thread4 signal the event.
Thread should set the event to be non-signal manually if the it is notification event(event will be set to non-signal automatically if call KeWaitForSingleObject again if it is synchronization event ).
Now, three threads share the same notification event,if the event that per-thread uses will be no-signal only one thread set it to no-signal?
—
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
"Now, three threads share the same notification event,if the event that per-thread uses will be no-signal only one thread set it to no-signal? "
That depends?on your logic.?All it?says is the notification event will remain signaled until someone clears it. So you may have multiple threads clear it multiple times. If that leads to a race?condition, you will need to?utlize?other?synchronization??primitives in combination with the syhncronization event.
Lijun
From: “xxxxx@yahoo.com.cn”
To: Windows System Software Devs Interest List
Sent: Fri, April 9, 2010 3:17:50 AM
Subject: RE:[ntdev] Can multi-threads wait for a same event?
As you said,it is a notification event, the thread1-3 will be wake up when thread4 signal the event.
Thread should set the event to be non-signal manually if the it is notification event(event will be set to non-signal automatically if call KeWaitForSingleObject again if it is synchronization event ).
Now, three threads share the same notification event,if the event that per-thread uses will be no-signal only one thread set it to no-signal?
—
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
xxxxx@yahoo.com.cn wrote:
As you said,it is a notification event, the thread1-3 will be wake up when thread4 signal the event.
Thread should set the event to be non-signal manually if the it is notification event(event will be set to non-signal automatically if call KeWaitForSingleObject again if it is synchronization event ).
Yes.
Now, three threads share the same notification event,if the event that per-thread uses will be no-signal only one thread set it to no-signal?
Kernel events are not per-thread. They are global. If one thread
clears the event, then the event becomes non-signaled, and the next
thread to wait on it will block.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
> Can multi-threads wait for a same event? Thread1-3 call KeWaitForSingleObject to wait the same
event, thread 4 will call KeSetEvent to set the event signal, then, If the thread1-3 can be wake up at the
same time?
For NotificationEvent, all 3 threads are awaken, and will run sooner or later. The event remains signaled.
For SynchronizationEvent, only 1 of the threads is awaken, and the event remains unsignaled.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com