The clock processing mechanism of Linux

Source: Internet
Author: User
Tags current time event timer time and date

In the Linux operating system, many activities are related to time, such as process scheduling and network processing, and so on. Therefore, understanding the clock processing mechanism in the Linux operating system helps to better understand how the Linux operating system works. This paper analyzes the clock processing mechanism of Linux 2.6.25 kernel, first introduces some hardware timers in computer system, then focuses on the hardware clock and software clock processing in Linux operating system and the application of software clock. Finally, the full text is summarized.

1 timers in a computer system

There are many hardware timers in the computer system, such as real timer Clock (RTC), Time Stamp Counter (TSC), and programmable Interval timer (PIT), and so on.

This section is not the midpoint of this article, just a few, and more, see references:

Real Timer Clock (RTC):

Independent of the entire computer system (e.g., CPU and other chip)

The kernel uses it to get the system current time and date

Time Stamp Counter (TSC):

From Pentium, a register TSC is provided to accumulate the clock signal generated by each external oscillator

Access this register via instruction RDTSC

can provide more accurate time measurements than PIT,TSC

Programmable Interval Timer (PIT):

Time Measuring Equipment

The kernel uses the device that produces clock interrupts, resulting in clock interrupts that depend on the hardware architecture, slow for Ms once, and fast for 1 ms at a time

High Precision Event Timer (hpet):

PIT and RTC replacements, compared to previous timers, Hpet provides a higher clock frequency (at least ten MHz) and a wider counter width (64-bit)

A hpet includes a fixed-frequency numeric increment counter and 3 to 32 independent timers, each of which has a comparator and a register (holding a value indicating when the interrupt is triggered). Each comparer compares the values in the counter with the values in the registers, and when the two values are equal, an interrupt is generated

2 Hardware clock processing

The hardware clock in this case refers to the processing of the hardware timer clock interruption.

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.