This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: periodic threads with kapi?
On Sun, Aug 17, 2003 at 07:43:16PM +0100, Bart Veer wrote:
> >>>>> "Ryan" == Ryan Boder <icanoop@bitwiser.org> writes:
>
> Ryan> Is there a clean way to do periodic threads with absolute
> Ryan> timing, as opposed to the relative timing you get with
> Ryan> cyg_thread_delay()?
>
> This should be easy enough using something like:
>
> void
> my_thread_delay_absolute(cyg_tick_count_t abs_time)
> {
> cyg_tick_count_t delay = abs_time - cyg_current_time();
> if (delay > 0) {
> cyg_thread_delay(delay);
> }
> }
>
> There is a possible problem if the current thread gets descheduled
> between the cyg_current_time() and cyg_thread_delay() calls, causing
> the thread to get delayed for longer than intended. You could avoid
> that by e.g. temporarily boosting the current thread's priority.
The problem still exists doing it that way. In fact that would even make it
worse.
The point is that I don't want to read the current time each period in my
thread. That causes drift.
I looked at the source code and I think it will be easy to add a correct
cyg_thread_absolute_delay(cyg_tick_count_t abs_time) to the kernel API. I
will be happy to write up a patch for it if the maintainers would consider
applying it.
--
Ryan Boder
http://www.bitwiser.org/icanoop
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss