On Fri, Jul 12, 2024 at 12:14:56PM -0500, Sami Imseih wrote: > 1/ TimestampDifference has a dependency on gettimeofday, > while my proposal utilizes clock_gettime. There are old discussions > that did not reach a conclusion comparing both mechanisms. > My main conclusion from these hacker discussions [1], [2] and other > online discussions on the topic is clock_gettime should replace > getimeofday when possible. Precision is the main reason. > > 2/ It no longer uses the remain time. I think the remain time > is still required here. I did a unrealistic stress test which shows > the original proposal can handle frequent interruptions much better.
My comment was mostly about coding style and not about gettimeofday() versus clock_gettime(). What does your testing show when you don't have the extra check, i.e., struct timespec delay; struct timespec remain; delay.tv_sec = microsec / 1000000L; delay.tv_nsec = (microsec % 1000000L) * 1000; while (nanosleep(&delay, &remain) == -1 && errno == EINTR) delay = remain; -- nathan