[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-rt
Subject:    Re: [rtl] Periodic /oneshot modes & usleep(), nanosleep()
From:       "Norm Dresner" <ndrez () att ! net>
Date:       2002-06-30 14:13:00
[Download RAW message or body]

My error.  The normal kernel's usleep() is a busy-wait loop -- and IIRC it
also was in RTLinux 1.0 -- but this is clearly not.

One alternative to multiple wait loops is to create a periodic task whose
period is the wait-time.  Waking a periodic task and having it suspend
itself until the next period are relatively cheap (in CPU resources)
operations.  Also, I've never tried it but it looks like
pthread_suspend_np() might actually suspend the invocation of even a
periodic thread until it's restarted with the wake-up function.  [If not,
this would be a very, very useful thing to have in a future version.]

    Norm


----- Original Message -----
From: Marc Le Douarain <mavati@club-internet.fr>
To: <rtl@rtlinux.org>
Sent: Sunday, June 30, 2002 8:03 AM
Subject: Re: [rtl] Periodic /oneshot modes & usleep(), nanosleep()


> Hello,
> First thanks, for your response.
>
> >First, don't use usleep() unless it's absolutely necessary for more
> >than a very small number of microseconds. It's a busy-wait loop that
> >doesn't give up the CPU. Find some other way to trigger a task.
>
> Are you sure usleep() is a busy-wait loop (so not freeing time for others
> tasks) ?
> I've take a look at the rtl_sched.c, where I don't understand all
really...
> but it seems that the functions pthread_wait_np() and usleep() have
nearly
> the same code, except of course for the value of timeout... so why
usleep()
> would be a busy-wait loop?
>
>
> In my application, One of the tasks, is a periodic task driving a LCD
display
> for menus. It is a periodic task (500ms). But when at the end I'm copying
the
> display buffer to the LCD, when copying the caracters, I have to wait a
> BusyFlag between each. And in this wait-loop it could be interesting to
> insert a usleep() to free time for others tasks with less priority,
instead
> of waiting and eating all the CPU time stupidly...
>
> Kind regards.
> ---
>    Marc Le Douarain
>    "mavati@club-internet.fr"
>    http://www.multimania.com/mavati
>
>
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail majordomo@rtlinux.org OR
> echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.org
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
>

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail majordomo@rtlinux.org OR
echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.org
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic