Hi, I just joined the list and was looking through some of the archives.
I have a question for those linux programmers out there. i'm writing a program on linux (kubuntu to be specific) that requires high-precision timing, somewhere on the order of 100 to 1000 micro seconds. <snip> The problem with this approach is that the process uses 99% of the CPU since it just spins the CPU until enough time has expired.
You can get up to 1/8192Hz (122us) periodic interrupts with the x86 RTC timer. You might have to do a little setup, like, # modprobe rtc # echo 8192 > /proc/sys/dev/rtc/max-user-freq [ fiddle permissions on /dev/misc/rtc or /dev/rtc unless you are running your app as root ] See Documentation/rtc.txt in the kernel source for programming details. Basically the kernel is free to idle or run other things until the RTC interrupt hits, then it wakes up your app doing read() or poll() on /dev/rtc. I used this to pulse a hardware register in a project I did a few years ago, worked good enough for my purposes. You might lose an RTC interrupt here and there if your system is under heavy load (call it "soft realtime"), but I think the interface tells you if and how many you lost. There's also the more advanced HPET timer available for newer x86 systems, but I haven't looked at that yet. Good luck, -Jamie Guinan
participants (1)
-
Jamie Guinan