I have 2 processes (not threads) that are supposed to read the system clock at the same time. For this purpose, the first process uses
QTime::currentTime();
and the second process uses
std::chrono::high_resolution_clock::now();
But when I read the respective clock values read by these 2 processes, I find that there's always a difference of a few microseconds. Is it because the system clock is a shared resource, so one has to wait for the other to finish reading? Is it because the functions that read the system clock are not the same, so the time resolution is not the same? (but this seems very unlikely to me... because in my understanding the time resolution is set by the RTC, not the high level APIs)
I do not use any specific 'measure' to synchronize these 2 processes. The first is constantly attempting to read the system clock (it has a while(1)), the second reads the system clock when I launch it. So because the first process is always attempting to read the system clock, I guess there will probably be a 'race condition' when process 2 attempts the read the clock.