Messages in this thread | | | Date | Tue, 23 Feb 1999 13:38:42 +0100 | From | Vojtech Pavlik <> | Subject | gettimeofday & high-res timers |
| |
On Tue, Feb 23, 1999 at 12:30:08PM +0100, Thomas Sailer wrote:
> If that happens infrequently, it's not a problem for baycom_ser_fdx > (the worst that can happen is it looses a packet), but otherwise > I need a different high resolution clock (resolution less than 100us). > What should I use for this?
I have to cope with a very similar problem in the joystick drivers - I do need a high resolution timer for measuring the analog joystick values and also for digital joysticks timeouts.
I tried using do_fast_gettimeofday at some time in the past, but it seemed to have trouble on certain machines when the interrupts were disabled for too long a time.
Now the joystick drivers selectively use different timing mechanisms at different places as appropriate, but always use the hardware directly, without any help from the rest of the kernel.
The methods:
If you need a quite high res timer (approx 800 kHz), but don't need it to be very precise and stable, you can go by with inb/outb instruction counting. This works if you're accessing the hardware through ISA, (or emulated ISA) which is on quite a bunch of architectures.
If you need the timer to be stable, still high res (1.193 MHz), but can live with that a timer read takes about 3.7 us, you can use the PC's PIT, the Programmable Interrupt Timer.
And, of course, if the CPU has its own high-res timer, then you're lucky and can use that. (586+, Alpha, Sparc ...)
Yes, it would be really cool if I could use something like do_fast_gettimeofday, but not all systems can have one which is both fast and high-res, so I have to choose ...
Vojtech
- 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.tux.org/lkml/
| |