Richard Teltz wrote:
> On Thu, 22 Oct 1998, Tommy Thorn wrote:
>
> > Hi all,
> >
> > while looking for a solution to controlling a servo directly under
> > Linux, I came across RT Linux. While at first I thought it looked
> > ideal, I was truly surprised to discover that there seems to be no
> > wait to let threads sleep for an arbitrary period, as opposed to a
> > fixed like with the make_periodic call.
> An easy way to do this is with semaphores. Have a periodic task
> keep time and release semaphores to the waiting task. Have the
> target task wait on the semaphore to sleep. A simple API can set
> wake up times, etc. The overhead for the semaphores is usually very
> low.
Too many task switches for nothing. A lot of jitter can be added and
that's not good for the PWMing Tommy wants to implement.
> There is a semaphore module for RTL at the following URL:
>
> http://stereotaxis.wustl.edu/~jerry/
It is in the official RTL distribution now.
I suggest that the friends at NMT include the following, untested, in
rtl_sched.c
void rt_task_sleep_until(RTIME time)
{
int flags;
r_save_flags(flags);
r_cli();
rtl_current->state = RT_TASK_DELAYED;
rtl_current->resume_time = time;
rt_schedule();
r_restore_flags(flags);
}
void rt_task_sleep(RTIME delay)
{
int flags;
r_save_flags(flags);
r_cli();
rtl_current->state = RT_TASK_DELAYED;
rtl_current->resume_time = rt_get_time() + delay;
rt_schedule();
r_restore_flags(flags);
}
That should work immediately as it does just what is already done for
waiting for a period.
Ciao, Paolo.
--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/