Solved

How would I go about using mulitple timer's efficiently?

Posted on 2007-11-23
6
196 Views
Last Modified: 2010-04-23
I am planning on using a Timer to "poll" an PCI card that controls two different axis of a machine. I need to have at LEAST one Timer constantly getting information from the PCI card to display any fault that the servos might run into. There are also times where I am going to need to have 2-3 more timers polling the PCI card for Inputs/Outputs that are currently on and other information that needs to be updated relatively quickly (I am shooting for <1 sec). Is there any good way to go about this? Or is have 3 or 4 timers (ticks at 1 sec) executing simultaneously not a problem?


Not sure if this matters, but I would assume it would have some effect: The program will be running on a new AMD 4000+ X2 Proc, XP pro, and 1 gig or memory.
0
Comment
Question by:Gssc1414
  • 3
  • 3
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20339990
would be more efficient a single timer with the proper granularity. But you have to notice that in this approach, will attend event sequentially, so if one event lasts more than 1 second, by example, another event can keep unattended for a while.
separate timers allows you to attend event virtually simultaneously, but this will depend also if your PCI card will not get confused with this.
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20340113
Would it be possible to use multi-threading? Maybe put each timer on it's own thread? Or even just the critical ones on a separate thread than that of the program? I don't know much about multi-threading, so im not sure if this is feasible, and if it is, if it would really help me out that much or not.



Jaime,

Thanks for your quick response!
I will have to check into the PCI card and make sure this won't be a problem.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340161
In fact you don't need to do multithreading explicity. Timers are multithreaded implicity.
Just create many timers and launch them. Each timer have it own Tick event that run in a separate thread.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 3

Author Comment

by:Gssc1414
ID: 20340179
Alright, good deal. One last one for ya! Can I explicitly set a priority to different timers?


P.S. I upped the point value because of your extremely fast and precise answers. I really appreciate the help!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340196
What do you want to do with a "priority timer" ?
Do some tasks sequentialy when timer collide? or do them in parallel with a differnent speed?

For first, I suggest a priority queue, for second use a regular thread an simulate a timer with an infinite loop with delay.

BTW, you have to check also if the API you are using to interface the PCI card will accept concurrency
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20347101
Very well. It looks like I am a little confused. I once again apologize for my lack of knowledge. I will take your advice and go with it.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question