TiIf a program requires measuring elapsed time, you will need an individual timer that will be independent even if the user changes the time on the system clock. In Linux there are several different implementations for different cases (https://linux.die.net/man/3/clock_gettime):

    System-wide realtime clock. Setting this clock requires appropriate privileges.
    Clock that cannot be set and represents monotonic time since some unspecified starting point.
    High-resolution per-process timer from the CPU.
    Thread-specific CPU-time clock.

To safely measure the elapsed time, you need a clock that ticks out time continuously, without any jumps when a user sets the system time. This kind of clock is called a monotonic clock. (CLOCK_MONOTONIC or CLOCK_MONOTONIC_RAW which gives more accurate results over very short intervals)



Write A Comment