Difference between real-time clock, system clock, and CPU clock

Source: Internet
Author: User
Tags event timer greatest common divisor

Http://blog.sina.com.cn/s/blog_68f909c30100pli7.html

Real-time Clock: RTC Clock, which provides real time information for years, months, days, hours, minutes, seconds, and weeks, powered by a back-up battery, and RTC still maintains the correct time and date when you shut down the system at night and open the system in the morning.

System clock: Is a logical clock stored in the system memory. For system calculations, such as interrupt exceptions due to timeouts, the timeout calculation is calculated by the system clock. This clock is cleared every time the system is power down or restarted.

CPU clock: That is the frequency of the CPU, of course, the clock frequency here refers to the operating frequency, that is, FSB, and what the frequency = FSB x octave, this online data a large pile, not introduced.

http://bbs.csdn.net/topics/330114794

System timers, which are all architectures, depend on the clock ticks that drive the kernel
Time slices, Process execution Interrupt execution Scheduler all rely on this clock tick, HZ, jffes are the concept of this clock
The hardware requirement of this clock is programmable so that it interrupts at a fixed Hz clock.
The default is to occupy IRQ0 in The wire

RTC is architecture-related, generally provides the clock on the wall when power-on, not lost,
can also be used as a normal timer, hard to use RTC to achieve the above system timer required clock interrupt is also OK

Http://hi.baidu.com/jackfrued/item/e245b029bf7e4a0b42634aa0

System clock

6.1.2 System Clock

The operating system should have the ability to dispatch a task at some point in the future, so a mechanism is needed to ensure that the task is scheduled to run on time. The core of the mechanism is the system clock. Unlike real clock RTC, the system clock is a combination of timer hardware and system software.

1. System Clock Interrupt Source

the system clock hardware can generate a certain frequency of interrupts after being programmed for configuration . In a personal computer, the interrupt vector number associated with the interrupt is 0. The System software maintains the system time by accumulating the number of times the interrupt is generated from the boot to the present , forming the system clock. This section focuses on hardware timers that are common in personal computers and can be used for system clocks.

(1) 8254 programmable timer.

The most commonly used timer hardware chip is the Intel 8254 programmable timer chip (programable Interval timer, referred to as pit), which is driven by a 1 193 181Hz oscillator and contains 3 independent channels ; Each channel contains a 16-bit counter. For each clock pulse that arrives, the value in the counter in the channel is reduced by 1, and when the counter is reduced to 0 o'clock, the corresponding channel produces one output. wherein the output of channel 0 is connected to the interrupt controller, its corresponding interrupt vector number is 0, for generating the tick required by the system clock, the output of Channel 1 is used in the early computer for DRAM refresh, the new computer system has dedicated hardware responsible for DRAM refresh, Channel 1 function no longer exists The output of Channel 2 is connected to the buzzer (PC Speaker) located on the motherboard, which controls the sound of a certain frequency.

Here is a description of the origin of the drive 8254 operating clock frequency. For cost reasons, the original PC was designed with a 14.318 18MHz oscillator that was widely used for televisions at the time, and the frequency of the oscillator was much higher than the operating frequency required by other parts of the system. The designer uses 3 to obtain the 4.77MHZ Drive central processing Unit 8088, uses 4 to obtain the 3.58MHZ signal to drive the color graphics adapter, finally the system various frequency base frequency 1.193 181 6MHz (various frequency greatest common divisor, The 12-way signal is used as the input clock of the system programmable timer chip. In order to maintain compatibility, programmable timer 82,541 uses the clock of this frequency as input directly.

(2) High-precision event timer.

The High Accuracy event timer (Hi Precision event timers) is designed to replace the full functionality of the 8254 programmable timer and the periodic interrupt function of the real clock RTC chip, which produces more accurate periodic interrupts than the 8254 programmable timers. The timer provides higher accuracy and a wider range of interrupt frequencies than the periodic interrupts of the real clock RTC chip.

This hardware timer complies with the high-precision event timer specification that is jointly developed by Intel and Microsoft. The specification specifies that a high-precision event timer has a maximum of 32 timers. After configuration, the timer 0 is used to replace the clock interrupt generated by the 8254 programmable timers; Timer 1 replaces the periodic interrupt function of the real clock RTC chip as a hardware timer; the rest of the timer is used as a hardware timer for the kernel or user process.

(3) processor local clock.

In multiprocessor systems, the processor local clock (CPU local Timer) is used to send clock interrupt requests to the local processor, updating the relative time jiffies on the local processor.

2. Other auxiliary clock sources

This type of auxiliary clock source does not have the ability to make interrupt requests to the system, but has a higher timing accuracy than the timer hardware that can produce system clock interrupts. During system clock interrupt processing, handlers can take advantage of these clock values to complete high-precision time measurements, such as the Udelay in "6.6 microsecond delay", and the Ndelay to complete high-precision latencies using such clock sources such as timestamp counters. The following are common types of auxiliary clock sources.

(1) Timestamp counter.

Starting with Pentium, all Intel processors contain a 64-bit register, which is known as the timestamp (time Stamp Counter, referred to as TSC). TSC adds 1 to each clock signal of the CPU, and in fact the register is an increasing counter, and if the processor has a frequency of 1GHz, the TSC register increases by 1 per 1ns. The assembly instruction RDTSC can be used to read the TSC values. Using the CPU's TSC, the operating system usually gets a more accurate time measurement.

(2) power management clock.

In the kernel, the Power management clock (ACPI Power Management Timer) can also act as the secondary clock source for the system, in addition to using the timestamp number above as the secondary clock source for the system clock. These clock sources are not described in detail here.

3. Macro definitions related to the system clock

(1) macro defines Hz.

The macro definition Hz records the frequency at which the programmable timers that are required by the system clock to generate interrupts under different architectures. In the IA32 architecture, the 6th line of the macro definition in file src/include/asm-i386/param.h is defined as follows:

#define HZ config_hz/* Internal kernel Timer frequency */

The config_hz is the kernel configuration option, which has 3 frequency candidates of 100Hz, 1 000Hz, and 250Hz, respectively, for server systems requiring high system throughput, personal desktop computer systems requiring rapid response, and computer systems with two types of applications.

(2) macro definition clock_tick_rate.

The macro definition clock_tick_rate records the input clock frequency that drives the programmable timer in different architectures. In the IA32 architecture, the value in the 15th line of the file src/include/asm-i386/timex.h is defined as follows:

#define CLOCK_TICK_RATE 1193182/* Underlying HZ */

Where the value 1 193 182 is the input clock frequency of the 8254 programmable timer. For details, see the analysis of the 8254 programmable timers in this section.

(3) macro definition latch.

The macro definition latch records the ratios of the above two macro definitions to set the initial value of the Counter register counter in the programmable timer during kernel initialization. Under the IA32 architecture, the macro definition is defined in the 46th row of the file Src/include/linux/jiffies.h as follows:

#define LATCH ((clock_tick_rate + HZ/2)/HZ)/* for divider */

Difference between real-time clock, system clock, and CPU clock

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.