Linux Time Module II

Source: Internet
Author: User

Hardware clock and system clock in Linux

There are two kinds of clocks, such as hardware clock and system clock, in Linux. The hardware clock is the clock device on the motherboard, which is usually the clock that can be set on the BIOS screen. The system clock refers to the clock in the kernel. When Linux starts, the system clock reads the settings of the hardware clock, and then the system clock runs independently. All Linux-related instructions and functions are programmed to read the system clock.
The setting of the system clock is our usual date command, and the RTC driver we write is for the hardware clock, it has its own command hwclock, so using the date command is not possible to call to our driver (at this point it began to depressed me, after writing the driver, Silly to test with the date command, and of course the result is nothing), we can update the RTC clock with some instructions from hwclock-that is, the interaction between the system clock and the hardware clock.

HWCLOCK–R display hardware clock and date
The hwclock–s adjusts the system clock to match the current hardware clock.
The hwclock–w adjusts the hardware clock to coincide with the current system clock.


The Linux system has two clocks: one is a motherboard battery-powered "Real time Clock" called RTC or a CMOS clock,
Hardware clock. When the operating system shuts down, use this to record the time, but for the running system is not the time.
The other time is "System clock" also called the kernel clock or software clock, is the software according to time interrupt to count,
The kernel clock does not exist in the case of system shutdown, so when the operating system starts, the kernel clock is to read the RTC time
To make time synchronization. And when the system shuts down, the system time is written back to the RTC for synchronization.


As mentioned earlier, there are only two times when the Linux kernel is interoperable with RTC:
1) The kernel reads the start time and date from RTC at startup;
2) The kernel writes the time and date back to the RTC when needed.


When the system starts, the kernel initializes the kernel clock by reading the RTC, also called the wall time, which is placed in the Xtime variable

Linux Time Module II

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.