All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] resume/suspend periodic timing issue
@ 2006-02-27 14:20 Steven Seeger
  2006-02-27 18:39 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 30+ messages in thread
From: Steven Seeger @ 2006-02-27 14:20 UTC (permalink / raw)
  To: xenomai@xenomai.org

I seem to have discovered a condition where if I have a thread in periodic
timing (system tick of 125000 ns) and my thread suspends itself based on
some condition, when I resume the thread later based on user input,
rt_task_wait_period() doesn't block until the thread has "caught up" with
where it should be. In other words, say I have a thread that is supposed to
run every 2 ms. I suspend it for 1 second, and then resume it.
rt_task_wait_period() will return immediately 50 times. This can be fixed by
calling rt_task_set_periodic() again after the thread's suspend call.

Is there any way around this?

Here is the thread in question: (2 ms period)

void meas_data::_meas_thread::task_func(void)
{
    meas_data::meas_update_data meas;
    const int display_hit = 25;
    
    int display_count=0;
        
    for(;;) {
        if(!motor->is_moving()) {
            meas.time = 0.0;
            display_count = 0;
            stop();
            set_period_ns(get_period_ns()); //fixes suspend/resume timing
        }
        else rt_task_wait_period();
        
        meas.force = motor->get_force();
        meas.lps = motor->get_linear();
        meas.sd = motor->get_limit_distal();
        meas.sp = motor->get_limit_proximal();
        meas.steps = motor->get_moved_steps();
        meas.time += 0.01;
        
/* log data to file */
        void *ptr = file_queue.alloc(sizeof(meas));
        assert(ptr);
        memcpy(ptr, &meas, sizeof(meas));
        file_queue.send(ptr, sizeof(meas));

/* display data on screen twice a second */
        if(++display_count>=display_hit) {
            display_count = 0;
            
            ptr = display_queue.alloc(sizeof(meas));
            assert(ptr);
            memcpy(ptr, &meas, sizeof(meas));
            display_queue.send(ptr, sizeof(meas));
        }
    }
}

When I resume the thread, I can see the data on the screen come in way too
fast until the thread "catches up." I have confirmed that it is
rt_task_wait_period() returning immediately.

Steven



^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2006-03-03 11:29 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-27 14:20 [Xenomai-help] resume/suspend periodic timing issue Steven Seeger
2006-02-27 18:39 ` Gilles Chanteperdrix
2006-02-28 13:45   ` Steven Seeger
2006-02-28 13:55     ` Gilles Chanteperdrix
2006-02-28 14:07       ` Steven Seeger
2006-02-28 14:21         ` Jan Kiszka
2006-02-28 14:24           ` Steven Seeger
2006-02-28 15:10             ` Philippe Gerum
2006-02-28 15:13               ` Steven Seeger
2006-02-28 15:27                 ` Jan Kiszka
2006-02-28 15:29                   ` Steven Seeger
2006-02-28 15:43                     ` Jan Kiszka
2006-02-28 15:46                       ` Steven Seeger
2006-02-28 16:01                         ` Jan Kiszka
2006-02-28 16:27                           ` Steven Seeger
2006-02-28 15:29                 ` Philippe Gerum
2006-02-28 15:31                   ` Steven Seeger
2006-02-28 16:20                     ` Philippe Gerum
2006-02-28 16:28                       ` Steven Seeger
2006-02-28 16:37                         ` Philippe Gerum
2006-02-28 17:24                           ` Steven Seeger
2006-02-28 17:53                             ` [Xenomai-core] rt_task_wait_period() and overruns Philippe Gerum
2006-02-28 18:02                               ` [Xenomai-core] Re: [Xenomai-help] " Philippe Gerum
2006-02-28 18:15                               ` Steven Seeger
2006-03-01 10:22                                 ` Philippe Gerum
2006-03-01 15:25                                   ` Dmitry Adamushko
2006-03-01 16:00                                     ` Philippe Gerum
2006-03-01 19:01                                       ` Dmitry Adamushko
2006-03-03 11:29                                         ` Philippe Gerum
2006-02-28 13:57     ` [Xenomai-help] resume/suspend periodic timing issue Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.