On Tue, 21 Nov 2000, Kevin Lawton wrote:
> Ramon van Handel wrote:
> >
> > Kevin Lawton wrote:
> > > Which brings up something else. One nice thing to put into
> > > open source OSes would be calling an interface to the VM
> > > code to handle delay loops.
> >
> > Most OSes do this pretty well...
> > If they can't fill up the delay, they call
> > HLT to idle the processor.
>
>
> I haven't looked at the Linux delay code for 2.4. How
> do they handle delays for IO devices (based on bogomips)
> these days? HLT is no problem to handle. Tight loops
> are a waste in the VM.
AFAIK, prumpf's code isnt implimented in 2.4 (as yet), but it will be in
2.2.18... here's how it does delays:
static void __rdtsc_delay(unsigned long loops)
{
unsigned long bclock, now;
rdtscl(bclock);
do
{
rdtscl(now);
}
while((now-bclock) < loops);
}
and it then caliberates based on that, after being called lots of
times. It's a very neat idea, but as it's only avaliable on 586+'s it
falls back onto:
static void __loop_delay(unsigned long loops)
{
int d0;
__asm__ __volatile__(
"\tjmp 1f\n"
".align 16\n"
"1:\tjmp 2f\n"
".align 16\n"
"2:\tdecl %0\n\tjns 2b"
:"=&a" (d0)
:"0" (loops));
}
for older boxen
--
Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
UL++++$ (GCM/GCS/GS/GM)GUG! dpu? s-:-@ a15! C+++>$ P++$>+++@ L+++>+++++$
!E---? W+++>$ N++@>+ o->+ w--- !M--? !V--? PS- PE--@ !PGP----? r++
!t---?@ !X---? !R- b+ !DI---? e->+++++ h+++*! y-
(www.geekcode.com)