Re: msgwaitformultipleobjects - loosing events ( i.e SetEvent - no eff
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Thu, 12 Jul 2007 17:50:43 -0700
Don't confuse kernel events with Windows messages. They
are completely unrelated.
I suspect you have a bug in your code and erroneously reset
your event after you finish processing (perhaps in a different
section of your code). The fact your event is manual reset, when
it most likley needs to be auto reset, is a strong red flag pointing
towards my hypothesis.
The other issue is you have a race condition. I strongly suggest
you switch to using auto reset events and never reset them
manually.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"arun_msdn" <arun_msdn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA83CC5B-F69A-409A-903A-1D98B4A24997@xxxxxxxxxxxxxxxx
Hello,
I use msgwaitformultipleobjects to wait on a couple of events - triggered
by SetEvent
(manual reset events) & a 3 sec. timer ( using SetTimer). The timeout for
msgwaitformultipleobjects is 1 sec as well.
Thread type used is a worker thread.
I am seeing an unique behavior whereby if I have a blocking call while
processing one of the events
(requests off a STL msg. queue), in order to ensure that I dont hold up
the
thread, I process only certain # requests, then issue a ResetEvent &
SetEvent
so that I can process the rest later.
The problem I'm facing is the SetEvent that I issue seems to be dropped on
the floor since I never
get the event trigger through msgwaitformultipleobjects.
My guess is during the time I block on processing the incoming requests,
the timer events probably
fill up the maximum allowed limit of windows message/event queue for the
thread and hence drops any of
the newer requests.
Questions :
1. How can I find whats the maximum queue size per worker thread (windows
queue size per thread ) using which msgwaitformultipleobjects dispatches
events/windows messages ?
after which it will discard new SetEvents & other queueing of
events/messages.
Is there anyway to configure this ?
2. When can a (Worker) Thread loose messages and or events in general
while
dispatching through MsgWaitForMultipleObjects ?
I can think of some blocking call causing this effect due to the thread
technically becoming a (sort of) slow consumer.
In my case, this is what I think is happening.
Too many events into the msg. Q. (sort of fast producer).
Are there any other reasons ?
3. Can you point me to any resources that discusses the internals of how
MsgWaitForMultipleObjects works ?
4. Finally currently I use SetTimer to create timer events. This creates
the issue of the internal windows timer implementation
queueing up timer events while the thread is blocked processing
requests.
Is there a way either using SetTimer or some other call whereby I can
request a once only timer ?
This will help in not queueing up a whole lot of timers in the threads
queue.
I can request another timer event once I process the first one.
Any pointers to the above questions will really help.
Thanks,
Arun
.
- References:
- Prev by Date: Re: TCP server stop receiving new connections
- Next by Date: Re: What is better Blocking Sockets or Async?
- Previous by thread: Re: msgwaitformultipleobjects - loosing events ( i.e SetEvent - no eff
- Next by thread: Re: Question on WinInet, NTLM authentication and IPV6
- Index(es):
Relevant Pages
|