cyclic thread with speicifc time interval
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: cyclic thread with speicifc time interval

  1. #1
    Join Date
    Apr 2014
    Posts
    1

    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

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,265

    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.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,762

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center