mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* udelay and nanosleep questions
@ 2002-09-21 11:23 Jos Hulzink
  2002-09-21 11:35 ` Russell King
  2002-09-22  3:51 ` george anzinger
  0 siblings, 2 replies; 3+ messages in thread
From: Jos Hulzink @ 2002-09-21 11:23 UTC (permalink / raw)
  To: Linux Kernel Development

Hi,

Talking about kernel driver programming:

1) Can I rely on udelay(1) ? i.e. is the resolution high enough to wait at
least 1 microsecond given it returns normally ? I know the actual
implementation is platform / cpu dependant, so maybe I should ask: Should
I be able to rely on udelay(1) ?

2) With the highspeed CPUs these days, the implementation of sys_nanosleep
(in kernel/timer.c) for realtime processes:

sys_nanosleep {udelay ((nsec+999)/1000}

is rather low-res. Time for something new ? sys_nanosleep seems not the
call to make for in-kernel accurate delays, for it schedules a timeout
instead of doing a busy wait. My driver needs 250 ns delays, is there a
more accurate way than udelay(1) ? It is a pity to waste 4x more
clockcycli than needed.

3) Usleep and friends seem not to care about speedstepping technologies.
Shouldn't we care, at least for in-kernel and realtime process waits ?
True, you are an idiot when running realtime processes on a speedstep
enabled CPU, but still...

Jos


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: udelay and nanosleep questions
  2002-09-21 11:23 udelay and nanosleep questions Jos Hulzink
@ 2002-09-21 11:35 ` Russell King
  2002-09-22  3:51 ` george anzinger
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King @ 2002-09-21 11:35 UTC (permalink / raw)
  To: Jos Hulzink; +Cc: Linux Kernel Development

On Sat, Sep 21, 2002 at 01:23:10PM +0200, Jos Hulzink wrote:
> 1) Can I rely on udelay(1) ? i.e. is the resolution high enough to wait at
> least 1 microsecond given it returns normally ? I know the actual
> implementation is platform / cpu dependant, so maybe I should ask: Should
> I be able to rely on udelay(1) ?

udelay() should (note: should) busy wait for at least the requested delay.
It may wait longer though.

Its behaviour in the presence of speedstep type technologies where cpufreq
is not in use is a little undefined; almost anything can happen.  However,
with cpufreq in place, we adjust the delay value appropriately so that
a udelay() always sleeps for at least the requested time.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: udelay and nanosleep questions
  2002-09-21 11:23 udelay and nanosleep questions Jos Hulzink
  2002-09-21 11:35 ` Russell King
@ 2002-09-22  3:51 ` george anzinger
  1 sibling, 0 replies; 3+ messages in thread
From: george anzinger @ 2002-09-22  3:51 UTC (permalink / raw)
  To: Jos Hulzink; +Cc: Linux Kernel Development

Jos Hulzink wrote:
> 
> Hi,
> 
> Talking about kernel driver programming:
> 
> 1) Can I rely on udelay(1) ? i.e. is the resolution high enough to wait at
> least 1 microsecond given it returns normally ? I know the actual
> implementation is platform / cpu dependant, so maybe I should ask: Should
> I be able to rely on udelay(1) ?
> 
> 2) With the highspeed CPUs these days, the implementation of sys_nanosleep
> (in kernel/timer.c) for realtime processes:
> 
> sys_nanosleep {udelay ((nsec+999)/1000}
> 
> is rather low-res. Time for something new ? sys_nanosleep seems not the
> call to make for in-kernel accurate delays, for it schedules a timeout
> instead of doing a busy wait. My driver needs 250 ns delays, is there a
> more accurate way than udelay(1) ? It is a pity to waste 4x more
> clockcycli than needed.
> 
> 3) Usleep and friends seem not to care about speedstepping technologies.
> Shouldn't we care, at least for in-kernel and realtime process waits ?
> True, you are an idiot when running realtime processes on a speedstep
> enabled CPU, but still...

You might want to check out the high-res-timers stuff.  We
will be sending this in soon for 2.5, for 2.4, see the link
below.

-g
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-22  3:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-21 11:23 udelay and nanosleep questions Jos Hulzink
2002-09-21 11:35 ` Russell King
2002-09-22  3:51 ` george anzinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®