Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
Sleep about one microsecond and outb on 0x80
- 08-17-2005
August 17, 2005, 2:39 pm

Hello,
I want to use delays of 1 microsend on linux 2.4 or linux 2.6 kernel
on x386 platform.
As we know, usleep depends on the HZ of the system.
So both in 2.4 and in 2.6 we cannot achieve 1 microsec delay calling
udelay (the man page of usleep says itslef that
"Probably not accurate on many machines down to the microsecond.").
According to "Linux I/O port programming mini-HOWTO"
(http://www.tldp.org/HOWTO/IO-Port-Programming-2.html )
you can use outb on 0x80 to create a dealy.
So I added this snippest of code
and trird to use outb('a',0x80) for creating a sleep time in
resolution of microseconds thus:
............
ioperm(0x80, 1, 1);
for (i=0;i<10000;i++)
outb('a',0x80);
............
On 3 machines (each of them had a different strength, one of the with
2.6
kernel and the other two with 2.6 kernek) it gave a result of
about 1.4 microsec for every such call, while on a differnet macine it
gave a much
higher average of 2.16 microsec.
That different machine was a strong one, with 3Ghz CPU.

creating a
microsec delay because it gives such different results on different
machines.
However , the results seems strange :
I have 2 almost similiar machines :
one gave 2.16 and one gave 1.4
Could it be that something in that machine caused it to do it slower
and gicv 2.16 microsec as an average?
I must empasize that "top" showed that there did not run something
heavy on
both these machines.(in terms of cpu and memory)
Any idea?
John Que
I want to use delays of 1 microsend on linux 2.4 or linux 2.6 kernel
on x386 platform.
As we know, usleep depends on the HZ of the system.
So both in 2.4 and in 2.6 we cannot achieve 1 microsec delay calling
udelay (the man page of usleep says itslef that
"Probably not accurate on many machines down to the microsecond.").
According to "Linux I/O port programming mini-HOWTO"
(http://www.tldp.org/HOWTO/IO-Port-Programming-2.html )
you can use outb on 0x80 to create a dealy.
So I added this snippest of code
and trird to use outb('a',0x80) for creating a sleep time in
resolution of microseconds thus:
............
ioperm(0x80, 1, 1);
for (i=0;i<10000;i++)
outb('a',0x80);
............
On 3 machines (each of them had a different strength, one of the with
2.6
kernel and the other two with 2.6 kernek) it gave a result of
about 1.4 microsec for every such call, while on a differnet macine it
gave a much
higher average of 2.16 microsec.
That different machine was a strong one, with 3Ghz CPU.

creating a
microsec delay because it gives such different results on different
machines.
However , the results seems strange :
I have 2 almost similiar machines :
one gave 2.16 and one gave 1.4
Could it be that something in that machine caused it to do it slower
and gicv 2.16 microsec as an average?
I must empasize that "top" showed that there did not run something
heavy on
both these machines.(in terms of cpu and memory)
Any idea?
John Que
Site Timeline
- » What are main issues while porting VxWorks code to Linux?
- — Next thread in » Embedded Linux
-
- » read serial interfaces inside of a thread
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » Fixed Point Arithmetic is a PITA!
- — The site's Newest Thread. Posted in » Electronics Design
-