From - Fri Sep 26 07:32:03 1997 Date: Thu, 25 Sep 1997 14:23:18 -0500 Message-ID: <342ABA26.1F0E@pac.sc.ti.com> From: "Joe N. Turner" Subject: Re: [Q] Can multiple processes wait on Event signaled from kernel-mode? Organization: Texas Instruments Lines: 85 References: <01bcc875$d69eee40$86adb9cd@matt-s-pc.motu.com> Reply-To: jturner@pac.sc.ti.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 3.0 (WinNT; I) Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode,microsoft.public.win32.programmer.kernel Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news.aa.ans.net!uppssnewspub03.moswest.msn.net!uppssnewspub05.moswest.msn.net!EFGSTL.EFG.com!cheech.primary.net!news-kc-17.sprintlink.net!news-east.sprintlink.net!news-dc-26.sprintlink.net!news-peer.sprintlink.net!news.sprintlink.net!Sprint!cpk-news-hub1.bbnplanet.com!atl-news-feed1.bbnplanet.com!news.bbnplanet.com!news.ti.com!not-for-mail Xref: news.mitre.org comp.os.ms-windows.programmer.nt.kernel-mode:3725 microsoft.public.win32.programmer.kernel:736 Matt Arnold wrote: > > Hi there, > > If arrange for N processes to call CreateEvent(), specifying a name, they > will all basically get a handle to the same Event object, right? > Yes. > Can these N processes all call WaitForSingleObject() and begin waiting for > my one "global" Event, perhaps all at the same time? And, when I signal > the Event with SetEvent() or PulseEvent(), will all the blocked threads (in > all the processes waiting for the Event) begin pre-emptively executing > according to their respective priorities? > > Is there a limit to the number N? > > Finally, if all the answer to all the above questions is "Certainly, sir!", > will there be any trouble signaling the Event from kernel-mode using > ObReferenceObjectByHandle() and KeSetEvent()? > > Regards, > Matt > Yes, it sounds like you are new to the Win32 synchronization objects (from the kernel stand point). Here is a brief overview of the synchronization objects as I have come to know and love them (Please forgive me if I restate the obvious): All of the Win32-visible synchronization objects (and a few extras) are implemented at the kernel level. These “Dispatcher Objects” include: * spinlocks * mutexes * mutants (referred to as a mutex at the Win32 API level) * events * critical sections * Semaphores * Timers At the user level, you are allowed to manipulate them via API calls like CreateEvent, OpenEvent, WaitForSingleObject, PulseEvent, ResetEvent, etc. Mutex, semaphore, events, critical sections... are all visible to the user mode applications through the Win32 API. Manual Reset Event (referred to as a NotificationEvent in the DDK documentation). A manual reset event is an event which must be manually reset. A good example of this think of the manual reset event as an fire alarm in a hotel. Most everyone is sleeping (waiting for the event, or for the timeout to expire (morning!)) When the event signals, everyone is woken up and released. It will keep sounding until it is turned off (by the fire department). Any new people (threads) who wander in to get some sleep (WaitForSingleObject) are immediately released until the fire alarm is turned off (reset or cleared). More technically stated: you have N threads waiting in an efficient wait state for an event to become signaled. When this event becomes signaled, all threads are woken up and released. The event stays signaled until explicitly reset KeResetEvent or ResetEvent (kernel and win32 api functions, respectively). Automatic Reset Event (referred to as a SynchronizationEvent in the DDK documentation). This is basically the same as the manual reset event, with one exception: the first thread that is activated resets the event to a non-signaled state (i.e., many threads can wait, but only one thread is “notified” and woken up. All others continue to wait until the event becomes signaled again...). [ Sorry, but I can’t think of a cheezy example at the moment ]. Look at the async example in the DDK to see how to create a manual-reset event at the kernel level and wait on it from a user mode program. This will at least give you some direction. Good Luck. -- Joe N. Turner Texas Instruments http://www.ti.com/ jturner@pac.sc.ti.com 13020 Floyd Road guardian@engineer.com Dallas, TX 80301 http://www.cauce.org/ PGP Fingerprint: D2B6 CFF4 8351 7E85 6CC7 5326 E555 E7E7 88CB FD32