Hi,

In RTLinux 3.0pre6 the function usleep is now present in rti_sched.c. I
was wondering what, if any, troubles there would be by the addition of a
nanosleep function (see code based on usleep).  It seems like there
might be a hardware related resolution problem (ticks ?) or something
else (time spent creating the new thread ?) that would make this
approach a bad idea since the times could be much smaller than in
usleep.

just changed the line
        th->resume_time = gethrtime() + HRT_FROM_NS(interval * 1000);
to
        th->resume_time = gethrtime() + HRT_FROM_NS(interval);

int nanosleep (nanoseconds_t interval)
{
        rtl_irqstate_t flags;
        pthread_t th = pthread_self();
        hrtime_t save_resume_time;

        rtl_no_interrupts (flags);
        save_resume_time = th->resume_time;

        th->resume_time = gethrtime() + HRT_FROM_NS(interval);
        th->state = RTL_THREAD_DELAYED;
        rtl_schedule_cancelable();

        th->resume_time = save_resume_time;
        rtl_restore_interrupts (flags);
        return 0;
}

Thanks,
Paul


-- [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/

Reply via email to