|
-
August 25th, 2004, 09:37 AM
#1
Timer
Hello,
I have an EXE COM object that has a worker thread. This object must schedule some actions and for that it uses another thread and a WaitableTimer object. The problem I am facing is the following:
1º) When the worker thread is not created, the "timer" thread works just fine, with the intervals being respected correctly (with acceptable error margins);
2º) When the worker thread is created and is performing its job, the "timer" thread does not respect small intervals anymore (values below 250ms).
I have tried to use SetThreadPriority() and SetPriorityClass() APIs (TIME CRITICAL and REALTIME), but the results were exactly the same... My opinion is: scheduling of threads inside the process is interfering in my "timer" thread.
Does anyone know how to solve this? I can use other ideas for timing issues, but they must be precise ones.
Thanks in advance,
Wagner
-
August 25th, 2004, 10:50 AM
#2
Re: Timer
What kinds of intervals are you talking about here? Windows is not a realtime OS, so you are not going to be able to get really precise times while some thread is working.
Viggy
-
August 25th, 2004, 03:18 PM
#3
Re: Timer
Hello,
I will need 10ms intervals... The problem is the following:
1º) When there is only the "timer" thread working, I got 14~15ms intervals (that is acceptable);
2º) When I start another thread (working thread), this value goes up to 124ms.
This 124ms interval seems to be fixed for intervals < 150ms, that is why I think it is a problem of thread scheduling.
Thanks,
Wagner
-
August 25th, 2004, 03:45 PM
#4
Re: Timer
Right. It's also a consequence of using a non-realtime os. I don't think it's possible for you to get the resolution that you want. 10ms is short. Very short. Check out this discussion of quantums:
http://www.codeguru.com/forum/showth...hlight=quantum
You can't completely control the OS in terms of what threads get run, and at what times. Even when you set your thread to "realtime" priority, other threads will get some (little) CPU time. When that happens, all your time critical code goes to pot.
Viggy
-
August 26th, 2004, 10:40 AM
#5
Re: Timer
Thanks for the help... I will try to use something else! If I find, I will let you know!!!
Thanks again,
Wagner
-
August 27th, 2004, 01:51 PM
#6
Re: Timer
We have found that under WIndows NT/2000 you can get 50 ms most of the time, 20 ms generally but the computer needs to be properly setup. Under pure Windows you can expect delays > 1000 ms from time to time!
You can look at the embedded Windows systems for better contol or try Venture COM's RTX for Windows, you can get sub ms level response.
RTX runs your real-time code under Windows, it is hard real-time, but it allows you to mix Windows with hard real time.
RTX Home page
Last edited by CJ1; August 27th, 2004 at 01:54 PM.
-
August 27th, 2004, 03:01 PM
#7
Re: Timer
Thanks for the help... I have downloaded the evaluation RTX and I will try to use it!!!
Thanks again,
Wagner
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|