Timing measurement: It is done by several hardware circuits based on fixed frequency oscillator and counter.
Overview of the time system:
Time-related tasks in the kernel:
Hardware devices:
Realtime Clock (RTC): 1, real Time clock, independent of the CPU and all chips, each PC has.
2, it has a special battery, not affected by the power outage of the PC.
3, can be in IRQ8 on-site periodic interruption, frequency of 2-8192hz
4. Programmable
Timestamp counter (TSC): 1, time Stamp Counter receive clock signal plus one
2, the frequency of the clock signal, if it is 1GHz, timestamp counter nanosecond plus one.
Programmable Interval Timer (PIT): 1, Programmable Interval timer
2, usually a 8354CMOS chip using the 0x40~0x43 I/O port
3, by issuing a clock interrupt to notify the kernel another time interval passed.
4. Always send interrupts with fixed to frequency
CPU Local timer: Has APIC provided, APIC (32bit), PIC (16bit), can be programmed to generate very low frequency interrupts for local timer programming
The local APIC timer sends interrupts only to its own processor, and the pit generates a global outage that any CPU can handle.
The APIC timer is based on the clock signal, and the pit is based on internal clock oscillation.
High Accuracy Event Timer (HPET):
Linux time-of-mind architecture:
The kernel periodically performs timing-related operations:
1, updated since the system started the time elapsed
2. Update Time and date
3. Determine how long the current process has been running on each CPU, and if it exceeds the time slice allotted to him, preempt it.
4. Update System Resource Usage statistics
5. Check whether the time interval of each soft timer has been reached.
Deep understanding of the Linux kernel-timing measurement