On 16/08/2011 12.17, Lorenzo Donati wrote:
To be clearer: I'd like to know (whether or not an OS chooses to provide
an high resolution sleep function) if the modern PC hardware is capable
of providing such a timing resolution to the upper sw layer by default
(using some standard BIOS call or standard I/O port or whatever), or if
it depends on some peculiar hw characteristic such as CPU setup, chipset
or similar things.
As far as I know, most (all?) modern CPUs have a high-resolution timer
in the nanosecond range; I don't think there's a portable call to access
it across different OSs, though (I may be wrong).
Of course it would be unwise to implement a true 'sleep' function with
such a short time duration, because of complications such as
interference with the task scheduler and unpredictable interrupt latency
(assuming interrupt could be used; I don't think so in the general
case); it would have to be a busy loop, with all that this implies, or
if possible a periodic check while doing some other processing.