In some system calls you need to specify whether the time is used Clock_monotonic or clock_realtime, it was always unclear how the difference between them, and now finally understand.
Clock_monotonic is monotonic time, and Clock_realtime is wall time. Monotonic time literally means the time of monotony, which in fact refers to the elapsed times after the system starts, which is recorded by the variable jiffies. Each time the system starts, Jiffies is initialized to 0, each timer interrupt,jiffies plus 1, which means that it represents the number of ticks that have elapsed since the system started. Jiffies must be monotonically increasing, because time is not enough inverse! Wall time literally means a wall clock, which actually refers to the actual time, which is recorded by the variable xtime. Each time the system starts, the RTC time on the CMOS is read into the Xtime, which is "the number of seconds experienced since 1970-01-01, the number of nanoseconds experienced in this second", each timer interrupt, also need to update xtime. I have been trying to understand, since each timer interrupt,jiffies and xtime are to be updated, then not all of the monotonically increment it? What is the difference between them when they are used? Yesterday saw an article, finally understand, wall time is not necessarily monotonous increment. Because wall time refers to real-world times, it is possible to arbitrarily change this wall time if the system is to be synchronized with a node in the network, or if the system administrator feels that the wall time is inconsistent with the reality. The simplest example of this is that our users can modify the system time arbitrarily, and the modified time should be wall times, that is, xtime, which can even be written to RTC for permanent storage. Some applications may be used in this wall time, such as the previous use of VMware Workstation, a start-up prompt trial period has expired, but as long as the system is adjusted for one year in advance, then start will not be prompted, This is probably because it starts with gettimeofday to read wall time, and then decide whether to expire, as long as the wall time to change, you can cheat the past. Transferred from: http://zhangjun2915.blog.163.com/blog/static/38086236201051811936178/
Wall time and monotonic time[reprint]