Two processors, two clocks
Sep. 12th, 2006 11:15 amAt work, I've the good fortune of having a two-CPU workstation on my desk.
Unfortunately, whilst the two CPUs are within a centimetre of one another on the same piece of silicon, they appear to maintain independent clocks running with a noticeable offset; I can't tell if the speeds are also different.
In any case,
can leave b reading out as several seconds before a, if the main thread was initially on the core with the later clock and got rescheduled onto the other one after the operation. This is not helpful for seeing which things are actually faster than which others.
Is there a standard C library routine, or at least something in <sys/*.h>, guaranteed to read a clock of a kind such that I can be reasonably confident that the computer's got only one?
Unfortunately, whilst the two CPUs are within a centimetre of one another on the same piece of silicon, they appear to maintain independent clocks running with a noticeable offset; I can't tell if the speeds are also different.
In any case,
a = clock() multi_threaded_operation() b = clock()
can leave b reading out as several seconds before a, if the main thread was initially on the core with the later clock and got rescheduled onto the other one after the operation. This is not helpful for seeing which things are actually faster than which others.
Is there a standard C library routine, or at least something in <sys/*.h>, guaranteed to read a clock of a kind such that I can be reasonably confident that the computer's got only one?