Re: gettimeofday() vs. /proc/rtc

Richard B. Johnson (root@chaos.analogic.com)
Sun, 19 Jul 1998 20:58:58 -0400 (EDT)


On Sun, 19 Jul 1998, Truxton Fulton wrote:

> It takes 1000 microseconds to read /proc/rtc, whereas gettimeofday()
> takes only 15 microseconds to complete. Both of these are way too
> long. On my 133 Mhz 486, it seems like there should be a fine grained
> timer that takes less than 1 microsecond to read... any suggestions?
>
> -Truxton
>
How would you get a system call from user mode to take less than 1
microsecond, is really what you are asking. If you look at an Intel
book on your processor, you will probably find that you are asking a
bit too much because a protected mode Operating System does not
execute user-mode code. Instead, it switches to kernel mode to process
a function on behalf of the user. In so doing, it performs a complete
context-switch. It has to perform two, to complete the operation (it
has to get back from kernel mode). So, if reading the time took zero
seconds, I feel you are still in a world of hurt. There is also no
guarantee that the kernel will directly return to your process. There
may be higher-priority tasks and interrupts that must be handled
before your code gets the CPU back.

If you need such instant response, you probably need to put your
"realtime" code in a dummy "driver" and use insmod to insert into
the kernel. You could tell your driver to "do something" and return
results, either through /dev/your_device, or /proc/your_proc.

Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.108 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html