Is the era of steady-state relative to the start time of the operating system? or the process itself?

Using boost::chrono::steady_clock

or std::chrono::steady_clock

assumes that physical time is always monotonic and does not depend on time changes in the system. Here is my question, if I have two processes that need to be immune to system time changes, is it enough to swap only time_since_epoch

? In other words, will the temporal interpretation of two processes at the same time from the epoch be the same? Specifically, I need to answer this question for Windows and QNX.

EDIT: Both processes are running on the same computer, on the same operating system, and communicating via IPC calls.

+3


source to share


2 answers


No tenses are interchangeable between systems because C ++ does not specify an era. The era depends on the operating system, different systems may have different eras.



If, on the other hand, you only divide time locally, within the same system, then everything is fine.

+3


source


The C ++ standard says steady_clock

:

20.12.7.2 Class stable_clock [time.clock.steady]

Objects of class stable_clock represent clocks for which time_point values ​​never decrease as physical time advances and for which values ​​of time_point advances at a constant speed relative to real time. That is, the clock may not be adjusted.

Compare that to what the standard has to say about system_clock

:



20.12.7.1 Class system_clock [time.clock.system]

Objects of class system_clock represent wall clocks from the system-wide real-time clock.

There is no mention of what steady_clock

is "system-wide" which makes me think that, according to the C ++ standard, you cannot trust two steady_clocks

in different processes on the same machine from the same era.

+1


source







All Articles