Wall time and monotonic time[reprint]

Source: Internet
Author: User

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.

Wall time and monotonic time[reprint]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.