On Sun, 26 Mar 2000, Edgar Hilton wrote:
> I need to mark tasks for execution at a later time. For example, at the
> completion of task A, I want to tell the scheduler to release task A for
> exeecution in exactly X microseconds. Here, X is a number which I don't
> necessarily know a priori, but will be determined on the fly.
>
> Does anybody have suggestions as to how I might be able to accomplish
> this using the RTLv2.0 API? I have considered using the
> "pthread_make_periodic" for one solution. A second solution might be to
> have the 8254 generate an interrupt which calls some interrupt service
> routine. Unfortunately, this seems to be a recurring requirement in
> several control and rotor dynamics applications that I encounter, so I
> don't see any way around this.
Yes, I agree this is very common requirement.
Using v1.2 API I have defined:
/* this really belongs to rtl_sched.c */
extern void rtl_schedule(void);
/* t_us is expressed in RT ticks, not us */
int rt_task_delay(RTIME t_us)
{
long interrupt_state;
rtl_no_interrupts (interrupt_state);
rtl_current->state = RT_TASK_DELAYED;
rtl_current->resume_time += t_us;
rtl_schedule();
rtl_restore_interrupts (interrupt_state);
return 0;
}
I think you should have no problem with porting it to 2.0. You should use it
instead of ..._wait_np function. If you want to measure time from "now", not
from when the task was last triggered use something like:
rtl_current->resume_time = rt_get_time() + my_delay;
I am not sure how well it will work in RTLv2.0.
--
Tomek
-- [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/