Re: Periodic Time Triggering!
From: Paul G. Tobey [eMVP] (ptobey_no_spam_at_instrument_no_spam.com)
Date: 03/01/04
- Next message: Paul G. Tobey [eMVP]: "Re: Memory leakage in Iphlpapi-Function GetRTTAndHopCount ?"
- Previous message: Paul G. Tobey [eMVP]: "Re: Problems with CreateThread and WaitForSingleObject."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Mar 2004 09:26:52 -0700
You're all worried about something that *might* happen. Just code it and
*see* if it really is too many threads or not. If the threads are generally
suspended, most of them are using *zero* processor time, anyway.
Paul T.
"Ali" <it2kaal@ituniv.se> wrote in message
news:eF4PQFd$DHA.1036@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Interesting thougt, but I can't see any difference between this solution
> and the one suggested by Paul G. Tobey. Both of them has the
> problem of meeting deadline (i.e. the frequency for each kind of query).
>
> If I understand you correctly, you suggestion is to create one thread
> with a loop (which can be true until Total time of the periodic request
> has ellapsed) and switch block which will check the current elapsed
> time and then try to find out which of the cases in the switch block needs
> to make the query. Do the work for that case, and then move on.
>
> Here the problem is similar to the one using timers.
> 1) Compare ellapsed time with the frequency of X
> 2) X needs to query
> 3) The operation might last more than 500 ms.
> 4) During this time some other queries (e.g. Y, Z) should have been
> triggered, but this is not possible because the thread (which is the only
> one handling all the queries) is busy with X.
>
> After some time different queries might miss deadline too many times.
> This is not desirable!
>
> The best solution would be to use a thread for each kind of query for
> being able to meet the deadline, but the problem here is that there
> might be too many threads at the same time!
>
> What a dilemma! :(
>
> Regards
> /Ali
>
>
>
> <r_z_aret@pen_fact.com> wrote in message
> news:14gv30hf7kecca4scdng5g10ut2mh4h8hl@4ax.com...
> > My initial response was to write a function for each fetch/response,
> > and have each act as the timer func for its own timer. I think that
> > means you would effectively create a separate thread for each event,
> > but only as needed.
> >
> > But it and Paul G. Tobey's solution are both vulnerable to a concern
> > you raised: too many threads running at once.
> >
> > So I then came up with the idea of having one thread, with a
> > continuous loop. It would service _all_ fetch/request events, so only
> > one would be handled at a time. For each loop, a switch block (or
> > analog) would trigger appropriate code for one event. The challenge is
> > keeping track of events that occur while one is being processed; that
> > means setting priorities, deciding what to do with multiple events of
> > one type, and probably more I haven't considered. I definitely have
> > _not_ figured out details.
> >
> >
> > On Wed, 25 Feb 2004 18:47:36 +0100, "Ali" <it2kaal@ituniv.se> wrote:
> >
> > >Hi,
> > >
> > >I need to fetch/request for data in a periodic manner from an external
> > >resource.
> > >There can be up to 4 different type of reqeusts. Each request can have
1
> to
> > >20
> > >different type of queries to sent to this externa resource. Let say
that
> for
> > >the moment
> > >there are 6 queries for each type of reqeust that should be logged
during
> 10
> > >minutes.
> > >Each of these has it own request frequency during this time, e.g. nr1
> needs
> > >to request
> > >for data each 500ms during 10 minutes, nr2 needs to request for data
each
> > >1000ms
> > >during 10 minutes, etc. Each request should be able to request for
data
> at
> > >the
> > >specified freqeuncy.
> > >
> > >What would be the proper way to implement this kind of request?
> > >Maybe creating a new thread for each request (that gives us 4 threads)
> and
> > >then for each
> > >query create a Timer which will hold track of frequency. When timer is
> > >"triggered", it is time
> > >to fetch/request for data from the external resource. Is this the
proper
> way
> > >to go?
> > >I might meet some problems using Timers. How many timers can I create
on
> > >PPC2002/wince 3.0?
> > >If I would have the above given scenario, then there would be a need
for
> lot
> > >of Timers!
> > >
> > >Hopefully someone can shed some light on my problem.
> > >
> > >Regards
> > >/Ali
> > >
> >
> > -----------------------------------------
> > To reply to me, remove the underscores (_) from my email address (and
> please indicate which newsgroup and message).
> >
> > Robert E. Zaret, eMVP
> > PenFact, Inc.
> > 500 Harrison Ave., Suite 3R
> > Boston, MA 02118
> > www.penfact.com
>
>
- Next message: Paul G. Tobey [eMVP]: "Re: Memory leakage in Iphlpapi-Function GetRTTAndHopCount ?"
- Previous message: Paul G. Tobey [eMVP]: "Re: Problems with CreateThread and WaitForSingleObject."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|