One: Preface
The clock is the pulse of the whole operating system, which provides the basis for the process scheduling and timing events. In addition, many of the operations of user space depend on clocks, such as select.poll,make. Operating System Management time is divided into two types, one called the current time, That's the time we spend in our daily life. This time is generally stored in CMOS. The motherboard has a specific chip to provide timing basis for it. Another time is called relative time. For example, the system run time. Obviously for computers, the relative time is more important than the current time.
Second: The clock-related hardware processing.
1): Real Time Clock (RTC)
The clock is independent of the CPU and other chips. The clock continues to run even if the PC is powered down. The timing is processed by a separate chip and the clock value is stored in CMOS. This time can be used to periodically generate time signals on the IRQ8. The frequency is between 2Hz ~ 8192Hz. But in Linux, Just use the RTC to get the current time.
2): Time stamp timer (TSC)
The CPU comes with a 64-bit timestamp register, when the clock signal arrives. Automatically add 1 to the Register contents
3): Programmable Interrupt timer (PIC)
The device can periodically send a time interrupt signal. The interval at which the interrupt signal is sent can be programmed to control. In a Linux system, the interrupt interval is represented by Hz. This time interval is also called a Beat (tick).
4): CPU Local Timer
Additional timing devices are also available on the local APIC of the processor. The CPU local timer can also generate interrupt signals on a single or periodic basis. Compared with the pic described previously. It has the following differences:
The APIC local timer is 32-bit. and pic is 16 bits. This APIC local timer can provide lower frequency interrupt signals
The local APIC only sends the interrupt signal to the local CPU. And the interrupt signal sent by pic can be processed by any CPU
The APIC timer is based on the bus clock signal. While PIC has its own internal clock oscillator
5): High precision timer (HPET)
Increased support for Hpet in linux2.6. Hpet is a new timing chip developed jointly by Microsoft and Intel. The device has a set of time-sending devices, each of which should have its own clock signal, and the clock signal will automatically add 1 when it arrives.
In fact, the Intel multiprocessor system differs from a single-processor system:
In a single processing system. All timing activities are triggered by a clock interrupt signal generated by pic.
In a multiple-processing system, all ordinary activities are triggered by a pic-generated interrupt. All specific CPU activity is triggered by the local APIC.