Re: How many timers?



Martin wrote:
I have an app that runs in a real-time environment. Its ability to
respond in a timely manner to various events is critical (mostly data
coming in and going out via WinSockets and a lot of database access).

I currently have 25 different timers running for various purposes
(some running all the time - others being turned on and off as
needed). I have a need to add 40 more timers to this app (20 would be
running constantly - the other 20 would be on only a small % of the
time).

What effect will this many timers have on the responsiveness of the
program? Do timers consume much in the way of resources?

FWIW, I've sort-of figured out a way to do what I need to do with only
2 timers (instead of 40) but I'm having a lot of trouble getting it to
work properly - thus my question.

Neither VB nor Win32 are realtime in the traditional sense, so if it's 'critical' that your app has real-time response you should consider another platform. If near-realtime is close enough, and if you can deal with an occasional missed tick, then VB might do the trick.

I don't think you actually consume system timer resources when you add VB timers to your app -- IIRC, all timers on a form are backed by a single system timer.

For that and other reasons, the usual advice is to use one timer and dispatch different activities based on the current tick count. You're less likely to be affected by a missed tick, for example.

Also be aware that _Timer ticks are not accumulated: if your _Timer sub, or something it dispatches, is still active when another tick comes along, that tick will just be discarded.

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com
.



Relevant Pages

  • Re: posix-cpu-timers revamp
    ... Where "interesting tick" means "tick in which a process timer has ... The thread CPU timers track the thread CPU clocks, ... The process CPU timers track the process CPU clocks. ...
    (Linux-Kernel)
  • Re: posix-cpu-timers revamp
    ... Where "interesting tick" means "tick in which a process timer has ... and the versions in the task struct for the thread-only timers. ... place) any timers it might have will never expire. ...
    (Linux-Kernel)
  • Re: [Bugme-new] [Bug 9906] New: Weird hang with NPTL and SIGPROF.
    ... were to provide cumulative totals that are updated on every tick, ... When a cumulative total is on hand in the tick handler, ... clock accumulators and the timers' expiry times. ...
    (Linux-Kernel)
  • Re: [PATCH] Dynamic tick, version 050127-1
    ... I was wondering how Windows handles high res timers, ... how do they implement 1ms timers with a 10ms tick rate? ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Variable timer tick rate?
    ... If there are no upcoming timeouts, ... > decrease the tick rate. ... tick, high-resolution timers would be a neat thing to have, and it ...
    (freebsd-arch)