Mohd Khalid Kasmin wrote:
>
> I am trying to read time to 1/100th of a sec. in Linux using C.
> Most of the time functions (from the man) are good to a sec.
> The gettimeofday() promises to tell time down to microseconds.
> That is better than what I wanted.
Do you know about RTC "Real Time Clock" in the Linux kernel?
You can enable that option as a module, and then create a special device file
called /dev/rtc. I can't remember the major and minor numbers, but if you do a
"make menuconfig" etc. and have a look at the help text for RTC it will tell you
what to do. Then you can use that device from within your Linux C Programs.
Here's the help text:
It is located under "Character Devices", as the last device listed. (At least
that's how it is for my 2.0.33 kernel.
lqqqqqqqqqqqqqqqqqqq Enhanced Real Time Clock Support qqqqqqqqqqqqqqqqqqqqk
x If you enable this option and create a character special file x
x /dev/rtc with major number 10 and minor number 135 using mknod ("man x
x mknod"), you will get access to the real time clock built into your x
x computer. Every PC has such a clock built in. It can be used to x
x generate signals from as low as 1Hz up to 8192Hz, and can also be x
x used as a 24 hour alarm. It reports status information via the file x
x /proc/rtc and its behaviour is set by various ioctls on x
x /dev/rtc. People running SMP (= multiprocessor) versions of Linux x
x should enable this option to read and set the RTC clock in a SMP x
x compatible fashion. If you think you have a use for such a device x
x (such as periodic data sampling), then say Y here, and go read the x
x file Documentation/rtc.txt for details. x
Brock
+------------------------/----------------------------------------------------+
| R. Brock Lynn / http://citv.unl.edu/linux/LinuxPresentation.html |
| [EMAIL PROTECTED] / http://www.kirch.net/unix-nt.html Live free or die. |
+---------------------/-------------------------------------------------------+