cyclic thread with speicifc time interval
It's the first time that I use codeguruand I hope that I get my question answered here :)
I have a robotcell with 4 robots in it. a A so called "update thread" (I hope you kow know what I mean) reads after a specific interval e.g. 1000 ms the coordinates of the roboters and puts them in a data structure.
Finally we have a thread for each robot (so 4) threads (again each have different read interval times) which read the coordinates and calculate the trajectory. I have to use win32api functions.
I have never done anything with time intervals in C++, so can anybody show me examples how to do that?
i have a threadbase class (with start and stop functions) and a critical section class.
but i need an idea how to "poll" the threads with an specific time interval.
i've read something ith createwaitabletimer, but I'm not sure if I#m on the right way.
Best regards
naruto90
Re: cyclic thread with speicifc time interval
You might find this of interest re waitable timers
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
together with its links.
Re: cyclic thread with speicifc time interval
note that waitable timers are NOT precise. you'll get "more or less" the interval you wanted, but it can be less and can be substantially more.
if you need things to be actually time coordinated, you'll need quite a bit more scaffolding work to get something like that going in Windows. Windows isn't an RTOS, and getting any kind of hard timing guarantees is tricky.
why do you need 5 threads for this ? It seems entirely doable to do this on a single thread with either a regular WM_TIMER (if timing isn't critical) or on a multimedia timer if it's semi critical.