Rtc/osc
Rtc,real time clock, real clock, also called CMOS clock, called Walltime
Osc,operation system clock. The operating system takes time data from the RTC to initialize the OSC when it is powered on, and is completely controlled by the operating system.
When setting the OSC time, the RTC time does not automatically synchronize, when shutting down or restarting, the operating system will automatically synchronize the OSC time to RTC, the operating system will refresh or correct the information in the RTC every other fixed time, when the operating system shuts down, time to the motherboard on the RTC to remember, Because the CMOS on the motherboard is powered by a lithium battery.
When power is turned on again, the operating system will go to the motherboard RTC for time.
Clock_realtime/clock_realtime
Clock_realtime, real time, walltime, or RTC, will be affected by settime ()/settimeofday ().
Clock_monotonic, monotonous time, that is, from a certain point in time to the present time of the past. The user cannot modify this time, but Clock_monotonic is not incremented when the system enters hibernation (suspend). Will not be affected by settime ()/settimeofday ().
The effects of NTP
If NTP calls the Adjtimex () interface when it adjusts time, it will affect both Clock_realtime and clock_monotonic.
Clock_monotonic_raw
Similar to monotonic time, but also monotonically increasing time, but raw monotonic time is not affected by NTP timing adjustment
int Clock_gettime (clockid_t clk_id, struct timespec *tp);
CLK_ID is Clock_monotonic, returns the number of seconds and nanoseconds after the system has been started.
CLK_ID is Clock_realtime, the RTC is returned
Clock_gettime interface and Linux time system