[go: up one dir, main page]

CN110119331A - Clock-switching method, device, server and clock system - Google Patents

Clock-switching method, device, server and clock system Download PDF

Info

Publication number
CN110119331A
CN110119331A CN201810123462.0A CN201810123462A CN110119331A CN 110119331 A CN110119331 A CN 110119331A CN 201810123462 A CN201810123462 A CN 201810123462A CN 110119331 A CN110119331 A CN 110119331A
Authority
CN
China
Prior art keywords
clock signal
phase
circuit
clock
standby
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810123462.0A
Other languages
Chinese (zh)
Other versions
CN110119331B (en
Inventor
黄子龙
郑庆宗
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201810123462.0A priority Critical patent/CN110119331B/en
Publication of CN110119331A publication Critical patent/CN110119331A/en
Application granted granted Critical
Publication of CN110119331B publication Critical patent/CN110119331B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/14Time supervision arrangements, e.g. real time clock
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/1658Data re-synchronization of a redundant component, or initial sync of replacement, additional or spare unit

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Stabilization Of Oscillater, Synchronisation, Frequency Synthesizers (AREA)

Abstract

本申请实施例提供一种时钟切换方法、装置、服务器和时钟系统,该方法包括,在检测到主时钟信号异常时,通过切换电路的备时钟信号输入端口接收备时钟信号;对备时钟信号的相位进行重建,并生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟信号的相位一致;根据备时钟信号和预设相位调整速度对重建后的时钟信号的相位进行补偿,并生成补偿后的时钟信号,将补偿后的时钟信号通过切换电路的时钟信号输出端口输出,补偿后的时钟信号的相位与备时钟信号的相位一致。本申请实施例提供的时钟切换方法可保证提供给各处理器的TSC的时钟信号的相位一致,保证服务器的操作系统的正常工作。

Embodiments of the present application provide a clock switching method, device, server, and clock system. The method includes, when an abnormality is detected in the main clock signal, receiving the standby clock signal through the standby clock signal input port of the switching circuit; The phase is reconstructed, and the reconstructed clock signal is generated. The phase of the reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality; the phase of the reconstructed clock signal is compensated according to the standby clock signal and the preset phase adjustment speed , and generate a compensated clock signal, output the compensated clock signal through the clock signal output port of the switching circuit, and the phase of the compensated clock signal is consistent with the phase of the standby clock signal. The clock switching method provided in the embodiment of the present application can ensure that the phases of the clock signals provided to the TSCs of each processor are consistent, and ensure the normal operation of the operating system of the server.

Description

时钟切换方法、装置、服务器和时钟系统Clock switching method, device, server and clock system

技术领域technical field

本申请涉及计算机领域,尤其涉及一种时钟切换方法、装置、服务器和时钟系统。The present application relates to the computer field, in particular to a clock switching method, device, server and clock system.

背景技术Background technique

服务器包括处理器,时间戳计数器(Time Stamp Counter,TSC)位于处理器的内部,用于为服务器上运行的操作系统提供时钟信号。在时钟系统中,TSC的时钟源采用冗余设计,通过主、备两个时钟板为TSC提供时钟源。当主时钟板发生故障时,与处理器对应的切换电路将提供给该处理器的TSC的时钟源切换为备时钟板,由备时钟板代替主时钟板继续工作,避免影响服务器处理业务。由于备时钟板提供的时钟信号与主时钟板提供的时钟信号之间可能存在相位差,导致TSC为服务器的操作系统提供的时钟信号不稳定,进而影响服务器的稳定运行。为解决主、备时钟信号相位不一致的问题,切换电路通常根据主、备时钟板提供的时钟信号之间的相位差对备时钟板提供的备时钟信号的相位进行相位重建,重建后的时钟信号的相位与主时钟板提供的主时钟信号的相位一致。The server includes a processor, and a time stamp counter (Time Stamp Counter, TSC) is located inside the processor, and is used to provide a clock signal for an operating system running on the server. In the clock system, the clock source of the TSC adopts a redundant design, and the clock source is provided for the TSC through the main clock board and the backup clock board. When the main clock board fails, the switching circuit corresponding to the processor will switch the clock source of the TSC provided to the processor to the standby clock board, and the standby clock board will continue to work instead of the main clock board, so as to avoid affecting the server's business processing. Because there may be a phase difference between the clock signal provided by the standby clock board and the clock signal provided by the master clock board, the clock signal provided by the TSC for the server operating system is unstable, which affects the stable running of the server. In order to solve the problem of phase inconsistency between the main and standby clock signals, the switching circuit usually reconstructs the phase of the standby clock signal provided by the standby clock board according to the phase difference between the clock signals provided by the main and standby clock boards, and the reconstructed clock signal The phase of the main clock signal is consistent with that of the main clock signal provided by the main clock board.

而对于多处理器服务器,各处理器的TSC均为同一个操作系统内核提供高精度时钟信号。各个处理器中的TSC的计数频率和相位一致,多处理器服务器的操作系统才可以正常工作。所以要保证时钟系统中提供给各处理器的TSC的时钟信号的相位和频率要一致。在多处理器服务器中,不同的切换电路对同一时钟信号进行重建时的处理偏差不尽相同,所以不同的切换电路对备时钟信号进行相位重建后获得的时钟信号之间存在相位偏差,可能相位偏差也不尽相同,导致提供给各处理器的TSC的时钟信号的相位不一致,进而影响服务器的操作系统的正常工作。For a multi-processor server, the TSCs of each processor provide a high-precision clock signal for the same operating system kernel. The operating system of the multiprocessor server can work normally only when the counting frequency and phase of the TSCs in each processor are consistent. Therefore, it is necessary to ensure that the phase and frequency of the clock signal provided to the TSC of each processor in the clock system are consistent. In a multiprocessor server, different switching circuits have different processing deviations when reconstructing the same clock signal, so there is a phase deviation between the clock signals obtained after different switching circuits reconstruct the phase of the standby clock signal, and the phase may be The deviations are also different, resulting in inconsistent phases of the clock signals provided to the TSCs of the processors, thereby affecting the normal operation of the operating system of the server.

发明内容Contents of the invention

本申请实施例提供一种时钟切换方法、装置、服务器和时钟系统,能够保证向多处理器服务器中的各处理器的TSC提供的时钟信号一致,确保服务器上的操作系统可以正常工作。The embodiments of the present application provide a clock switching method, device, server and clock system, which can ensure that the clock signals provided to the TSCs of each processor in the multiprocessor server are consistent, and ensure that the operating system on the server can work normally.

第一方面,本申请实施例提供一种时钟切换方法,包括:在主时钟信号正常时,第一电路接收所述主时钟信号后,向第一负载提供所述主时钟信号,所述主时钟信号由与所述第一电路连接的主时钟电路提供。在所述主时钟信号异常时,所述第一电路接收备时钟信号,所述备时钟信号由与所述第一电路连接的备时钟电路提供。所述第一电路对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述第一重建时钟信号的相位与异常前的所述主时钟信号的相位一致。所述第一电路向所述第一负载提供所述第一重建时钟信号。所述第一电路根据所述备时钟信号和预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,所述多个调整时钟信号中最后生成的调整时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的调整时钟信号,所述多个调整时钟信号中其他的调整时钟信号的相位介于所述第一重建时钟信号的相位和所述备时钟信号的相位之间。所述第一电路每次调整后向所述第一负载提供调整后生成的所述调整时钟信号。In the first aspect, the embodiment of the present application provides a clock switching method, including: when the main clock signal is normal, the first circuit provides the main clock signal to the first load after receiving the main clock signal, and the main clock A signal is provided by a master clock circuit connected to said first circuit. When the main clock signal is abnormal, the first circuit receives a backup clock signal, and the backup clock signal is provided by a backup clock circuit connected to the first circuit. The first circuit reconstructs the phase of the standby clock signal to generate a first reconstructed clock signal, and the phase of the first reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality. The first circuit provides the first reconstructed clock signal to the first load. The first circuit continuously adjusts the phase of the first reconstruction clock signal according to the backup clock signal and a preset phase adjustment speed to generate a plurality of adjustment clock signals, and the last generated adjustment clock signal among the plurality of adjustment clock signals is The phase of the clock signal is equal to the phase of the standby clock signal, except for the last generated adjustment clock signal, the phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phases of the first reconstructed clock signal and between the phases of the standby clock signal. The first circuit provides the adjusted clock signal generated after adjustment to the first load after each adjustment.

通过根据预设相位调整速度对重建的时钟信号的相位进行相位调整,生成与备时钟信号相位一致的时钟信号,保证了多个第一电路调整的时钟信号相位缓慢变化,且变化一致,使得各第一电路为各处理器的TSC提供的时钟信号的相位一致,避免了多处理器操作系统的不稳定运行,也避免了多次时钟切换可能造成的累积误差。By adjusting the phase of the reconstructed clock signal according to the preset phase adjustment speed, a clock signal with a phase consistent with that of the standby clock signal is generated, which ensures that the phases of the clock signals adjusted by multiple first circuits change slowly and are consistent, so that each The phases of the clock signals provided by the first circuit to the TSCs of the processors are consistent, avoiding the unstable operation of the multi-processor operating system and avoiding the possible cumulative error caused by multiple clock switching.

在一种可能的实施方式中,所述预设相位调整速度的取值范围为1-10微秒/秒。In a possible implementation manner, the value range of the preset phase adjustment speed is 1-10 microseconds/second.

在一种可能的实施方式中,时钟切换方法还包括:在主时钟信号正常时,第二电路接收所述主时钟信号后,向第二负载提供所述主时钟信号,所述主时钟信号由与所述第二电路连接的所述主时钟电路提供。在所述主时钟信号异常时,所述第二电路接收备时钟信号,所述备时钟信号由与所述第二电路连接的所述备时钟电路提供。所述第二电路对所述备时钟信号的相位进行重建,生成第二重建时钟信号,所述第二重建时钟信号的相位与异常前的所述主时钟信号的相位一致。所述第二电路向所述第二负载提供所述第二重建时钟信号。所述第二电路根据所述备时钟信号和所述预设相位调整速度对所述第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,所述多个补偿时钟信号中最后生成的补偿时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的补偿时钟信号,所述多个补偿时钟信号中其他的补偿时钟信号的相位介于所述第二重建时钟信号的相位和所述备时钟信号的相位之间。所述第二电路每次调整后向所述第二负载提供调整后生成的所述补偿时钟信号。In a possible implementation manner, the clock switching method further includes: when the main clock signal is normal, the second circuit provides the main clock signal to the second load after receiving the main clock signal, and the main clock signal is determined by The master clock circuit connected to the second circuit provides. When the main clock signal is abnormal, the second circuit receives a backup clock signal, and the backup clock signal is provided by the backup clock circuit connected to the second circuit. The second circuit reconstructs the phase of the standby clock signal to generate a second reconstructed clock signal, and the phase of the second reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality. The second circuit provides the second reconstructed clock signal to the second load. The second circuit continuously adjusts the phase of the second reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of compensation clock signals, and the last of the plurality of compensation clock signals is generated The phase of the compensated clock signal is equal to the phase of the standby clock signal, except for the last generated compensated clock signal, the phases of other compensated clock signals in the plurality of compensated clock signals are between that of the second reconstructed clock signal phase and the phase of the standby clock signal. The second circuit provides the adjusted and generated compensation clock signal to the second load after each adjustment.

由于第一电路与第二电路进行相位重建时存在处理偏差,导致第一重建时钟信号和第二重建时钟信号的相位存在偏差,通过对第一重建时钟信号和第二重建时钟信号分别进行相位调整,使得最后生成的补偿时钟信号和调整时钟信号的相位均与备时钟信号相位一致,二者相位一致且不存在偏差。Due to the processing deviation between the first circuit and the second circuit when performing phase reconstruction, there is a phase deviation between the first reconstruction clock signal and the second reconstruction clock signal. By adjusting the phases of the first reconstruction clock signal and the second reconstruction clock signal respectively , so that the phases of the finally generated compensation clock signal and the adjustment clock signal are consistent with the phases of the standby clock signal, and the phases of the two are consistent without deviation.

在一种可能的实施方式中,第二电路和第一电路的结构相同;第一负载可以包括一个或多个处理器,第二负载也可以包括一个或多个处理器。In a possible implementation manner, the structure of the second circuit is the same as that of the first circuit; the first load may include one or more processors, and the second load may also include one or more processors.

在一种可能的实施方式中,所述第一电路包括第一控制电路和第一锁相环电路,所述第一控制电路与所述第一锁相环电路连接。时钟切换方法还包括:在所述主时钟信号异常时,所述第一控制电路将所述第一锁相环电路的工作状态设置为相位重建状态。所述第一电路对所述备时钟信号的相位进行重建,生成第一重建时钟信号,包括:所述第一锁相环电路在工作状态为相位重建状态时,对所述备时钟信号的相位进行重建,生成第一重建时钟信号。时钟切换方法还包括:所述第一控制电路确定所述第一锁相环电路生成所述第一重建时钟信号,将所述第一锁相环电路的工作状态设置为相位补偿状态。所述第一电路根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,包括:所述第一锁相环电路在工作状态为相位补偿状态时,根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。In a possible implementation manner, the first circuit includes a first control circuit and a first phase-locked loop circuit, and the first control circuit is connected to the first phase-locked loop circuit. The clock switching method further includes: when the main clock signal is abnormal, the first control circuit sets the working state of the first phase-locked loop circuit to a phase reconstruction state. The first circuit reconstructs the phase of the standby clock signal to generate a first reconstructed clock signal, including: when the first phase-locked loop circuit is in the phase rebuilding state, reconfiguring the phase of the standby clock signal Perform reconstruction to generate a first reconstruction clock signal. The clock switching method further includes: the first control circuit determines that the first phase-locked loop circuit generates the first reconstruction clock signal, and sets the working state of the first phase-locked loop circuit to a phase compensation state. The first circuit continuously adjusts the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, including: the first phase-locked loop circuit When the working state is the phase compensation state, the phase of the first reconstruction clock signal is continuously adjusted according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjustment clock signals.

第一电路包括第一控制电路和第一锁相环电路,通过先控制第一锁相环电路工作在相位重建状态对备时钟信号进行相位重建生成第一重建时钟信号,再控制第一锁相环电路工作在相位补偿状态对第一重建时钟信号进行相位调整,来使得最终生成的调整时钟信号的相位等于所述备时钟信号的相位,简化了第一电路的电路结构。The first circuit includes a first control circuit and a first phase-locked loop circuit, by first controlling the first phase-locked loop circuit to work in the phase reconstruction state to perform phase reconstruction on the standby clock signal to generate a first reconstruction clock signal, and then controlling the first phase-locked loop The loop circuit works in the phase compensation state to adjust the phase of the first reconstructed clock signal, so that the phase of the finally generated adjusted clock signal is equal to the phase of the standby clock signal, which simplifies the circuit structure of the first circuit.

在一种可能的实施方式中,在所述主时钟信号异常时,第一控制电路向第一锁相环电路中的工作状态寄存器写入相位重建配置信息。相位重建配置信息用于指示第一锁相环电路工作在相位重建状态。第一控制电路在确定所述第一锁相环电路生成所述第一重建时钟信号,向第一锁相环电路中的工作状态寄存器写入相位补偿配置信息。相位补偿配置信息用于指示第一锁相环电路工作在相位补偿状态。In a possible implementation manner, when the main clock signal is abnormal, the first control circuit writes phase reconstruction configuration information to a working status register in the first phase-locked loop circuit. The phase reconstruction configuration information is used to indicate that the first phase-locked loop circuit works in a phase reconstruction state. After determining that the first phase-locked loop circuit generates the first reconstruction clock signal, the first control circuit writes phase compensation configuration information into a working state register in the first phase-locked loop circuit. The phase compensation configuration information is used to indicate that the first phase locked loop circuit works in a phase compensation state.

在一种可能的实施方式中,所述第一电路通过所述第一电路的时钟信号输出端口向所述第一负载提供时钟信号,所述第一电路的时钟信号输出端口与所述第一电路的反馈时钟信号输入端口连接,所述第一电路的反馈时钟信号输入端口与所述第一锁相环电路的反馈输入端口连接。时钟切换方法还包括:所述第一锁相环电路对所述备时钟信号的相位进行重建之前,关闭所述第一锁相环电路的反馈输入端口,停止从所述第一锁相环电路的反馈输入端口接收所述第一电路的时钟信号输出端口输出的时钟信号。时钟切换方法还包括:所述第一锁相环电路根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号之前,关闭所述第一锁相环电路的振荡器反馈端口,停止从所述第一锁相环电路的振荡器反馈端口接收所述振荡器提供的时钟信号,并打开所述第一锁相环电路的反馈输入端口。所述第一锁相环电路在工作状态为相位补偿状态时,根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,包括:所述第一锁相环电路在工作状态为相位补偿状态时,根据所述备时钟信号、从所述锁相环电路的反馈输入端口接收的时钟反馈信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。In a possible implementation manner, the first circuit provides a clock signal to the first load through a clock signal output port of the first circuit, and the clock signal output port of the first circuit is connected to the first The feedback clock signal input port of the circuit is connected, and the feedback clock signal input port of the first circuit is connected with the feedback input port of the first phase-locked loop circuit. The clock switching method further includes: before the first phase-locked loop circuit rebuilds the phase of the standby clock signal, closing the feedback input port of the first phase-locked loop circuit and stopping the output from the first phase-locked loop circuit The feedback input port of the first circuit receives the clock signal output by the clock signal output port of the first circuit. The clock switching method further includes: before the first phase-locked loop circuit continuously adjusts the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, Close the oscillator feedback port of the first phase-locked loop circuit, stop receiving the clock signal provided by the oscillator from the oscillator feedback port of the first phase-locked loop circuit, and open the first phase-locked loop circuit feedback input port. The first phase-locked loop circuit continuously adjusts the phase of the first reconstruction clock signal according to the backup clock signal and the preset phase adjustment speed to generate a plurality of adjustment clocks when the working state is the phase compensation state Signals, including: when the first phase-locked loop circuit is in the phase compensation state, according to the standby clock signal, the clock feedback signal received from the feedback input port of the phase-locked loop circuit and the preset phase The adjustment speed continuously adjusts the phase of the first reconstruction clock signal to generate a plurality of adjustment clock signals.

在相位补偿过程中,根据备时钟信号和第一电路的时钟信号输出端口输出的反馈时钟信号对重建后的时钟信号的相位进行补偿,使得第一电路的时钟信号输出端口输出的最终生成的调整时钟信号的相位与备时钟信号的相位一致,从而保证了所有第一电路向各处理器提供的时钟信号的相位完全一致。In the phase compensation process, the phase of the reconstructed clock signal is compensated according to the standby clock signal and the feedback clock signal output by the clock signal output port of the first circuit, so that the final generated adjustment of the clock signal output port of the first circuit The phase of the clock signal is consistent with the phase of the standby clock signal, thereby ensuring that the phases of the clock signals provided by all the first circuits to the processors are completely consistent.

在一种可能的实施方式中,所述第一锁相环电路在工作状态为相位重建状态时,对所述备时钟信号的相位进行重建,生成第一重建时钟信号,包括:所述第一锁相环电路在工作状态为相位重建状态时,根据相位差对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述相位差为所述备时钟信号与异常前的所述主时钟信号之间的相位差。In a possible implementation manner, when the working state of the first phase-locked loop circuit is a phase reconstruction state, the phase of the standby clock signal is reconstructed to generate a first reconstruction clock signal, including: the first When the phase-locked loop circuit is in the phase reconstruction state, the phase of the standby clock signal is reconstructed according to the phase difference to generate the first reconstruction clock signal, and the phase difference is the difference between the standby clock signal and the abnormality before Phase difference between master clock signals.

在一种可能的实施方式中,所述相位差为所述备时钟信号与异常前所述第一电路最后确定的主时钟信号之间的相位差。In a possible implementation manner, the phase difference is a phase difference between the standby clock signal and the main clock signal finally determined by the first circuit before the abnormality.

在一种可能的实施方式中,所述备时钟信号的频率根据所述主时钟电路在预设时间段内提供的主时钟信号的频率平均值确定。In a possible implementation manner, the frequency of the standby clock signal is determined according to an average frequency of the main clock signal provided by the main clock circuit within a preset time period.

通过采用两个时钟电路为多处理器服务器系统中的处理器供电,提高了时钟源的稳定性,避免了采用单个稳定精准时钟源通过主备两个时钟电路同时向各处理器提供时钟信号,降低了时钟系统的时钟成本。By using two clock circuits to supply power to the processors in the multi-processor server system, the stability of the clock source is improved, and it is avoided to use a single stable and accurate clock source to provide clock signals to each processor at the same time through two active and standby clock circuits. The clock cost of the clock system is reduced.

第二方面,本申请实施例还提供一种时钟切换装置,用于执行上述第一方面的时钟切换方法,具有相同的技术特征和技术效果。本申请对此不再赘述。In the second aspect, the embodiment of the present application further provides a clock switching device, configured to implement the clock switching method in the first aspect above, and has the same technical features and technical effects. This application will not repeat this.

本申请实施例第二方面提供一种时钟切换装置,包括第一电路,所述第一电路分别与主时钟电路、备时钟电路和第一负载连接。A second aspect of the embodiments of the present application provides a clock switching device, including a first circuit, and the first circuit is respectively connected to a main clock circuit, a backup clock circuit, and a first load.

所述第一电路用于,在主时钟信号正常时,接收所述主时钟信号后,向所述第一负载提供所述主时钟信号,所述主时钟信号由所述主时钟电路提供;The first circuit is configured to, when the main clock signal is normal, provide the main clock signal to the first load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit;

所述第一电路还用于,在所述主时钟信号异常时,接收备时钟信号,所述备时钟信号由所述备时钟电路提供。The first circuit is further configured to receive a backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by the backup clock circuit.

所述第一电路还用于,对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述第一重建时钟信号的相位与异常前的所述主时钟信号的相位一致。The first circuit is further configured to reconstruct the phase of the standby clock signal to generate a first reconstructed clock signal, where the phase of the first reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality.

所述第一电路还用于,向所述第一负载提供所述第一重建时钟信号。The first circuit is further configured to provide the first reconstruction clock signal to the first load.

所述第一电路还用于,根据所述备时钟信号和预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,所述多个调整时钟信号中最后生成的调整时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的调整时钟信号,所述多个调整时钟信号中其他的调整时钟信号的相位介于所述第一重建时钟信号的相位和所述备时钟信号的相位之间;The first circuit is further configured to continuously adjust the phase of the first reconstructed clock signal according to the standby clock signal and a preset phase adjustment speed to generate a plurality of adjusted clock signals, among the plurality of adjusted clock signals The phase of the last generated adjustment clock signal is equal to the phase of the standby clock signal, except for the last generated adjustment clock signal, the phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phases of the first reconstruction clock between the phase of the signal and the phase of the standby clock signal;

所述第一电路还用于,每次调整后向所述第一负载提供调整后生成的所述调整时钟信号。The first circuit is further configured to provide the adjusted clock signal generated after adjustment to the first load after each adjustment.

在一种可能的实施方式中,所述预设相位调整速度的取值范围为1-10微秒/秒。In a possible implementation manner, the value range of the preset phase adjustment speed is 1-10 microseconds/second.

在一种可能的实施方式中,时钟切换装置还包括:第二电路;所述第二电路分别与所述主时钟电路、所述备时钟电路和第二负载连接;In a possible implementation manner, the clock switching device further includes: a second circuit; the second circuit is respectively connected to the main clock circuit, the backup clock circuit and a second load;

所述第二电路用于,在主时钟信号正常时,接收所述主时钟信号后,向所述第二负载提供所述主时钟信号,所述主时钟信号由所述主时钟电路提供;The second circuit is configured to, when the main clock signal is normal, provide the main clock signal to the second load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit;

所述第二电路还用于,在所述主时钟信号异常时,接收备时钟信号,所述备时钟信号由所述备时钟电路提供;The second circuit is further configured to receive a backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by the backup clock circuit;

所述第二电路还用于,对所述备时钟信号的相位进行重建,生成第二重建时钟信号,所述第二重建时钟信号的相位与异常前的所述主时钟信号的相位一致;The second circuit is further configured to reconstruct the phase of the standby clock signal to generate a second reconstructed clock signal, where the phase of the second reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality;

所述第二电路还用于,向所述第二负载提供所述第二重建时钟信号;The second circuit is further configured to provide the second reconstruction clock signal to the second load;

所述第二电路还用于,根据所述备时钟信号和所述预设相位调整速度对所述第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,所述多个补偿时钟信号中最后生成的补偿时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的补偿时钟信号,所述多个补偿时钟信号中其他的补偿时钟信号的相位介于所述第二重建时钟信号的相位和所述备时钟信号的相位之间;The second circuit is further configured to continuously adjust the phase of the second reconstruction clock signal according to the backup clock signal and the preset phase adjustment speed to generate a plurality of compensation clock signals, and the plurality of compensation clock signals The phase of the last generated compensation clock signal in the signal is equal to the phase of the standby clock signal, except for the last generated compensation clock signal, the phases of other compensation clock signals in the plurality of compensation clock signals are between the second Between the phase of the reconstructed clock signal and the phase of the standby clock signal;

所述第二电路还用于,每次调整后向所述第二负载提供调整后生成的所述补偿时钟信号。The second circuit is further configured to provide the adjusted and generated compensation clock signal to the second load after each adjustment.

在一种可能的实施方式中,第二电路和第一电路的结构相同;第一负载可以包括一个或多个处理器,第二负载也可以包括一个或多个处理器。In a possible implementation manner, the structure of the second circuit is the same as that of the first circuit; the first load may include one or more processors, and the second load may also include one or more processors.

在一种可能的实施方式中,所述第一电路包括第一控制电路和第一锁相环电路,所述第一控制电路与所述第一锁相环电路连接;In a possible implementation manner, the first circuit includes a first control circuit and a first phase-locked loop circuit, and the first control circuit is connected to the first phase-locked loop circuit;

所述第一控制电路用于,在所述主时钟信号异常时,将所述第一锁相环电路的工作状态设置为相位重建状态;The first control circuit is configured to set the working state of the first phase-locked loop circuit to a phase reconstruction state when the main clock signal is abnormal;

所述第一锁相环电路用于,在工作状态为相位重建状态时,对所述备时钟信号的相位进行重建,生成第一重建时钟信号;The first phase-locked loop circuit is configured to, when the working state is a phase reconstruction state, reconstruct the phase of the standby clock signal to generate a first reconstruction clock signal;

所述第一控制电路还用于,确定所述第一锁相环电路生成所述第一重建时钟信号,将所述第一锁相环电路的工作状态设置为相位补偿状态;The first control circuit is further configured to determine that the first phase-locked loop circuit generates the first reconstruction clock signal, and set the working state of the first phase-locked loop circuit to a phase compensation state;

所述第一锁相环电路还用于,在工作状态为相位补偿状态时,根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。The first phase-locked loop circuit is further configured to continuously adjust the phase of the first reconstruction clock signal according to the standby clock signal and the preset phase adjustment speed when the working state is the phase compensation state to generate Multiple adjustment clock signals.

在一种可能的实施方式中,所述第一电路通过所述第一电路的时钟信号输出端口向所述第一负载提供时钟信号,所述第一电路的时钟信号输出端口与所述第一电路的反馈时钟信号输入端口连接,所述第一电路的反馈时钟信号输入端口与所述第一锁相环电路的反馈输入端口连接;In a possible implementation manner, the first circuit provides a clock signal to the first load through a clock signal output port of the first circuit, and the clock signal output port of the first circuit is connected to the first The feedback clock signal input port of the circuit is connected, and the feedback clock signal input port of the first circuit is connected to the feedback input port of the first phase-locked loop circuit;

所述第一锁相环电路还用于,在对所述备时钟信号的相位进行重建之前,关闭所述第一锁相环电路的反馈输入端口,停止从所述第一锁相环电路的反馈输入端口接收所述第一电路的时钟信号输出端口输出的时钟信号;The first phase-locked loop circuit is also used to close the feedback input port of the first phase-locked loop circuit and stop the feedback from the first phase-locked loop circuit before rebuilding the phase of the standby clock signal. The feedback input port receives the clock signal output by the clock signal output port of the first circuit;

所述第一锁相环电路还用于,在根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号之前,关闭所述第一锁相环电路的振荡器反馈端口,停止从所述第一锁相环电路的振荡器反馈端口接收所述振荡器提供的时钟信号,并打开所述第一锁相环电路的反馈输入端口;The first phase-locked loop circuit is further configured to, before continuously adjusting the phase of the first reconstruction clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjustment clock signals, turn off The oscillator feedback port of the first phase-locked loop circuit stops receiving the clock signal provided by the oscillator from the oscillator feedback port of the first phase-locked loop circuit, and opens the Feedback input port;

所述第一锁相环电路还用于,在工作状态为相位补偿状态时,根据所述备时钟信号、从所述锁相环电路的反馈输入端口接收的时钟反馈信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。The first phase-locked loop circuit is also used to, when the working state is a phase compensation state, according to the standby clock signal, the clock feedback signal received from the feedback input port of the phase-locked loop circuit and the preset phase The adjustment speed continuously adjusts the phase of the first reconstruction clock signal to generate a plurality of adjustment clock signals.

在一种可能的实施方式中,所述第一锁相环电路具体用于,在工作状态为相位重建状态时,根据相位差对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述相位差为所述备时钟信号与异常前的所述主时钟信号之间的相位差。In a possible implementation manner, the first phase-locked loop circuit is specifically configured to, when the working state is the phase reconstruction state, reconstruct the phase of the standby clock signal according to the phase difference to generate the first reconstruction clock signal , the phase difference is a phase difference between the standby clock signal and the main clock signal before the abnormality.

在一种可能的实施方式中,所述相位差为所述备时钟信号与异常前所述第一电路最后确定的主时钟信号之间的相位差。In a possible implementation manner, the phase difference is a phase difference between the standby clock signal and the main clock signal finally determined by the first circuit before the abnormality.

在一种可能的实施方式中,所述备时钟信号的频率根据所述主时钟电路在预设时间段内提供的主时钟信号的频率平均值确定。In a possible implementation manner, the frequency of the standby clock signal is determined according to an average frequency of the main clock signal provided by the main clock circuit within a preset time period.

第三方面,本申请实施例还提供一种时钟切换装置,用于执行上述第一方面的时钟切换方法,具有相同的技术特征和技术效果。本申请对此不再赘述。In the third aspect, the embodiment of the present application further provides a clock switching device, configured to implement the clock switching method in the first aspect above, and has the same technical features and technical effects. This application will not repeat this.

本申请实施例第三方面提供一种时钟切换装置,包括:A third aspect of the embodiment of the present application provides a clock switching device, including:

第一时钟信号获取模块,用于在主时钟信号正常时,接收所述主时钟信号后,向第一负载提供所述主时钟信号,所述主时钟信号由与所述第一时钟信号获取模块连接的主时钟电路提供;The first clock signal acquisition module is configured to provide the main clock signal to the first load after receiving the main clock signal when the main clock signal is normal, and the main clock signal is obtained by the first clock signal acquisition module. The connected master clock circuit provides;

所述第一时钟信号获取模块,还用于在所述主时钟信号异常时,接收备时钟信号,所述备时钟信号由与所述第一时钟信号获取模块连接的备时钟电路提供;The first clock signal acquisition module is further configured to receive a backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by a backup clock circuit connected to the first clock signal acquisition module;

第一重建模块,用于对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述第一重建时钟信号的相位与异常前的所述主时钟信号的相位一致;向所述第一负载提供所述第一重建时钟信号;The first reconstruction module is configured to reconstruct the phase of the standby clock signal to generate a first reconstruction clock signal, the phase of the first reconstruction clock signal is consistent with the phase of the main clock signal before the abnormality; The first load provides the first reconstruction clock signal;

第一调整模块,用于根据所述备时钟信号和预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,所述多个调整时钟信号中最后生成的调整时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的调整时钟信号,所述多个调整时钟信号中其他的调整时钟信号的相位介于所述第一重建时钟信号的相位和所述备时钟信号的相位之间;每次调整后向所述第一负载提供调整后生成的所述调整时钟信号。The first adjustment module is configured to continuously adjust the phase of the first reconstruction clock signal according to the backup clock signal and a preset phase adjustment speed to generate a plurality of adjustment clock signals, and the last generated among the plurality of adjustment clock signals The phase of the adjusted clock signal is equal to the phase of the standby clock signal, except for the last generated adjusted clock signal, the phases of other adjusted clock signals in the plurality of adjusted clock signals are between that of the first reconstructed clock signal Between the phase and the phase of the standby clock signal; after each adjustment, the adjusted clock signal generated after adjustment is provided to the first load.

在一种可能的实施方式中,所述预设相位调整速度的取值范围为1-10微秒/秒。In a possible implementation manner, the value range of the preset phase adjustment speed is 1-10 microseconds/second.

在一种可能的实施方式中,时钟切换装置还包括:In a possible implementation manner, the clock switching device further includes:

第二时钟信号获取模块,用于在主时钟信号正常时,接收所述主时钟信号后,向第二负载提供所述主时钟信号,所述主时钟信号由与所述第二时钟信号获取模块连接的主时钟电路提供;The second clock signal acquisition module is configured to provide the main clock signal to the second load after receiving the main clock signal when the main clock signal is normal, and the main clock signal is obtained by the second clock signal acquisition module. The connected master clock circuit provides;

所述第二时钟信号获取模块还用于,在所述主时钟信号异常时,接收备时钟信号,所述备时钟信号由与所述第二时钟信号获取模块连接的备时钟电路提供;The second clock signal acquisition module is further configured to receive a backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by a backup clock circuit connected to the second clock signal acquisition module;

第二重建模块,用于对所述备时钟信号的相位进行重建,生成第二重建时钟信号,所述第二重建时钟信号的相位与异常前的所述主时钟信号的相位一致;向所述第二负载提供所述第二重建时钟信号;The second reconstruction module is configured to reconstruct the phase of the standby clock signal to generate a second reconstruction clock signal, the phase of the second reconstruction clock signal is consistent with the phase of the main clock signal before the abnormality; a second load provides the second reconstruction clock signal;

第二调整模块,用于根据所述备时钟信号和所述预设相位调整速度对所述第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,所述多个补偿时钟信号中最后生成的补偿时钟信号的相位等于所述备时钟信号的相位,除所述最后生成的补偿时钟信号,所述多个补偿时钟信号中其他的补偿时钟信号的相位介于所述第二重建时钟信号的相位和所述备时钟信号的相位之间;每次调整后向所述第二负载提供调整后生成的所述补偿时钟信号。The second adjustment module is configured to continuously adjust the phase of the second reconstruction clock signal according to the backup clock signal and the preset phase adjustment speed to generate a plurality of compensation clock signals, among the plurality of compensation clock signals The phase of the last generated compensation clock signal is equal to the phase of the standby clock signal, except for the last generated compensation clock signal, the phases of other compensation clock signals in the plurality of compensation clock signals are between the phases of the second reconstruction clock Between the phase of the signal and the phase of the standby clock signal; providing the adjusted and generated compensated clock signal to the second load after each adjustment.

在一种可能的实施方式中,第二重建模块和第一重建模块相同,第二调整模块和第一调整模块相同;第一负载可以包括一个或多个处理器,第二负载也可以包括一个或多个处理器。In a possible implementation manner, the second reconstruction module is the same as the first reconstruction module, and the second adjustment module is the same as the first adjustment module; the first load may include one or more processors, and the second load may also include a or multiple processors.

在一种可能的实施方式中,时钟切换装置还包括:In a possible implementation manner, the clock switching device further includes:

第一控制模块,用于在所述主时钟信号异常时,将所述第一重建模块设置为工作状态;A first control module, configured to set the first reconstruction module to a working state when the main clock signal is abnormal;

所述第一控制模块还用于,确定所述第一重建模块生成所述第一重建时钟信号后,将所述第一调整模块设置为工作状态。The first control module is further configured to set the first adjustment module to a working state after determining that the first reconstruction module generates the first reconstruction clock signal.

在一种可能的实施方式中,所述时钟切换装置通过所述时钟切换装置的时钟信号输出端口向所述第一负载提供时钟信号,所述时钟切换装置的时钟信号输出端口与所述时钟切换装置的反馈时钟信号输入端口连接,所述时钟切换装置的反馈时钟信号输入端口与所述第一调整模块的反馈输入端口连接;In a possible implementation manner, the clock switching device provides a clock signal to the first load through a clock signal output port of the clock switching device, and the clock signal output port of the clock switching device is connected to the clock switching device. The feedback clock signal input port of the device is connected, and the feedback clock signal input port of the clock switching device is connected to the feedback input port of the first adjustment module;

所述第一控制模块还用于,在所述第一重建模块对所述备时钟信号的相位进行重建之前,关闭所述第一调整模块的反馈输入端口,停止从所述第一调整模块的反馈输入端口接收所述时钟切换装置的时钟信号输出端口输出的时钟信号;The first control module is further configured to, before the first reconstruction module rebuilds the phase of the backup clock signal, close the feedback input port of the first adjustment module, and stop the output from the first adjustment module. The feedback input port receives the clock signal output by the clock signal output port of the clock switching device;

所述第一控制模块还用于,在所述第一调整模块根据所述备时钟信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号之前,关闭所述第一调整模块的调整反馈端口,停止从所述第一调整模块的调整反馈端口接收所述第一调整模块提供的时钟信号,并打开所述第一调整模块的反馈输入端口;The first control module is further configured to continuously adjust the phase of the first reconstruction clock signal according to the backup clock signal and the preset phase adjustment speed in the first adjustment module to generate a plurality of adjustment clocks Before the signal, close the adjustment feedback port of the first adjustment module, stop receiving the clock signal provided by the first adjustment module from the adjustment feedback port of the first adjustment module, and open the feedback input of the first adjustment module port;

所述第一调整模块还用于,根据所述备时钟信号、从所述第一调整模块的反馈输入端口接收的时钟反馈信号和所述预设相位调整速度对所述第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。The first adjustment module is further configured to adjust the speed of the first reconstructed clock signal according to the backup clock signal, the clock feedback signal received from the feedback input port of the first adjustment module, and the preset phase adjustment speed. The phase is continuously adjusted to generate multiple adjusted clock signals.

在一种可能的实施方式中,所述第一重建模块还用于,根据相位差对所述备时钟信号的相位进行重建,生成第一重建时钟信号,所述相位差为所述备时钟信号与异常前的所述主时钟信号之间的相位差。In a possible implementation manner, the first reconstruction module is further configured to reconstruct the phase of the standby clock signal according to a phase difference to generate a first reconstruction clock signal, the phase difference being the phase difference of the standby clock signal The phase difference from the master clock signal before the exception.

在一种可能的实施方式中,所述相位差为所述备时钟信号与异常前所述第一电路最后确定的主时钟信号之间的相位差。In a possible implementation manner, the phase difference is a phase difference between the standby clock signal and the main clock signal finally determined by the first circuit before the abnormality.

在一种可能的实施方式中,所述备时钟信号的频率根据所述主时钟电路在预设时间段内提供的主时钟信号的频率平均值确定。In a possible implementation manner, the frequency of the standby clock signal is determined according to an average frequency of the main clock signal provided by the main clock circuit within a preset time period.

在一种可能的实施方式中,时钟切换装置还包括:第二控制模块,用于在所述主时钟信号异常时,将所述第二重建模块设置为工作状态。所述第二控制模块还用于,确定所述第二重建模块生成所述第二重建时钟信号后,将所述第二调整模块设置为工作状态。所述第二控制模块与第二调整模块、第二重建模块的通信方式与所述第一控制模块同所述第一调整模块和所述第一重建模块的通信方式相同,第二控制模块与第二调整模块、第二重建模块的通信方式可以参考所述第一控制模块同所述第一调整模块和所述第一重建模块的通信方式,细节在此不再赘述。In a possible implementation manner, the clock switching device further includes: a second control module, configured to set the second reconstruction module to a working state when the main clock signal is abnormal. The second control module is further configured to set the second adjustment module to a working state after determining that the second reconstruction module generates the second reconstruction clock signal. The communication mode between the second control module, the second adjustment module and the second reconstruction module is the same as the communication mode between the first control module, the first adjustment module and the first reconstruction module, and the second control module communicates with the first reconstruction module. For the communication manner between the second adjustment module and the second reconstruction module, reference may be made to the communication manner between the first control module, the first adjustment module, and the first reconstruction module, and the details will not be repeated here.

第四方面,本申请实施例还提供一种服务器,包括一个或多个负载,以及包括与所有负载的数量相同的一个或多个时钟切换装置,所有负载与所有时钟切换装置一一对应连接,所述时钟切换装置为如上述第二方面中任一可能的实施方式中所述的时钟切换装置,所述时钟切换装置的时钟信号输出端口与对应的所述负载连接,为对应的所述负载提供时钟信号。In a fourth aspect, the embodiment of the present application further provides a server, including one or more loads, and one or more clock switching devices having the same number as all loads, and all loads are connected to all clock switching devices in a one-to-one correspondence, The clock switching device is the clock switching device as described in any possible implementation manner of the second aspect above, and the clock signal output port of the clock switching device is connected to the corresponding load, which is the corresponding load Provides a clock signal.

第五方面,本申请实施例还提供一种时钟系统,包括主时钟电路、备时钟电路和至少一个如上述第四方面所述的服务器,所有服务器的所有时钟切换装置与所述主时钟电路和所述备时钟电路连接。In the fifth aspect, the embodiment of the present application also provides a clock system, including a main clock circuit, a backup clock circuit and at least one server as described in the fourth aspect above, and all clock switching devices of all servers are connected with the main clock circuit and the The standby clock circuit is connected.

在一种可能的实施方式中,所述服务器的负载包括至少一个处理器,或所述服务器的所述负载包括至少一个处理器和一个节点控制器,所述负载的所有处理器和所述节点控制器与所述负载对应的所述时钟切换装置连接,所述系统的所有服务器的所有节点控制器相互连接。In a possible implementation manner, the load of the server includes at least one processor, or the load of the server includes at least one processor and a node controller, and all processors of the load and the node The controller is connected to the clock switching device corresponding to the load, and all node controllers of all servers in the system are connected to each other.

第六方面,本申请实施例还提供一种时钟系统包括第一节点服务器、主时钟电路和备时钟电路,第一节点服务器包括第一时钟切换装置和第一处理器;第一时钟切换装置为上述第二方面中任一可能的实施方式中所述的时钟切换装置。所述第一时钟切换装置分别与所述主时钟电路和所述备时钟电路连接,用于接收所述主时钟电路提供的主时钟信号和所述备时钟电路提供的备时钟信号。所述第一时钟切换装置还与所述第一处理器连接,用于向所述第一处理器提供时钟信号。In the sixth aspect, the embodiment of the present application also provides a clock system including a first node server, a main clock circuit and a backup clock circuit, the first node server includes a first clock switching device and a first processor; the first clock switching device is The clock switching device described in any possible implementation manner of the second aspect above. The first clock switching device is respectively connected to the main clock circuit and the backup clock circuit, and is used to receive the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The first clock switching device is also connected to the first processor for providing a clock signal to the first processor.

在一种可能的实施方式中,所述第一节点服务器还包括第二时钟切换装置和第二处理器;第二时钟切换装置为上述第二方面中任一可能的实施方式中所述的时钟切换装置。所述第二时钟切换装置分别与所述主时钟电路和所述备时钟电路连接,用于接收所述主时钟电路提供的主时钟信号和所述备时钟电路提供的备时钟信号。所述第二时钟切换装置还与所述第二处理器连接,用于向所述第二处理器提供时钟信号。In a possible implementation manner, the first node server further includes a second clock switching device and a second processor; the second clock switching device is the clock described in any possible implementation manner of the second aspect above Switch device. The second clock switching device is respectively connected to the main clock circuit and the backup clock circuit, and is used to receive the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The second clock switching device is also connected to the second processor for providing a clock signal to the second processor.

在一种可能的实施方式中,所述第一节点服务器还包括第三处理器和第一节点控制器,所述第三处理器与第一节点控制器分别和所述第一时钟切换装置连接,接收所述第一时钟切换装置提供的时钟信号。所述第一节点服务器还包括第四处理器和第二节点控制器,所述第四处理器与所述第二节点控制器分别和所述第二时钟切换装置连接,所述第一节点控制器和所述第二节点控制器连接,接收所述第二时钟切换装置提供的时钟信号。In a possible implementation manner, the first node server further includes a third processor and a first node controller, and the third processor and the first node controller are respectively connected to the first clock switching device , receiving the clock signal provided by the first clock switching device. The first node server further includes a fourth processor and a second node controller, the fourth processor and the second node controller are respectively connected to the second clock switching device, and the first node controls The device is connected to the second node controller to receive the clock signal provided by the second clock switching device.

在一种可能的实施方式中,所述时钟系统还包括第二节点服务器,所述第二节点服务器包括第三时钟切换装置和第五处理器;第三时钟切换装置为上述第二方面中任一可能的实施方式中所述的时钟切换装置。所述第三时钟切换装置分别与所述主时钟电路和所述备时钟电路连接,用于接收所述主时钟电路提供的主时钟信号和所述备时钟电路提供的备时钟信号。所述第三时钟切换装置还与所述第五处理器连接,用于向所述第五处理器提供时钟信号。In a possible implementation manner, the clock system further includes a second node server, and the second node server includes a third clock switching device and a fifth processor; the third clock switching device is any A clock switching device described in a possible implementation manner. The third clock switching device is respectively connected to the main clock circuit and the backup clock circuit, and is used to receive the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The third clock switching device is also connected to the fifth processor for providing a clock signal to the fifth processor.

在一种可能的实施方式中,所述第二节点服务器还包括第四时钟切换装置和第六处理器;第四时钟切换装置为上述第二方面中任一可能的实施方式中所述的时钟切换装置。所述第四时钟切换装置分别与所述主时钟电路和所述备时钟电路连接,用于接收所述主时钟电路提供的主时钟信号和所述备时钟电路提供的备时钟信号。所述第四时钟切换装置还与所述第六处理器连接,用于向所述第六处理器提供时钟信号。In a possible implementation manner, the second node server further includes a fourth clock switching device and a sixth processor; the fourth clock switching device is the clock described in any possible implementation manner in the second aspect above Switch device. The fourth clock switching device is respectively connected to the main clock circuit and the backup clock circuit, and is used for receiving the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The fourth clock switching device is also connected to the sixth processor for providing a clock signal to the sixth processor.

在一种可能的实施方式中,所述第二节点服务器还包括第七处理器和第三节点控制器,所述第七处理器与所述第三节点控制器分别和所述第四时钟切换装置连接。所述第二节点服务器还包括第八处理器和第四节点控制器,所述第八处理器与所述第四节点控制器分别和所述第四时钟切换装置连接,所述第一节点控制器、所述第二节点控制器、所述第三节点控制器和所述第四节点控制器连接。In a possible implementation manner, the second node server further includes a seventh processor and a third node controller, and the seventh processor and the third node controller are respectively switched to the fourth clock device connection. The second node server further includes an eighth processor and a fourth node controller, the eighth processor and the fourth node controller are respectively connected to the fourth clock switching device, and the first node controls controller, the second node controller, the third node controller and the fourth node controller are connected.

附图说明Description of drawings

图1为本申请实施例提供的一种时钟系统的架构示意图;FIG. 1 is a schematic structural diagram of a clock system provided by an embodiment of the present application;

图2为本申请实施例一提供的时钟切换方法的流程示意图;FIG. 2 is a schematic flowchart of a clock switching method provided in Embodiment 1 of the present application;

图3为本申请实施例一提供的时钟信号的时序示意图;FIG. 3 is a schematic timing diagram of a clock signal provided in Embodiment 1 of the present application;

图4为本申请实施例一提供的时钟切换装置的结构示意图;FIG. 4 is a schematic structural diagram of a clock switching device provided in Embodiment 1 of the present application;

图5为本申请实施例二提供的时钟切换装置的结构示意图;FIG. 5 is a schematic structural diagram of a clock switching device provided in Embodiment 2 of the present application;

图6为本申请实施例二提供的时钟切换方法的流程示意图;FIG. 6 is a schematic flowchart of a clock switching method provided in Embodiment 2 of the present application;

图7为本申请实施例三提供的时钟切换装置的结构示意图。FIG. 7 is a schematic structural diagram of a clock switching device provided in Embodiment 3 of the present application.

具体实施方式Detailed ways

下面结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。The technical solutions in the embodiments of the present application are described below with reference to the drawings in the embodiments of the present application.

在时钟源故障的情况下,为保证节点服务器的运行不受影响,本申请实施例提供的时钟系统采用时钟源冗余设计,使用主、备两个时钟电路作为节点服务器的时钟源,通过主、备两个时钟电路为节点服务器提供时钟信号,在其中一个时钟电路提供的时钟信号异常时,节点服务器接收另一个时钟电路提供的时钟信号。该时钟系统的一种具体实现可参考图1,图1为本申请实施例提供的一种时钟系统的架构示意图。如图1所示,该时钟系统至少包括主时钟电路101、备时钟电路102和至少一个节点服务器103。时钟系统正常时,节点服务器103用于从主时钟电路101获取主时钟信号,在检测到主时钟电路提供的主时钟信号异常时,节点服务器用于从备时钟电路102获取备时钟信号。时钟系统中的至少一个节点服务器103可以是单处理器服务器,也可以是多处理器服务器。如果节点服务器103是单处理器服务器,节点服务器103包括一个处理器105。如果节点服务器103是多处理器服务器,节点服务器103包括多个处理器105。如果时钟系统包括至少两个节点服务器103,所有节点服务器103组合成一个多处理器服务系统,运行有一个操作系统。In the case of a clock source failure, in order to ensure that the operation of the node server is not affected, the clock system provided by the embodiment of the present application adopts a clock source redundancy design, and uses two main and standby clock circuits as the clock source of the node server. 1. Prepare two clock circuits to provide clock signals for the node server. When the clock signal provided by one of the clock circuits is abnormal, the node server receives the clock signal provided by the other clock circuit. For a specific implementation of the clock system, reference may be made to FIG. 1 , which is a schematic structural diagram of a clock system provided in an embodiment of the present application. As shown in FIG. 1 , the clock system at least includes a main clock circuit 101 , a backup clock circuit 102 and at least one node server 103 . When the clock system is normal, the node server 103 is used to obtain the main clock signal from the main clock circuit 101 , and when the main clock signal provided by the main clock circuit is detected to be abnormal, the node server is used to obtain the backup clock signal from the backup clock circuit 102 . At least one node server 103 in the clock system may be a single-processor server or a multi-processor server. The node server 103 includes one processor 105 if the node server 103 is a single processor server. If the node server 103 is a multiprocessor server, the node server 103 includes a plurality of processors 105 . If the clock system includes at least two node servers 103, all node servers 103 are combined into a multi-processor service system running an operating system.

节点服务器从备时钟电路获取的备时钟信号与异常前的主时钟信号之间存在相位差,为解决节点服务器的时钟源切换至备时钟电路后由于主、备时钟信号之间的相位不一致,导致节点服务器的运行不稳定的问题,节点服务器通过切换电路根据备时钟信号与异常前的主时钟信号之间的相位差,对切换后的备时钟信号进行相位重建,重建后的时钟信号的相位与异常前的主时钟电路提供的主时钟信号的相位一致。具体实现时,如图1所示,节点服务器103包括处理器105和与所述处理器105对应的切换电路104,处理器105与其对应的切换电路104连接,切换电路104分别与主时钟电路101、备时钟电路102连接。在主时钟电路101提供的主时钟信号异常时,节点服务器103通过该切换电路104切换时钟源,从备时钟电路102获取备时钟信号。节点服务器103获取备时钟信号后,根据预先记录的异常前的主时钟信号确定备时钟信号与异常前的主时钟信号之间的相位差,根据相位差对切换后的备时钟信号进行相位重建。There is a phase difference between the standby clock signal obtained by the node server from the standby clock circuit and the main clock signal before the abnormality. The operation of the node server is unstable. The node server reconstructs the phase of the switched standby clock signal through the switching circuit according to the phase difference between the standby clock signal and the main clock signal before the abnormality. The phase of the reconstructed clock signal is the same as The phases of the main clock signal supplied by the main clock circuit before the abnormality match. During specific implementation, as shown in Figure 1, the node server 103 includes a processor 105 and a switching circuit 104 corresponding to the processor 105, the processor 105 is connected to the switching circuit 104 corresponding to it, and the switching circuit 104 is connected to the master clock circuit 101 respectively. , The standby clock circuit 102 is connected. When the main clock signal provided by the main clock circuit 101 is abnormal, the node server 103 switches the clock source through the switching circuit 104 and obtains the standby clock signal from the standby clock circuit 102 . After acquiring the standby clock signal, the node server 103 determines the phase difference between the standby clock signal and the pre-abnormal master clock signal according to the pre-recorded master clock signal, and reconstructs the phase of the switched standby clock signal according to the phase difference.

时钟系统可以包括多个处理器和至少两个切换电路,例如时钟系统包括一个多处理器服务器和至少两个切换电路,其中,该多处理器服务器中的至少一个处理器与一个切换电路对应;或时钟系统包括由至少两个节点服务器组成的多处理器服务系统和至少两个切换电路,其中,每个节点服务器中的至少一个处理器与该节点服务器中的一个切换电路对应。在包括多个处理器的时钟系统中,各处理器的TSC均为同一个操作系统内核提供高精度时钟信号。各个处理器中的TSC的计数频率和相位一致,处理器所在的节点服务器的操作系统才可以正常工作。The clock system may include multiple processors and at least two switching circuits, for example, the clock system includes a multiprocessor server and at least two switching circuits, wherein at least one processor in the multiprocessor server corresponds to one switching circuit; Or the clock system includes a multiprocessor service system composed of at least two node servers and at least two switch circuits, wherein at least one processor in each node server corresponds to a switch circuit in the node server. In a clock system including multiple processors, the TSCs of each processor provide a high-precision clock signal for the same operating system kernel. The operating system of the node server where the processor is located can work normally only when the counting frequency and phase of the TSC in each processor are consistent.

在现有的包括多个处理器和至少两个切换电路的时钟系统中,不同的切换电路对同一时钟信号进行重建时的处理偏差不尽相同,所以不同的切换电路对备时钟信号进行相位重建后获得的时钟信号之间存在相位偏差,可能相位偏差也不尽相同,导致提供给各处理器的TSC的时钟信号的相位不一致,进而影响服务器的操作系统的正常工作。In an existing clock system including multiple processors and at least two switching circuits, different switching circuits have different processing deviations when reconstructing the same clock signal, so different switching circuits reconstruct the phase of the standby clock signal There is a phase deviation between the clock signals obtained later, and the phase deviation may be different, resulting in inconsistent phases of the clock signals provided to the TSCs of the processors, thereby affecting the normal operation of the operating system of the server.

在本申请实施例提供的时钟系统中,对于包括多个处理器和至少两个切换电路的时钟系统,为解决现有的不同的切换电路对同一备时钟信号进行重建时的处理偏差不尽相同,导致提供给各处理器的TSC的时钟信号的相位不一致的问题,切换电路对备时钟信号进行重建,生成重建后的时钟信号后,根据所述备时钟信号和预设相位调整速度对所述重建后的时钟信号的相位进行补偿,生成补偿后的时钟信号,由于所述补偿后的时钟信号的相位与所述备时钟信号的相位一致,解决了各切换电路对同一备时钟信号进行相位重建后获得的时钟信号之间存在相位偏差的问题。In the clock system provided by the embodiment of the present application, for a clock system including multiple processors and at least two switching circuits, in order to solve the different processing deviations when different existing switching circuits reconstruct the same standby clock signal , resulting in the inconsistency of the phases of the clock signals of the TSCs provided to each processor, the switching circuit reconstructs the standby clock signal, and after generating the reconstructed clock signal, adjusts the speed according to the standby clock signal and the preset phase. The phase of the reconstructed clock signal is compensated to generate a compensated clock signal. Since the phase of the compensated clock signal is consistent with the phase of the standby clock signal, it is solved that each switching circuit performs phase reconstruction on the same standby clock signal. There is a problem of phase deviation between the obtained clock signals.

本申请实施例提供的时钟系统,在具体实现时可以参照图1,节点服务器103至少可以包括至少一个切换电路104和至少一个处理器105。每个切换电路104与一个或多个处理器105连接。切换电路104分别与主时钟电路101和备时钟电路102连接,用于在主时钟电路101提供的主时钟信号正常时,接收主时钟电路101提供的主时钟信号,并将该主时钟信号提供给与切换电路104连接的处理器105;在主时钟电路101提供的主时钟信号异常时,将从主时钟电路101接收主时钟信号切换为从备时钟电路102接收备时钟信号,并将该备时钟信号的相位进行重建后提供给与切换电路104连接的处理器105,重建后的时钟信号的相位与主时钟电路提供的时钟信号的相位一致。The clock system provided by the embodiment of the present application can be implemented with reference to FIG. 1 , and the node server 103 can at least include at least one switching circuit 104 and at least one processor 105 . Each switching circuit 104 is connected to one or more processors 105 . The switching circuit 104 is connected with the main clock circuit 101 and the standby clock circuit 102 respectively, and is used for receiving the main clock signal provided by the main clock circuit 101 when the main clock signal provided by the main clock circuit 101 is normal, and providing the main clock signal to The processor 105 that is connected with switching circuit 104; When the main clock signal that main clock circuit 101 provides is abnormal, will receive main clock signal from main clock circuit 101 and switch to receive standby clock signal from standby clock circuit 102, and this standby clock The phase of the signal is reconstructed and provided to the processor 105 connected to the switching circuit 104, and the phase of the reconstructed clock signal is consistent with the phase of the clock signal provided by the main clock circuit.

示例性的,在图1所示的时钟系统中,主、备时钟电路与各切换电路之间可以通过线缆或同步以太网方式实现。主、备时钟电路采用双平面组网结构,备时钟电路通过互锁通路实现主备时钟的同步,主、备时钟电路之间的互锁通路可以通过线缆、背板或同步以太网方式实现。如果采用同步以太网方式实现主备时钟电路之间的连接,以及主备时钟电路与切换电路之间的连接时,可以减少采用电缆连接方式所带来的理线复杂、高成本等问题。Exemplarily, in the clock system shown in FIG. 1 , the connection between the main clock circuit and the backup clock circuit and each switching circuit can be realized through cables or synchronous Ethernet. The main and standby clock circuits adopt a dual-plane network structure, and the standby clock circuit realizes the synchronization of the main and standby clocks through an interlocking path. The interlocking path between the main and standby clock circuits can be realized through cables, backplanes or synchronous Ethernet. . If synchronous Ethernet is used to realize the connection between the main and standby clock circuits, as well as the connection between the main and standby clock circuits and the switching circuit, problems such as complicated line management and high cost caused by cable connection can be reduced.

示例性的,在图1所示的时钟系统中,主时钟电路101的时钟源由主时钟101电路包括的本地钟振自由震荡为主时钟电路101的锁相环提供,备时钟电路102通过互锁通路跟踪主时钟电路101提供的时钟信号的频率,使得备时钟电路102提供的时钟信号的频率与主时钟电路101提供的时钟信号的频率一致。因此,时钟系统中不需要额外的高精度时钟源设备为主、备时钟电路提供时钟信号,而是由各时钟电路的本地钟振自由震荡为时钟电路的锁相环提供时钟源,从而降低了对通信、计算机设备成本和数据中心机房部署的要求。以及,示例性的,一个节点服务器可以为一个物理节点服务器,例如一个服务器机柜群。当一个节点服务器为一个服务器机柜时,考虑到整个机柜上的所有处理器连接在同一个背板上成本较高,可将多个处理器连接在一个背板上,多个背板之间相互连接。一个背板上设置有一个节点控制器和至少一个处理器。其中,节点控制器(Node Controller,NC)用于管理和控制一个背板上的处理器,不同背板上的节点控制器通过电缆或光纤互连。通过将不同节点服务器或不同背板上的节点控制器互连,可实现处理器的远端内存访问。具体实现时,各节点控制器之间通过跨框高速互联总线以电缆或光纤连接。各切换电路提供的时钟信号同源,使得互联的节点控制器之间的互联总线两端的时钟频率和相位均相同,减少了互联总线上的传输延时,确保了不同处理器之间远端内存访问性能。以及,示例性的,处理器可以是多处理器服务器的运算核心和控制核心(control unit)。处理器中可以包括一个或多个处理器核(core)。处理器可以是一块超大规模的集成电路。可以理解的是,在本申请实施例中,处理器中的Core例如可以是中央处理器(central processing unit,CPU),还可以是其他特定集成电路(application specific integrated circuit,ASIC)。示例性的,如图1所示,切换电路104可通过扇出扩展器107将时钟信号分发给不同的处理器105、节点控制器106或其他器件。示例性的,对于属于一个缓存一致性总线域内的器件,由同一个切换电路104通过扇出扩展器107提供时钟信号。Exemplarily, in the clock system shown in FIG. 1 , the clock source of the main clock circuit 101 is provided by the phase-locked loop of the main clock circuit 101 from the free oscillation of the local clock included in the main clock circuit 101 circuit, and the backup clock circuit 102 is provided by the mutual The lock path tracks the frequency of the clock signal provided by the main clock circuit 101 , so that the frequency of the clock signal provided by the standby clock circuit 102 is consistent with the frequency of the clock signal provided by the main clock circuit 101 . Therefore, there is no need for additional high-precision clock source equipment in the clock system to provide clock signals for the main and backup clock circuits, but the free oscillation of the local clock oscillators of each clock circuit provides the clock source for the phase-locked loop of the clock circuit, thereby reducing Requirements for communications, computer equipment costs, and data center room deployment. And, exemplary, a node server may be a physical node server, such as a server rack group. When a node server is a server cabinet, considering the high cost of connecting all the processors in the entire cabinet to the same backplane, multiple processors can be connected to one backplane, and multiple backplanes are connected to each other. connect. A node controller and at least one processor are arranged on a backplane. Wherein, a node controller (Node Controller, NC) is used to manage and control processors on one backplane, and node controllers on different backplanes are interconnected through cables or optical fibers. By interconnecting different node servers or node controllers on different backplanes, processor remote memory access can be realized. During specific implementation, each node controller is connected with cables or optical fibers through a cross-frame high-speed interconnection bus. The clock signals provided by each switching circuit are of the same source, so that the clock frequency and phase at both ends of the interconnection bus between the interconnected node controllers are the same, reducing the transmission delay on the interconnection bus and ensuring the remote memory between different processors access performance. And, for example, the processor may be a calculation core and a control core (control unit) of a multi-processor server. A processor may include one or more processor cores (core). The processor can be a very large scale integrated circuit. It can be understood that, in the embodiment of the present application, the Core in the processor may be, for example, a central processing unit (central processing unit, CPU) or other specific integrated circuit (application specific integrated circuit, ASIC). Exemplarily, as shown in FIG. 1 , the switching circuit 104 can distribute the clock signal to different processors 105 , node controllers 106 or other devices through the fan-out expander 107 . Exemplarily, for devices belonging to one cache coherency bus domain, the same switching circuit 104 provides clock signals through the fan-out expander 107 .

如图1所示,节点服务器103包括至少两个切换电路104,在主时钟电路101提供的主时钟信号异常时,多个切换电路104同时进行时钟切换和时钟信号的相位重建。此时,由于各切换电路104之间存在不可避免的器件差异,各切换电路104对备时钟电路102提供的备时钟信号进行相位重建后获得的时钟信号之间存在相位偏差,导致提供给各处理器105的TSC的时钟信号的相位不一致,影响服务器的操作系统的正常工作。进一步的,当备时钟电路102提供的时钟信号异常时,切换电路104再次进行时钟切换和时钟信号的相位重建,此次切换电路104重建后的时钟信号的相位与上一次切换电路重建后的时钟信号的相位一致,但是不同切换电路之间在进行相位重建时仍存在相位偏差。因此,随着切换电路104进行时钟切换的次数的增加,各切换电路104提供给各处理器105的TSC的时钟信号的相位之间的相位偏差越来越大。例如,在主时钟电路101提供主时钟信号clk1,备时钟电路102提供备时钟信号clk2,当clk1出现异常时,第一切换电路根据clk1对clk2进行相位重建得到clk2_1,第二切换电路根据clk1对clk2进行相位重建得到clk2_2,clk2_1与clk2_2之间存在相位偏差Δ1。当clk2出现异常时,切换电路再次接收修复后的clk1,此时,第一切换电路根据clk2_1对clk1进行相位重建得到clk3_1,第二切换电路根据clk2_2对clk1进行相位重建得到clk3_2,clk3_1与clk3_2之间存在相位偏差Δ1+Δ2。当clk1再次出现异常时,切换电路再次接收修复后的clk2,此时,第一切换电路根据clk3_1对clk2进行相位重建得到clk4_1,第二切换电路根据clk3_2对clk2进行相位重建得到clk4_2,clk4_1与clk4_2之间存在相位偏差Δ1+Δ21+Δ3。As shown in FIG. 1 , the node server 103 includes at least two switching circuits 104. When the main clock signal provided by the main clock circuit 101 is abnormal, multiple switching circuits 104 simultaneously perform clock switching and phase reconstruction of the clock signal. At this time, due to the unavoidable device differences between the switching circuits 104, there is a phase deviation between the clock signals obtained after the phase reconstruction of the standby clock signal provided by the standby clock circuit 102 by each switching circuit 104, resulting in the The phases of the clock signals of the TSC of the controller 105 are inconsistent, which affects the normal operation of the operating system of the server. Further, when the clock signal provided by the standby clock circuit 102 is abnormal, the switching circuit 104 performs clock switching and phase reconstruction of the clock signal again, and the phase of the clock signal reconstructed by the switching circuit 104 this time is the same as that of the clock reconstructed by the switching circuit last time. The phases of the signals are consistent, but there are still phase deviations between different switching circuits when performing phase reconstruction. Therefore, as the number of times the switching circuits 104 perform clock switching increases, the phase deviation between the phases of the clock signals of the TSCs provided by each switching circuit 104 to each processor 105 becomes larger and larger. For example, the main clock circuit 101 provides the main clock signal clk1, and the backup clock circuit 102 provides the backup clock signal clk2. When clk1 is abnormal, the first switching circuit reconstructs the phase of clk2 according to clk1 to obtain clk2_1, and the second switching circuit performs phase reconstruction of clk2 according to clk1. clk2 performs phase reconstruction to obtain clk2_2, and there is a phase deviation Δ1 between clk2_1 and clk2_2. When clk2 is abnormal, the switching circuit receives the repaired clk1 again. At this time, the first switching circuit reconstructs the phase of clk1 according to clk2_1 to obtain clk3_1, and the second switching circuit reconstructs the phase of clk1 according to clk2_2 to obtain clk3_2. The difference between clk3_1 and clk3_2 There is a phase deviation Δ1+Δ2 between them. When clk1 is abnormal again, the switching circuit receives the repaired clk2 again. At this time, the first switching circuit reconstructs the phase of clk2 according to clk3_1 to obtain clk4_1, and the second switching circuit reconstructs the phase of clk2 according to clk3_2 to obtain clk4_2, clk4_1 and clk4_2 There is a phase deviation Δ1+Δ21+Δ3 between them.

为解决上述问题,本申请实施例提供一种时钟切换方法,切换电路104对备时钟信号进行重建,生成重建后的时钟信号后,通过对重建后的时钟信号进行相位补偿,使得补偿后的时钟信号的相位与备时钟时钟信号的相位一致,解决了各切换电路对备时钟信号进行相位重建后获得的时钟信号之间存在相位偏差的问题。In order to solve the above problems, the embodiment of the present application provides a clock switching method. The switching circuit 104 reconstructs the standby clock signal, and after generating the reconstructed clock signal, performs phase compensation on the reconstructed clock signal so that the compensated clock The phase of the signal is consistent with the phase of the standby clock signal, which solves the problem of phase deviation between the clock signals obtained after each switching circuit reconstructs the phase of the standby clock signal.

下面结合具体实施例对本申请实施例提供的时钟切换方法进行详细说明。本申请实施例一方面提供一种时钟切换方法。图2为本申请实施例一提供的时钟切换方法的流程示意图。如图2所示,本实施例提供的时钟切换方法,应用于如图1所示的时钟系统中的节点服务器103中,执行主体示例性的可以为切换电路104。本实施例中切换电路104在切换时钟信号时,首先对备时钟电路102提供的备时钟信号进行相位重建,然后对重建后的时钟信号进行相位补偿,使得调整后的时钟信号的相位与备时钟电路102提供的备时钟信号的相位一致,从而避免了不同切换电路104之间由于器件差异可能导致的重建后的时钟信号之间的相位差异。如图2所示,本实施例提供的时钟切换方法,包括:The clock switching method provided by the embodiment of the present application will be described in detail below in conjunction with specific embodiments. Embodiments of the present application provide, on the one hand, a clock switching method. FIG. 2 is a schematic flowchart of a clock switching method provided in Embodiment 1 of the present application. As shown in FIG. 2 , the clock switching method provided in this embodiment is applied to the node server 103 in the clock system shown in FIG. 1 , and the execution subject may be, for example, the switching circuit 104 . In this embodiment, when switching the clock signal, the switching circuit 104 firstly performs phase reconstruction on the standby clock signal provided by the standby clock circuit 102, and then performs phase compensation on the reconstructed clock signal, so that the phase of the adjusted clock signal is the same as that of the standby clock. The phases of the standby clock signals provided by the circuit 102 are consistent, thereby avoiding phase differences between the reconstructed clock signals that may be caused by device differences between different switching circuits 104 . As shown in Figure 2, the clock switching method provided in this embodiment includes:

S201、在检测到主时钟信号异常时,通过切换电路的备时钟信号输入端口接收备时钟信号。S201. Receive a standby clock signal through a standby clock signal input port of a switching circuit when an abnormality of the main clock signal is detected.

其中,主时钟信号由与切换电路连接的主时钟电路提供,备时钟信号由与切换电路连接的备时钟电路提供。Wherein, the main clock signal is provided by the main clock circuit connected to the switching circuit, and the backup clock signal is provided by the backup clock circuit connected to the switching circuit.

示例性的,在主时钟信号正常时,第一电路接收主时钟信号后,向第一负载提供主时钟信号,主时钟信号由与第一电路连接的主时钟电路提供。在主时钟信号异常时,第一电路接收备时钟信号,备时钟信号由与第一电路连接的备时钟电路提供。其中,第一电路示例性的可以为图1中的切换电路104,第一负载示例性的可以为图1中的一个或多个处理器105。Exemplarily, when the main clock signal is normal, the first circuit provides the main clock signal to the first load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit connected to the first circuit. When the main clock signal is abnormal, the first circuit receives the backup clock signal, and the backup clock signal is provided by the backup clock circuit connected to the first circuit. Wherein, the first circuit may be, for example, the switching circuit 104 in FIG. 1 , and the first load may be, for example, one or more processors 105 in FIG. 1 .

示例性的,当切换电路检测到主时钟信号异常时,切换电路开始进行时钟切换。示例性的,当切换电路检测或接收到主时钟电路故障、主时钟电路与切换电路连接线故障、备时钟电路与主时钟电路之间连接线故障、主备时钟信号之间的频率差超出预设范围等时,可认为主时钟信号异常。示例性的,当切换电路接收到时钟切换指令时,同样可认为主时钟信号异常,开始进行时钟切换。切换电路在进行时钟切换时,接收备时钟电路提供的备时钟信号。示例性的,切换电路还停止接收主时钟电路提供的主时钟信号,并提醒用户对主时钟电路进行故障检修。此时,备时钟电路作为新的主时钟电路,当主时钟电路恢复正常时,则作为新的备时钟电路,时钟切换的处理方式不变。Exemplarily, when the switching circuit detects that the main clock signal is abnormal, the switching circuit starts clock switching. Exemplarily, when the switching circuit detects or receives a failure of the main clock circuit, a failure of the connection line between the main clock circuit and the switching circuit, a failure of the connection line between the standby clock circuit and the main clock circuit, or a frequency difference between the main and standby clock signals exceeds the preset When setting the range, etc., it can be considered that the main clock signal is abnormal. Exemplarily, when the switching circuit receives the clock switching instruction, it may also consider that the main clock signal is abnormal, and start clock switching. When the switching circuit performs clock switching, it receives the standby clock signal provided by the standby clock circuit. Exemplarily, the switching circuit also stops receiving the main clock signal provided by the main clock circuit, and reminds the user to perform troubleshooting on the main clock circuit. At this time, the backup clock circuit is used as the new main clock circuit, and when the main clock circuit returns to normal, it is used as the new backup clock circuit, and the clock switching processing method remains unchanged.

示例性的,当主时钟电路提供的主时钟信号没有异常而备时钟电路提供的备时钟信号异常时,不进行时钟切换,仅提醒用户进行故障检修,使得备时钟电路重新恢复正常工作。Exemplarily, when the main clock signal provided by the main clock circuit is normal and the backup clock signal provided by the backup clock circuit is abnormal, clock switching is not performed, and the user is only reminded to perform troubleshooting so that the backup clock circuit resumes normal operation.

S202、对备时钟信号的相位进行重建,并生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟信号的相位一致。S202. Reconstruct the phase of the standby clock signal, and generate a reconstructed clock signal, where the phase of the reconstructed clock signal is consistent with the phase of the primary clock signal before the abnormality.

示例性的,第一电路对备时钟信号的相位进行重建,生成第一重建时钟信号,第一重建时钟信号的相位与异常前的主时钟信号的相位一致;第一电路向第一负载提供第一重建时钟信号。Exemplarily, the first circuit reconstructs the phase of the standby clock signal to generate a first reconstructed clock signal, and the phase of the first reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality; the first circuit provides the first load with the first - Reconstruct the clock signal.

示例性的,图3为本申请实施例一提供的时钟信号的时序示意图。备时钟电路提供的备时钟信号与主时钟电路提供的主时钟信号之间存在相位差如图3所示。当切换电路停止接收主时钟电路提供的主时钟信号,而接收备时钟电路提供的备时钟信号时,存在时钟信号相位变化较大的情况。本实施例中切换电路对接收到的备时钟信号进行相位重建,生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟电路提供的主时钟信号的相位一致,避免了由主备时钟信号之间的相位差而导致的处理器的不稳定。Exemplarily, FIG. 3 is a schematic timing diagram of clock signals provided in Embodiment 1 of the present application. There is a phase difference between the standby clock signal provided by the standby clock circuit and the main clock signal provided by the main clock circuit, as shown in FIG. 3 . When the switching circuit stops receiving the main clock signal provided by the main clock circuit and receives the backup clock signal provided by the backup clock circuit, there is a situation that the phase of the clock signal changes greatly. In this embodiment, the switching circuit reconstructs the phase of the received standby clock signal to generate a reconstructed clock signal. The phase of the reconstructed clock signal is consistent with the phase of the main clock signal provided by the main clock circuit before the abnormality, avoiding the Processor instability caused by the phase difference between the main and standby clock signals.

示例性的,图3以备时钟电路提供的备时钟信号的相位落后主时钟电路提供的主时钟信号的相位为例,本领域技术人员明白备时钟电路提供的备时钟信号的相位还可能超前主时钟电路提供的主时钟信号的相位,本申请实施例对此不做限定。Exemplarily, in FIG. 3, the phase of the standby clock signal provided by the standby clock circuit lags behind the phase of the main clock signal provided by the main clock circuit as an example. Those skilled in the art understand that the phase of the standby clock signal provided by the standby clock circuit may also be ahead of the main clock signal. The phase of the main clock signal provided by the clock circuit is not limited in this embodiment of the present application.

可选的,切换电路进行相位重建的过程,具体可以包括:Optionally, the process of switching the circuit to perform phase reconstruction may specifically include:

切换电路根据相位差对备时钟信号的相位进行重建,并生成重建后的时钟信号,相位差为备时钟信号与异常前的主时钟信号之间的相位差。The switching circuit reconstructs the phase of the standby clock signal according to the phase difference, and generates the reconstructed clock signal, where the phase difference is the phase difference between the standby clock signal and the main clock signal before abnormality.

示例性的,切换电路在进行相位重建时,可根据异常前的主时钟信号与异常后切换电路接收的备时钟信号之间的相位差,对备时钟信号的相位进行重建,重建后的时钟信号的相位取决于备时钟信号的相位以及相位差。示例性的,在进行相位重建时,首先根据异常前的主时钟信号和异常后切换电路接收的备时钟信号获取并存储相位差。由于不同的切换电路不可能完全一致,因此,各切换电路之间相位差的计算过程中,可能存在偏差,同时在根据相位差进行相位重建的过程中,由于重建电路也无法达到完全一致,还可能进一步扩大相位偏差。Exemplarily, when the switching circuit performs phase reconstruction, it can reconstruct the phase of the standby clock signal according to the phase difference between the main clock signal before the abnormality and the standby clock signal received by the switching circuit after the abnormality, and the reconstructed clock signal The phase of depends on the phase and phase difference of the standby clock signal. Exemplarily, when performing phase reconstruction, first, the phase difference is obtained and stored according to the main clock signal before the abnormality and the backup clock signal received by the switching circuit after the abnormality. Since it is impossible for different switching circuits to be completely consistent, there may be deviations in the calculation process of the phase difference between the switching circuits. It is possible to further expand the phase deviation.

S203、根据备时钟信号和预设相位调整速度对重建后的时钟信号的相位进行补偿,并生成补偿后的时钟信号,将补偿后的时钟信号通过切换电路的时钟信号输出端口输出,补偿后的时钟信号的相位与备时钟信号的相位一致。S203. Compensate the phase of the reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed, and generate a compensated clock signal, output the compensated clock signal through the clock signal output port of the switching circuit, and the compensated clock signal The phase of the clock signal is consistent with the phase of the standby clock signal.

示例性的,第一电路根据备时钟信号和预设相位调整速度对第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,多个调整时钟信号中最后生成的调整时钟信号的相位等于备时钟信号的相位,除最后生成的调整时钟信号,多个调整时钟信号中其他的调整时钟信号的相位介于第一重建时钟信号的相位和备时钟信号的相位之间;第一电路每次调整后向第一负载提供调整后生成的调整时钟信号。Exemplarily, the first circuit continuously adjusts the phase of the first reconstructed clock signal according to the backup clock signal and the preset phase adjustment speed to generate multiple adjusted clock signals, and the phase of the last generated adjusted clock signal among the multiple adjusted clock signals Equal to the phase of the standby clock signal, except for the last generated adjustment clock signal, the phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phase of the first reconstruction clock signal and the phase of the standby clock signal; the first circuit every After the second adjustment, the adjusted clock signal generated after adjustment is provided to the first load.

示例性的,考虑到不同切换电路进行相位重建后得到的重建后的时钟信号的相位之间存在相位偏差,且相位偏差可能随着切换次数的增多而累加,本实施例中对重建后的时钟信号的相位进行了相位补偿,生成与备时钟信号的相位一致的补偿后的时钟信号,由于不同切换电路生成的补偿后的时钟信号的相位均与备时钟电路提供的备时钟信号的相位一致,从而保证了各切换电路为各处理器的TSC提供的时钟信号的相位一致。同时,当切换电路进行多次切换时,由于切换电路在每次时钟切换后,都生成与备用时钟电路提供的备时钟信号一致的时钟信号,因此即使进行多次时钟切换,也并不存在偏差累积的情况。例如,在主时钟电路提供主时钟信号clk1,备时钟电路提供备时钟信号clk2,当clk1出现异常时,第一切换电路根据clk1对clk2进行相位重建和补偿得到clk2,第二切换电路根据clk1对clk2进行相位重建和补偿得到clk2,两个切换电路在时钟切换后提供的时钟信号之间没有相位偏差。当clk2出现异常时,切换电路再次接收修复后的clk1,此时,第一切换电路根据clk2对clk1进行相位重建和补偿得到clk1,第二切换电路根据clk2对clk1进行相位重建和补偿得到clk1,两个切换电路在时钟切换后提供的时钟信号之间没有相位偏差。示例性的,如图3所示,切换电路根据备时钟电路和预设相位调整速度将重建后的时钟信号调整为备时钟信号,在保证了时钟信号的相位不剧变的前提下,还保证了在时钟切换阶段,各切换电路输出的时钟信号的相位变化一致。可选的,预设相位调整速度的取值范围为1-10微秒/秒。Exemplarily, considering that there is a phase deviation between the phases of the reconstructed clock signals obtained after phase reconstruction by different switching circuits, and the phase deviation may accumulate as the number of switching times increases, the reconstructed clock signal in this embodiment The phase of the signal is phase compensated to generate a compensated clock signal that is consistent with the phase of the standby clock signal. Since the phases of the compensated clock signals generated by different switching circuits are consistent with the phase of the standby clock signal provided by the standby clock circuit, Therefore, it is ensured that the phases of the clock signals provided by the switching circuits to the TSCs of the processors are consistent. At the same time, when the switching circuit performs multiple switching, since the switching circuit generates a clock signal consistent with the standby clock signal provided by the standby clock circuit after each clock switching, there is no deviation even if multiple clock switching is performed cumulative situation. For example, the main clock circuit provides the main clock signal clk1, and the backup clock circuit provides the backup clock signal clk2. When clk1 is abnormal, the first switching circuit reconstructs and compensates the phase of clk2 according to clk1 to obtain clk2, and the second switching circuit uses clk1 to clk2 performs phase reconstruction and compensation to obtain clk2, and there is no phase deviation between clock signals provided by the two switching circuits after clock switching. When clk2 is abnormal, the switching circuit receives the repaired clk1 again. At this time, the first switching circuit performs phase reconstruction and compensation on clk1 according to clk2 to obtain clk1, and the second switching circuit performs phase reconstruction and compensation on clk1 according to clk2 to obtain clk1. There is no phase deviation between the clock signals provided by the two switching circuits after clock switching. Exemplarily, as shown in FIG. 3 , the switching circuit adjusts the reconstructed clock signal to the standby clock signal according to the standby clock circuit and the preset phase adjustment speed. On the premise of ensuring that the phase of the clock signal does not change drastically, it also ensures that In the clock switching stage, the phase changes of the clock signals output by each switching circuit are consistent. Optionally, the value range of the preset phase adjustment speed is 1-10 microseconds/second.

本申请实施例提供的时钟切换方法,应用于包括切换电路的服务器,切换电路在检测到主时钟信号异常时,通过切换电路的备时钟信号输入端口接收备时钟信号,对备时钟信号的相位进行重建,并生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟信号的相位一致;根据备时钟信号和预设相位调整速度对重建后的时钟信号的相位进行补偿,并生成补偿后的时钟信号,将补偿后的时钟信号通过切换电路的时钟信号输出端口输出,补偿后的时钟信号的相位与备时钟信号的相位一致。通过根据预设相位调整速度对重建的时钟信号的相位进行相位补偿,生成与备时钟信号相位一致的时钟信号,保证了多个切换电路补偿的时钟信号相位缓慢变化,且变化一致,使得各切换电路为各处理器的TSC提供的时钟信号的相位一致,避免了多处理器操作系统的不稳定运行,也避免了多次时钟切换可能造成的累积误差。The clock switching method provided by the embodiment of the present application is applied to a server including a switching circuit. When the switching circuit detects that the main clock signal is abnormal, it receives the standby clock signal through the standby clock signal input port of the switching circuit, and performs phase adjustment of the standby clock signal. Reconstruct and generate a reconstructed clock signal, the phase of the reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality; the phase of the reconstructed clock signal is compensated according to the standby clock signal and the preset phase adjustment speed, and A compensated clock signal is generated, and the compensated clock signal is output through the clock signal output port of the switching circuit, and the phase of the compensated clock signal is consistent with the phase of the standby clock signal. By performing phase compensation on the phase of the reconstructed clock signal according to the preset phase adjustment speed, a clock signal with the same phase as the standby clock signal is generated, which ensures that the phases of the clock signals compensated by multiple switching circuits change slowly and are consistent, so that each switch The phases of the clock signals provided by the circuit to the TSCs of each processor are consistent, avoiding the unstable operation of the multi-processor operating system and avoiding the cumulative error that may be caused by multiple clock switching.

示例性的,在图2所示实施例的基础上,本申请实施例还提供一种时钟切换方法。该方法应用于如图1所示的时钟系统,时钟系统中包括第一节点服务器,第一节点服务器包括第一切换电路和第二切换电路,以及与各切换电路连接的负载,负载包括至少一个处理器。其中,第一切换电路用于执行上述图2所示的时钟切换方法,第二切换切换执行的时钟切换方法包括:Exemplarily, on the basis of the embodiment shown in FIG. 2 , this embodiment of the present application further provides a clock switching method. The method is applied to the clock system shown in Figure 1, the clock system includes a first node server, the first node server includes a first switching circuit and a second switching circuit, and loads connected to each switching circuit, the load includes at least one processor. Wherein, the first switching circuit is used to execute the clock switching method shown in FIG. 2 above, and the clock switching method performed by the second switching circuit includes:

S11、在主时钟信号正常时,第二电路接收主时钟信号后,向第二负载提供主时钟信号,主时钟信号由与第二电路连接的主时钟电路提供;S11. When the main clock signal is normal, the second circuit provides the main clock signal to the second load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit connected to the second circuit;

S12、在主时钟信号异常时,第二电路接收备时钟信号,备时钟信号由与第二电路连接的备时钟电路提供;S12. When the main clock signal is abnormal, the second circuit receives the backup clock signal, and the backup clock signal is provided by the backup clock circuit connected to the second circuit;

S13、第二电路对备时钟信号的相位进行重建,生成第二重建时钟信号,第二重建时钟信号的相位与异常前的主时钟信号的相位一致;S13. The second circuit reconstructs the phase of the standby clock signal to generate a second reconstructed clock signal, and the phase of the second reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality;

S14、第二电路向第二负载提供第二重建时钟信号;S14. The second circuit provides a second reconstruction clock signal to the second load;

S15、第二电路根据备时钟信号和预设相位调整速度对第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,多个补偿时钟信号中最后生成的补偿时钟信号的相位等于备时钟信号的相位,除最后生成的补偿时钟信号,多个补偿时钟信号中其他的补偿时钟信号的相位介于第二重建时钟信号的相位和备时钟信号的相位之间;S15. The second circuit continuously adjusts the phase of the second reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate multiple compensation clock signals, and the phase of the last generated compensation clock signal among the multiple compensation clock signals is equal to the phase of the standby clock signal The phase of the clock signal, except for the last generated compensation clock signal, the phases of other compensation clock signals in the plurality of compensation clock signals are between the phase of the second reconstructed clock signal and the phase of the standby clock signal;

S16、第二电路每次调整后向第二负载提供调整后生成的补偿时钟信号。S16. The second circuit provides the adjusted and generated compensation clock signal to the second load after each adjustment.

其中,第二电路示例性的可以为图1中的第二切换电路,第二负载示例性的可以为图1中的第二处理器和/或第四处理器。Wherein, the second circuit may be, for example, the second switching circuit in FIG. 1 , and the second load may, for example, be the second processor and/or the fourth processor in FIG. 1 .

本申请实施例提供的时钟切换方法中,两个切换电路均根据预设相位调整速度对重建的时钟信号的相位进行相位补偿,生成与备时钟信号相位一致的时钟信号,确保了最后生成的调整时钟信号和补偿时钟信号的相位一致,保证了多个切换电路补偿的时钟信号相位缓慢变化,且变化一致,使得各切换电路为各处理器的TSC提供的时钟信号的相位一致,避免了多处理器操作系统的不稳定运行,也避免了多次时钟切换可能造成的累积误差。In the clock switching method provided in the embodiment of the present application, both switching circuits perform phase compensation on the phase of the reconstructed clock signal according to the preset phase adjustment speed, and generate a clock signal that is in phase with the standby clock signal, ensuring that the final generated clock signal is adjusted The phases of the clock signal and the compensation clock signal are consistent, ensuring that the phases of the clock signals compensated by multiple switching circuits change slowly and consistently, so that the phases of the clock signals provided by each switching circuit for the TSC of each processor are consistent, avoiding multiprocessing The unstable operation of the server operating system also avoids the cumulative error that may be caused by multiple clock switching.

本申请实施例另一方面提供一种时钟切换装置,用于执行上述图2所示实施例中的时钟切换方法,具有相同或相似的技术效果。Another aspect of the embodiments of the present application provides a clock switching device, which is used to implement the clock switching method in the above embodiment shown in FIG. 2 , and has the same or similar technical effects.

时钟切换装置包括如图1中的第一切换电路的第一电路,第一电路分别与主时钟电路101、备时钟电路102和第一负载连接;第一负载示例性的可以为图1中的第一处理器和/或第三处理器。The clock switching device includes a first circuit such as the first switching circuit in Figure 1, and the first circuit is respectively connected to the main clock circuit 101, the backup clock circuit 102 and the first load; the first load can be exemplarily the the first processor and/or the third processor.

第一电路用于,在主时钟信号正常时,接收主时钟信号后,向第一负载提供主时钟信号,主时钟信号由主时钟电路提供;The first circuit is configured to, when the main clock signal is normal, provide the main clock signal to the first load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit;

第一电路还用于,在主时钟信号异常时,接收备时钟信号,备时钟信号由备时钟电路提供;The first circuit is also used to receive the standby clock signal when the main clock signal is abnormal, and the standby clock signal is provided by the standby clock circuit;

第一电路还用于,对备时钟信号的相位进行重建,生成第一重建时钟信号,第一重建时钟信号的相位与异常前的主时钟信号的相位一致;The first circuit is further configured to reconstruct the phase of the standby clock signal to generate a first reconstructed clock signal, where the phase of the first reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality;

第一电路还用于,向第一负载提供第一重建时钟信号;The first circuit is further configured to provide a first reconstruction clock signal to the first load;

第一电路还用于,根据备时钟信号和预设相位调整速度对第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,多个调整时钟信号中最后生成的调整时钟信号的相位等于备时钟信号的相位,除最后生成的调整时钟信号,多个调整时钟信号中其他的调整时钟信号的相位介于第一重建时钟信号的相位和备时钟信号的相位之间;The first circuit is further configured to continuously adjust the phase of the first reconstructed clock signal according to the backup clock signal and the preset phase adjustment speed to generate multiple adjusted clock signals, and the phase of the last generated adjusted clock signal among the multiple adjusted clock signals Equal to the phase of the standby clock signal, except for the last generated adjustment clock signal, the phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phase of the first reconstructed clock signal and the phase of the standby clock signal;

第一电路还用于,每次调整后向第一负载提供调整后生成的调整时钟信号。The first circuit is further configured to provide an adjusted clock signal generated after adjustment to the first load after each adjustment.

可选地,时钟切换装置还包括如图1中的第二切换电路的第二电路;第二电路分别与主时钟电路101、备时钟电路102和第二负载连接,第二负载示例性的可以为图1中的第二处理器和/或第四处理器。Optionally, the clock switching device further includes a second circuit such as the second switching circuit in FIG. 1; the second circuit is respectively connected to the main clock circuit 101, the backup clock circuit 102 and the second load, and the second load can illustratively be is the second processor and/or the fourth processor in FIG. 1 .

第二电路用于,在主时钟信号正常时,接收主时钟信号后,向第二负载提供主时钟信号,主时钟信号由主时钟电路提供;The second circuit is used to, when the main clock signal is normal, provide the main clock signal to the second load after receiving the main clock signal, and the main clock signal is provided by the main clock circuit;

第二电路还用于,在主时钟信号异常时,接收备时钟信号,备时钟信号由备时钟电路提供;The second circuit is also used to receive the standby clock signal when the main clock signal is abnormal, and the standby clock signal is provided by the standby clock circuit;

第二电路还用于,对备时钟信号的相位进行重建,生成第二重建时钟信号,第二重建时钟信号的相位与异常前的主时钟信号的相位一致;The second circuit is also used to reconstruct the phase of the standby clock signal to generate a second reconstructed clock signal, and the phase of the second reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality;

第二电路还用于,向第二负载提供第二重建时钟信号;The second circuit is also used to provide a second reconstruction clock signal to the second load;

第二电路还用于,根据备时钟信号和预设相位调整速度对第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,多个补偿时钟信号中最后生成的补偿时钟信号的相位等于备时钟信号的相位,除最后生成的补偿时钟信号,多个补偿时钟信号中其他的补偿时钟信号的相位介于第二重建时钟信号的相位和备时钟信号的相位之间;The second circuit is further configured to continuously adjust the phase of the second reconstructed clock signal according to the backup clock signal and the preset phase adjustment speed to generate multiple compensated clock signals, and the phase of the last generated compensated clock signal among the multiple compensated clock signals Equal to the phase of the standby clock signal, except for the last generated compensation clock signal, the phases of other compensation clock signals in the multiple compensation clock signals are between the phase of the second reconstructed clock signal and the phase of the standby clock signal;

第二电路还用于,每次调整后向第二负载提供调整后生成的补偿时钟信号。The second circuit is also used for providing the adjusted and generated compensation clock signal to the second load after each adjustment.

本申请实施例另一方面提供一种时钟切换装置,用于执行上述实施例中的时钟切换方法。图4为本申请实施例一提供的时钟切换装置的结构示意图。本实施例中的时钟切换装置示例性的可以为图1中的切换电路104。如图4所示,时钟切换装置400包括:控制电路401和锁相环电路402;控制电路401分别与时钟切换装置的主时钟信号输入端口、备时钟信号输入端口和锁相环电路402的参考输入端口连接,锁相环电路402的输出端口与时钟切换装置的时钟信号输出端口连接;控制电路401与锁相环电路402连接;其中,Another aspect of the embodiments of the present application provides a clock switching device, configured to implement the clock switching method in the foregoing embodiments. FIG. 4 is a schematic structural diagram of a clock switching device provided in Embodiment 1 of the present application. The clock switching device in this embodiment may be, for example, the switching circuit 104 in FIG. 1 . As shown in Figure 4, clock switching device 400 comprises: control circuit 401 and phase-locked loop circuit 402; The input port is connected, and the output port of the phase-locked loop circuit 402 is connected with the clock signal output port of the clock switching device; the control circuit 401 is connected with the phase-locked loop circuit 402; wherein,

控制电路401在检测到主时钟信号异常时,通过时钟切换装置400的备时钟信号输入端口接收备时钟信号,并将锁相环电路402的工作状态设置为相位重建状态;When the control circuit 401 detects that the main clock signal is abnormal, it receives the standby clock signal through the standby clock signal input port of the clock switching device 400, and sets the working state of the phase-locked loop circuit 402 to the phase reconstruction state;

锁相环电路402在工作状态为相位重建状态时,对备时钟信号的相位进行重建,并生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟信号的相位一致;When the phase-locked loop circuit 402 is in the phase reconstruction state, the phase of the standby clock signal is reconstructed, and a reconstructed clock signal is generated, and the phase of the reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality;

控制电路401在锁相环电路402生成重建后的时钟信号时,将锁相环电路402的工作状态设置为相位补偿状态;The control circuit 401 sets the working state of the phase-locked loop circuit 402 to the phase compensation state when the phase-locked loop circuit 402 generates the reconstructed clock signal;

锁相环电路402在工作状态为相位补偿状态时,根据备时钟信号和预设相位调整速度对重建后的时钟信号的相位进行补偿,并生成补偿后的时钟信号。When the phase locked loop circuit 402 is in the phase compensation state, it compensates the phase of the reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed, and generates the compensated clock signal.

示例性的,如图4所示,时钟切换装置400包括控制电路401和锁相环电路402。控制电401分别与时钟切换装置400的主时钟信号输入端口和备时钟信号输入端口连接,接收主时钟电路提供的主时钟信号以及备时钟电路提供的备时钟信号。控制电路401还与锁相环电路402的参考输入端口连接,用于在主备时钟信号中选择时钟信号发送至锁相环电路402的参考输入端口。示例性的控制电路401还用于监测主时钟信号,当监测到主时钟信号异常时,控制电路401停止接收主时钟信号,通过时钟切换装置400的备时钟信号输入端口接收备时钟信号,并将备时钟信号发送至锁相环电路402。Exemplarily, as shown in FIG. 4 , a clock switching device 400 includes a control circuit 401 and a phase-locked loop circuit 402 . The control circuit 401 is respectively connected to the main clock signal input port and the backup clock signal input port of the clock switching device 400, and receives the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The control circuit 401 is also connected to the reference input port of the phase-locked loop circuit 402 , and is used to select a clock signal from the main and standby clock signals to send to the reference input port of the phase-locked loop circuit 402 . The exemplary control circuit 401 is also used to monitor the main clock signal. When the main clock signal is detected to be abnormal, the control circuit 401 stops receiving the main clock signal, receives the standby clock signal through the standby clock signal input port of the clock switching device 400, and sends The standby clock signal is sent to the PLL circuit 402.

示例性的,控制电路401在监测到主时钟信号异常,需要进行时钟切换时,控制电路401先后控制锁相环电路402处于不同的工作状态,使得锁相环电路402分别进行时钟信号的相位重建和相位补偿。示例性的,锁相环电路402中设置有寄存器,寄存器中用于存储锁相环电路402的配置参数,不同的配置参数对应锁相环电路402的不同工作状态。控制电路401可通过修改锁相环电路402的寄存器中配置参数,来控制锁相环电路402处于不同的工作状态。Exemplarily, when the control circuit 401 detects that the main clock signal is abnormal and needs to switch clocks, the control circuit 401 successively controls the phase-locked loop circuit 402 to be in different working states, so that the phase-locked loop circuit 402 respectively performs phase reconstruction of the clock signal and phase compensation. Exemplarily, the phase-locked loop circuit 402 is provided with a register, and the register is used to store configuration parameters of the phase-locked loop circuit 402 , and different configuration parameters correspond to different working states of the phase-locked loop circuit 402 . The control circuit 401 can control the phase-locked loop circuit 402 to be in different working states by modifying the configuration parameters in the registers of the phase-locked loop circuit 402 .

示例性的,控制电路401监测到需要主时钟信号异常时,首先控制锁相环电路402处于相位重建工作状态。Exemplarily, when the control circuit 401 detects that the master clock signal is abnormal, it first controls the phase-locked loop circuit 402 to be in the phase reconstruction working state.

当锁相环电路402工作在相位重建工作状态时,锁相环电路402通过参考输入端口接收备时钟信号,同时,锁相环电路402内部设置的振荡器与鉴频/鉴相器之间的反馈通路向锁相环电路402提供异常前的主时钟信号,锁相环电路402获取并存储备时钟信号与异常前的主时钟信号的相位差,并根据存储的相位差对锁相环电路402接收到的备时钟信号的相位进行逐步调节,使得锁相环电路402的输出端输出的时钟信号的相位与异常前的主时钟信号的相位一致。When the phase-locked loop circuit 402 was working in the phase reconstruction working state, the phase-locked loop circuit 402 received the standby clock signal through the reference input port, and at the same time, the internal oscillator of the phase-locked loop circuit 402 and the frequency discriminator/phase detector The feedback path provides the main clock signal before the abnormality to the phase-locked loop circuit 402, and the phase-locked loop circuit 402 acquires and stores the phase difference between the backup clock signal and the main clock signal before the abnormality, and receives the phase-locked loop circuit 402 according to the stored phase difference. The phase of the received standby clock signal is gradually adjusted, so that the phase of the clock signal output from the output terminal of the phase-locked loop circuit 402 is consistent with the phase of the main clock signal before the abnormality.

示例性的,锁相环电路402实时检测输出端口提供的时钟信号的相位与锁相环电路402接收到的备时钟信号的相位之间的相位差,并确定实时检测得到的相位差与主时钟信号异常时存储的相位差之间的差别是否在预设范围内,若是,则确认相位重建结束。Exemplarily, the phase-locked loop circuit 402 detects the phase difference between the phase of the clock signal provided by the output port and the phase of the standby clock signal received by the phase-locked loop circuit 402 in real time, and determines that the phase difference obtained by the real-time detection and the main clock Whether the difference between the stored phase differences when the signal is abnormal is within a preset range, and if so, it is confirmed that the phase reconstruction is completed.

此时,控制电路401重新配置锁相环电路402的配置参数,控制锁相环电路402工作在相位补偿状态。当锁相环电路402的工作状态为相位补偿状态时,锁相环电路402根据接收到的备时钟信号,对振荡器反馈给鉴频/鉴相器的重建后的时钟信号进行相位补偿,使得振荡器输出的时钟信号的相位与备时钟信号的相位逐步接近,直至振荡器输出的时钟信号的相位与备时钟信号的相位相同。At this time, the control circuit 401 reconfigures the configuration parameters of the phase-locked loop circuit 402, and controls the phase-locked loop circuit 402 to work in a phase compensation state. When the working state of the phase-locked loop circuit 402 is the phase compensation state, the phase-locked loop circuit 402 performs phase compensation on the reconstructed clock signal fed back to the frequency/phase detector by the oscillator according to the received standby clock signal, so that The phase of the clock signal output by the oscillator is gradually approached to the phase of the standby clock signal until the phase of the clock signal output by the oscillator is the same as the phase of the standby clock signal.

本实施例提供的时钟切换装置包括控制电路和锁相环电路,控制电路用于控制锁相环电路的工作状态,锁相环电路用于在工作状态为相位重建状态时,根据异常前的主时钟信号和备时钟信号对备时钟信号的相位进行相位重建,得到重建后的时钟信号,避免了时钟切换时时钟信号的相位的突然变化,在相位重建结束后,锁相环电路的工作状态变为相位补偿状态,锁相环电路将重建后的时钟信号的相位逐渐变更为与备时钟信号一致,使得各切换电路为各处理器的TSC提供的时钟信号的相位一致,时钟切换装置通过采用控制电路控制锁相环电路工作在不同工作状态的方式,由一个锁相环电路实现了时钟信号的相位重建和相位补偿,切换电路结构简单。The clock switching device provided in this embodiment includes a control circuit and a phase-locked loop circuit. The control circuit is used to control the working state of the phase-locked loop circuit. The clock signal and the standby clock signal perform phase reconstruction on the phase of the standby clock signal to obtain the reconstructed clock signal, which avoids the sudden change of the phase of the clock signal when the clock is switched. After the phase reconstruction is completed, the working state of the phase-locked loop circuit changes. In the phase compensation state, the phase-locked loop circuit gradually changes the phase of the reconstructed clock signal to be consistent with the standby clock signal, so that the phases of the clock signals provided by each switching circuit for the TSC of each processor are consistent, and the clock switching device adopts the control The circuit controls the way that the phase-locked loop circuit works in different working states, the phase reconstruction and phase compensation of the clock signal are realized by a phase-locked loop circuit, and the switching circuit structure is simple.

示例性的,在图4所示实施例的基础上,本申请实施例还提供一种时钟切换装置。图5为本申请实施例二提供的时钟切换装置的结构示意图。如图5所示,本实施例提供的时钟切换装置,时钟切换装置的时钟信号输出端口还与时钟切换装置的反馈时钟信号输入端口连接,时钟切换装置的反馈时钟信号输入端口与锁相环电路的反馈输入端口连接,构成了时钟切换装置的零延时反馈通路。对应的,结合图5所示实施例,在图2所示实施例的基础上,本申请实施例还提供一种时钟切换方法,该方法中时钟切换装置接收时钟信号输出端口输出的反馈时钟信号,根据反馈时钟信号对重建的时钟信号进行相位补偿,使得时钟切换装置的时钟信号输出端口输出的时钟信号与备时钟信号的相位完全一致。图6为本申请实施例二提供的时钟切换方法的流程示意图。如图6所示,时钟切换方法包括:Exemplarily, on the basis of the embodiment shown in FIG. 4 , an embodiment of the present application further provides a clock switching device. FIG. 5 is a schematic structural diagram of a clock switching device provided in Embodiment 2 of the present application. As shown in Figure 5, in the clock switching device provided by this embodiment, the clock signal output port of the clock switching device is also connected to the feedback clock signal input port of the clock switching device, and the feedback clock signal input port of the clock switching device is connected to the phase-locked loop circuit The feedback input port is connected to form a zero-delay feedback path of the clock switching device. Correspondingly, in combination with the embodiment shown in FIG. 5 , on the basis of the embodiment shown in FIG. 2 , this embodiment of the present application also provides a clock switching method, in which the clock switching device receives the feedback clock signal output from the clock signal output port , performing phase compensation on the reconstructed clock signal according to the feedback clock signal, so that the phase of the clock signal output by the clock signal output port of the clock switching device is completely consistent with that of the standby clock signal. FIG. 6 is a schematic flowchart of a clock switching method provided in Embodiment 2 of the present application. As shown in Figure 6, clock switching methods include:

S601、控制电路在检测到主时钟信号异常时,通过时钟切换装置的备时钟信号输入端口接收备时钟信号;锁相环电路停止通过锁相环电路的反馈输入端口接收反馈时钟信号,反馈时钟信号为时钟切换装置的反馈时钟信号输入端口所输入的时钟信号。S601. When the control circuit detects that the main clock signal is abnormal, it receives the standby clock signal through the standby clock signal input port of the clock switching device; the phase-locked loop circuit stops receiving the feedback clock signal through the feedback input port of the phase-locked loop circuit, and the feedback clock signal It is the clock signal input by the feedback clock signal input port of the clock switching device.

示例性的,控制电路在检测到主时钟信号异常时,控制电路断开零延时反馈通路。具体的,控制电路设置锁相环电路的工作状态,使得锁相环电路停止通过锁相环电路的反馈输入端口接收反馈时钟信号,也即停止接收时钟切换装置的时钟信号输出端口输出的时钟信号。示例性的,锁相环电路中设置有寄存器,寄存器中存储的信息为锁相环电路是否开启零延时反馈通路的使能信号。当控制电路控制零延时反馈通路导通时,控制电路向寄存器中写入第一数值,当锁相环电路读取到寄存器中的数值为第一数值时,使能零延时反馈通路导通。当控制电路控制零延时反馈通路断开时,控制电路向寄存器中写入第二数值,当锁相环电路读取到寄存器中的数值为第二数值时,无法使能零延时反馈通路导通,也即零延时反馈通路关断。Exemplarily, when the control circuit detects that the main clock signal is abnormal, the control circuit disconnects the zero-delay feedback path. Specifically, the control circuit sets the working state of the phase-locked loop circuit, so that the phase-locked loop circuit stops receiving the feedback clock signal through the feedback input port of the phase-locked loop circuit, that is, stops receiving the clock signal output by the clock signal output port of the clock switching device . Exemplarily, a register is set in the phase-locked loop circuit, and the information stored in the register is an enable signal for whether the phase-locked loop circuit enables the zero-delay feedback path. When the control circuit controls the zero-delay feedback path to be turned on, the control circuit writes the first value to the register, and when the phase-locked loop circuit reads that the value in the register is the first value, the zero-delay feedback path is enabled. Pass. When the control circuit controls the zero-delay feedback path to be disconnected, the control circuit writes the second value into the register, and when the value read by the phase-locked loop circuit in the register is the second value, the zero-delay feedback path cannot be enabled is turned on, that is, the zero-delay feedback path is turned off.

S602、锁相环电路对备时钟信号的相位进行重建,并生成重建后的时钟信号,重建后的时钟信号的相位与异常前的主时钟信号的相位一致。S602. The phase-locked loop circuit reconstructs the phase of the standby clock signal, and generates a reconstructed clock signal. The phase of the reconstructed clock signal is consistent with the phase of the main clock signal before the abnormality.

示例性的,本实施例中的S602与图2所示实施例中的S202相同,本申请对此不再赘述。Exemplarily, S602 in this embodiment is the same as S202 in the embodiment shown in FIG. 2 , which will not be repeated in this application.

S603、锁相环电路停止接收锁相环电路的振荡器所提供的时钟信号,并通过锁相环电路的反馈输入端口接收反馈时钟信号。S603. The phase-locked loop circuit stops receiving the clock signal provided by the oscillator of the phase-locked loop circuit, and receives the feedback clock signal through the feedback input port of the phase-locked loop circuit.

示例性的,在实际时钟切换装置中,锁相环电路的输出端与时钟切换装置的时钟信号输出端口之间可能存在删除扩展器、缓存器等器件,使得时钟切换装置的时钟信号输出端口输出的时钟信号的相位与锁相环电路的输出端输出的时钟信号的相位不一致。尽管各时钟切换装置的锁相环电路在进行相位补偿后,可控制各锁相环电路的输出端的时钟信号与备时钟信号一致,但是,由于锁相环电路的输出端与时钟切换装置的时钟信号输出端口之间的器件不完全相同,可能存在不同时钟切换装置的时钟信号输出端口输出的时钟信号之间存在相位不一致。因此,在锁相环电路在生成重建后的时钟信号后,锁相环电路断开锁相环电路内部的反馈通路,根据零延时反馈通路对时钟切换装置的时钟信号输出端口输出的重建后的时钟信号的相位进行相位补偿,使得时钟切换装置的时钟信号输出端口输出的时钟信号的相位与备时钟信号的相位一致,从而确保了不同时钟切换装置的时钟信号输出端口输出的时钟信号均与备时钟信号一致,相互之间不存在相位不一致。Exemplarily, in an actual clock switching device, there may be devices such as deletion expanders and buffers between the output terminal of the phase-locked loop circuit and the clock signal output port of the clock switching device, so that the clock signal output port of the clock switching device outputs The phase of the clock signal is inconsistent with the phase of the clock signal output from the output terminal of the phase-locked loop circuit. Although the phase-locked loop circuits of each clock switching device can control the clock signal at the output end of each phase-locked loop circuit to be consistent with the standby clock signal after performing phase compensation, because the output end of the phase-locked loop circuit and the clock of the clock switching device The devices between the signal output ports are not exactly the same, and there may be phase inconsistencies between the clock signals output by the clock signal output ports of different clock switching devices. Therefore, after the phase-locked loop circuit generates the reconstructed clock signal, the phase-locked loop circuit disconnects the feedback path inside the phase-locked loop circuit, and after the reconstruction of the clock signal output port output of the clock switching device according to the zero-delay feedback path Phase compensation is performed on the phase of the clock signal of the clock signal, so that the phase of the clock signal output by the clock signal output port of the clock switching device is consistent with the phase of the standby clock signal, thereby ensuring that the clock signals output by the clock signal output ports of different clock switching devices are consistent with the The standby clock signals are consistent, and there is no phase inconsistency between them.

S604、锁相环电路根据备时钟信号、反馈时钟信号和预设相位调整速度对重建后的时钟信号的相位进行补偿,并生成补偿后的时钟信号,将补偿后的时钟信号通过时钟切换装置的时钟信号输出端口输出,补偿后的时钟信号的相位与备时钟信号的相位一致。S604. The phase-locked loop circuit compensates the phase of the reconstructed clock signal according to the standby clock signal, the feedback clock signal and the preset phase adjustment speed, and generates a compensated clock signal, and passes the compensated clock signal through the clock switching device. The clock signal output port outputs, and the phase of the compensated clock signal is consistent with the phase of the standby clock signal.

示例性的,锁相环电路根据备时钟信号、时钟切换装置的时钟信号输出端口输出的反馈时钟信号以及预设相位调整速度,对时钟切换装置的时钟信号输出端口输出的重建后的时钟信号的相位进行补偿,生成的补偿后的时钟信号的相位与备时钟信号的相位一致。Exemplarily, the phase-locked loop circuit adjusts the speed according to the standby clock signal, the feedback clock signal output by the clock signal output port of the clock switching device, and the preset phase, and adjusts the output of the reconstructed clock signal output by the clock signal output port of the clock switching device. Phase compensation is performed, and the phase of the generated compensated clock signal is consistent with the phase of the standby clock signal.

示例性的,当控制电路检测到备时钟信号异常时,控制电路从修复的主时钟电路接收主时钟信号,并断开零延时反馈通路。示例性的,控制电路还控制锁相环电路开始接收锁相环电路的振荡器所提供的时钟信号,以再次进行相位重建。Exemplarily, when the control circuit detects that the standby clock signal is abnormal, the control circuit receives the main clock signal from the repaired main clock circuit, and disconnects the zero-delay feedback path. Exemplarily, the control circuit also controls the phase-locked loop circuit to start receiving the clock signal provided by the oscillator of the phase-locked loop circuit, so as to perform phase reconstruction again.

本申请实施例提供的时钟切换方法,在相位补偿过程中,根据备时钟信号和时钟切换装置的时钟信号输出端口输出的反馈时钟信号对重建后的时钟信号的相位进行补偿,生成补偿后的时钟信号,使得补偿后的时钟信号的相位与备时钟信号的相位一致,从而保证了所有时钟切换装置向处理器提供的时钟信号的相位完全一致。In the clock switching method provided by the embodiment of the present application, in the phase compensation process, the phase of the reconstructed clock signal is compensated according to the standby clock signal and the feedback clock signal output from the clock signal output port of the clock switching device, and a compensated clock is generated. signal, so that the phase of the compensated clock signal is consistent with the phase of the standby clock signal, thereby ensuring that the phases of the clock signals provided by all clock switching devices to the processor are completely consistent.

可选的,在上述任一所示实施例的基础上,备时钟电路提供的第一时钟信号的频率可根据主时钟电路在预设时间段内提供的时钟信号的频率平均值确定。Optionally, on the basis of any of the above-mentioned embodiments, the frequency of the first clock signal provided by the standby clock circuit may be determined according to the average frequency of the clock signal provided by the main clock circuit within a preset time period.

示例性的,如图1所示,备时钟电路通过互锁通路监测主时钟电路提供的时钟信号的频率,以预设时间段为周期获取主时钟电路在预设时间段内提供的时钟信号的频率平均值,作为备时钟信号的频率。通过采用两个时钟电路为多处理器服务器系统中的处理器的处理器供电,提高了时钟源的稳定性,避免了采用单个稳定精准时钟源通过主备两个时钟电路同时向各处理器提供时钟信号,降低了时钟系统的时钟成本。Exemplarily, as shown in FIG. 1, the standby clock circuit monitors the frequency of the clock signal provided by the main clock circuit through an interlock path, and obtains the frequency of the clock signal provided by the main clock circuit within a preset time period with a preset time period as a cycle. Frequency average, used as the frequency of the standby clock signal. By using two clock circuits to supply power to the processors of the processors in the multi-processor server system, the stability of the clock source is improved, and it is avoided to use a single stable and accurate clock source to provide power to each processor at the same time through two active and standby clock circuits. The clock signal reduces the clock cost of the clock system.

可选的,在上述任一实施例的基础上,切换电路检测到主时钟信号异常示例性的可以为如下中的任一种:切换电路接收到备时钟电路发送的主时钟电路故障指示信息;或者,切换电路检测到主时钟信号中断;或者,切换电路接收到时钟切换指令。Optionally, on the basis of any of the above-mentioned embodiments, the abnormality of the main clock signal detected by the switching circuit may be any of the following illustratively: the switching circuit receives the failure indication information of the main clock circuit sent by the standby clock circuit; Or, the switching circuit detects that the main clock signal is interrupted; or, the switching circuit receives a clock switching instruction.

示例性的,当主时钟电路故障或主时钟电路与切换电路之间的连接线故障时,切换电路可检测到主时钟电路发送的主时钟信号中断,此时切换电路认为主时钟信号异常,需进行时钟切换。Exemplarily, when the main clock circuit fails or the connection line between the main clock circuit and the switching circuit fails, the switching circuit can detect that the main clock signal sent by the main clock circuit is interrupted. Clock switching.

可选的,备时钟电路在检测到互锁通路上时钟信号丢失或检测到频偏超过预设阈值时,向切换电路发送主时钟电路故障指示信息。Optionally, when the backup clock circuit detects the loss of the clock signal on the interlock path or detects that the frequency deviation exceeds a preset threshold, it sends the main clock circuit failure indication information to the switching circuit.

示例性的,备时钟电路通过互锁通路监测主时钟电路提供的时钟信号,当备时钟电路监测到互锁通路上没有时钟信号时则认为主时钟电路故障,或者当备时钟电路监测到主时钟电路提供的时钟信号的频率与备时钟电路提供的时钟信号的频率之间的频偏大于预设阈值时,同样认为主时钟电路故障,此时,备时钟电路向切换电路发送主时钟电路故障指示信息。Exemplarily, the standby clock circuit monitors the clock signal provided by the main clock circuit through the interlock path. When the standby clock circuit detects that there is no clock signal on the interlock path, it considers that the main clock circuit is faulty, or when the standby clock circuit detects that the main clock When the frequency deviation between the frequency of the clock signal provided by the circuit and the frequency of the clock signal provided by the standby clock circuit is greater than the preset threshold, it is also considered that the main clock circuit is faulty. At this time, the standby clock circuit sends a failure indication of the main clock circuit to the switching circuit information.

示例性的,本申请各实施例提供的时钟切换方法同样适用于其他需要保证同时钟源的分布式结构中。例如,在由多个ARM处理器构成的多处理器服务器中,不同ARM处理器之间的时钟源需保持一致。又如,在由多个存储单元构成的网络存储器系统中,各存储单元之间的时钟源需保持一致。示例性的,本申请各实施例提供的时钟切换方法可以避免时钟切换过程中时钟信号相位的大幅度瞬变、相位不连续等问题,因此同样适用于任意需要稳定时钟源对时钟相位精度要求较高的设备,如计算机、服务器、路由器、基站等网络设备。Exemplarily, the clock switching methods provided by the embodiments of the present application are also applicable to other distributed structures that need to ensure the same clock source. For example, in a multi-processor server composed of multiple ARM processors, the clock sources of different ARM processors need to be consistent. As another example, in a network memory system composed of multiple storage units, the clock sources among the storage units need to be consistent. Exemplarily, the clock switching methods provided by the various embodiments of the present application can avoid problems such as large-scale transients and phase discontinuities of the clock signal phase during the clock switching process, so it is also applicable to any clock source that requires a stable clock source and requires relatively high clock phase accuracy. High equipment, such as computers, servers, routers, base stations and other network equipment.

本申请实施例另一方面还提供一种时钟切换装置,用于执行上述任一实施例中的时钟切换方法,具有相同的技术效果,本申请对此不再赘述。On the other hand, the embodiment of the present application also provides a clock switching device, which is used to implement the clock switching method in any of the above embodiments, and has the same technical effect, and the present application will not repeat it here.

本申请实施例提供一种时钟切换装置。图7为本申请实施例三提供的时钟切换装置的结构示意图。如图7所示,时钟切换装置,包括:An embodiment of the present application provides a clock switching device. FIG. 7 is a schematic structural diagram of a clock switching device provided in Embodiment 3 of the present application. As shown in Figure 7, the clock switching device includes:

第一时钟信号获取模块701,用于在主时钟信号正常时,接收主时钟信号后,向第一负载提供主时钟信号,主时钟信号由与第一时钟信号获取模块701连接的主时钟电路提供;The first clock signal acquisition module 701 is configured to provide the main clock signal to the first load after receiving the main clock signal when the main clock signal is normal, and the main clock signal is provided by the main clock circuit connected to the first clock signal acquisition module 701 ;

第一时钟信号获取模块701,还用于在主时钟信号异常时,接收备时钟信号,备时钟信号由与第一时钟信号获取模块701连接的备时钟电路提供;The first clock signal acquisition module 701 is also used to receive the backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by the backup clock circuit connected to the first clock signal acquisition module 701;

第一重建模块702,用于对备时钟信号的相位进行重建,生成第一重建时钟信号,第一重建时钟信号的相位与异常前的主时钟信号的相位一致;向第一负载提供第一重建时钟信号;The first reconstruction module 702 is configured to reconstruct the phase of the standby clock signal to generate a first reconstruction clock signal, the phase of the first reconstruction clock signal is consistent with the phase of the main clock signal before the abnormality; provide the first reconstruction to the first load clock signal;

第一调整模块703,用于根据备时钟信号和预设相位调整速度对第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号,多个调整时钟信号中最后生成的调整时钟信号的相位等于备时钟信号的相位,除最后生成的调整时钟信号,多个调整时钟信号中其他的调整时钟信号的相位介于第一重建时钟信号的相位和备时钟信号的相位之间;每次调整后向第一负载提供调整后生成的调整时钟信号。The first adjustment module 703 is configured to continuously adjust the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate multiple adjusted clock signals, and the last generated adjusted clock signal among the multiple adjusted clock signals The phase is equal to the phase of the standby clock signal, except for the last generated adjustment clock signal, the phases of other adjustment clock signals in the multiple adjustment clock signals are between the phase of the first reconstruction clock signal and the phase of the standby clock signal; each adjustment Afterwards, the adjusted clock signal generated after adjustment is provided to the first load.

可选地,如图7所示,时钟切换装置还包括:Optionally, as shown in Figure 7, the clock switching device further includes:

第二时钟信号获取模块704,用于在主时钟信号正常时,接收主时钟信号后,向第二负载提供主时钟信号,主时钟信号由与第二时钟信号获取模块704连接的主时钟电路提供;The second clock signal acquisition module 704 is configured to provide the main clock signal to the second load after receiving the main clock signal when the main clock signal is normal, and the main clock signal is provided by the main clock circuit connected to the second clock signal acquisition module 704 ;

第二时钟信号获取模块704还用于,在主时钟信号异常时,接收备时钟信号,备时钟信号由与第二时钟信号获取模块704连接的备时钟电路提供;The second clock signal acquisition module 704 is also used to receive the backup clock signal when the main clock signal is abnormal, and the backup clock signal is provided by the backup clock circuit connected to the second clock signal acquisition module 704;

第二重建模块705,用于对备时钟信号的相位进行重建,生成第二重建时钟信号,第二重建时钟信号的相位与异常前的主时钟信号的相位一致;向第二负载提供第二重建时钟信号;The second reconstruction module 705 is configured to reconstruct the phase of the standby clock signal to generate a second reconstruction clock signal, the phase of the second reconstruction clock signal is consistent with the phase of the main clock signal before the abnormality; provide the second reconstruction to the second load clock signal;

第二调整模块706,用于根据备时钟信号和预设相位调整速度对第二重建时钟信号的相位进行连续地调整生成多个补偿时钟信号,多个补偿时钟信号中最后生成的补偿时钟信号的相位等于备时钟信号的相位,除最后生成的补偿时钟信号,多个补偿时钟信号中其他的补偿时钟信号的相位介于第二重建时钟信号的相位和备时钟信号的相位之间;每次调整后向第二负载提供调整后生成的补偿时钟信号。The second adjustment module 706 is configured to continuously adjust the phase of the second reconstruction clock signal according to the backup clock signal and the preset phase adjustment speed to generate multiple compensation clock signals, and the compensation clock signal generated last among the multiple compensation clock signals The phase is equal to the phase of the standby clock signal. Except for the last generated compensation clock signal, the phases of other compensation clock signals in the plurality of compensation clock signals are between the phase of the second reconstructed clock signal and the phase of the standby clock signal; each adjustment Afterwards, the adjusted and generated compensation clock signal is provided to the second load.

可选地,如图7所示,时钟切换装置还包括:第一控制模块707,用于在主时钟信号异常时,将第一重建模块702设置为工作状态。第一控制模块707还用于,确定第一重建模块702生成第一重建时钟信号后,将第一调整模块703设置为工作状态。Optionally, as shown in FIG. 7 , the clock switching device further includes: a first control module 707 configured to set the first rebuilding module 702 to a working state when the main clock signal is abnormal. The first control module 707 is further configured to set the first adjustment module 703 to the working state after determining that the first reconstruction module 702 generates the first reconstruction clock signal.

可选的,时钟切换装置通过时钟切换装置的时钟信号输出端口向第一负载提供时钟信号,时钟切换装置的时钟信号输出端口与时钟切换装置的反馈时钟信号输入端口连接,时钟切换装置的反馈时钟信号输入端口与第一调整模块703的反馈输入端口连接。Optionally, the clock switching device provides a clock signal to the first load through the clock signal output port of the clock switching device, the clock signal output port of the clock switching device is connected to the feedback clock signal input port of the clock switching device, and the feedback clock of the clock switching device The signal input port is connected to the feedback input port of the first adjustment module 703 .

第一控制模块707还用于,在第一重建模块702对备时钟信号的相位进行重建之前,关闭第一调整模块703的反馈输入端口,停止从第一调整模块703的反馈输入端口接收时钟切换装置的时钟信号输出端口输出的时钟信号。The first control module 707 is also configured to close the feedback input port of the first adjustment module 703 and stop receiving clock switching from the feedback input port of the first adjustment module 703 before the first reconstruction module 702 reconstructs the phase of the standby clock signal The clock signal output by the clock signal output port of the device.

第一控制模块707还用于,在第一调整模块703根据备时钟信号和预设相位调整速度对第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号之前,关闭第一调整模块703的调整反馈端口,停止从第一调整模块703的调整反馈端口接收第一调整模块703提供的时钟信号,并打开第一调整模块703的反馈输入端口。The first control module 707 is also used to close the first adjustment module before the first adjustment module 703 continuously adjusts the phase of the first reconstruction clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjustment clock signals The adjustment feedback port of 703 stops receiving the clock signal provided by the first adjustment module 703 from the adjustment feedback port of the first adjustment module 703 , and opens the feedback input port of the first adjustment module 703 .

第一调整模块703还用于,根据备时钟信号、从第一调整模块703的反馈输入端口接收的时钟反馈信号和预设相位调整速度对第一重建时钟信号的相位进行连续地调整生成多个调整时钟信号。The first adjustment module 703 is further configured to continuously adjust the phase of the first reconstructed clock signal according to the standby clock signal, the clock feedback signal received from the feedback input port of the first adjustment module 703, and the preset phase adjustment speed to generate multiple Adjust the clock signal.

可选地,第一重建模块702还用于,根据相位差对备时钟信号的相位进行重建,生成第一重建时钟信号,相位差为备时钟信号与异常前的主时钟信号之间的相位差。Optionally, the first reconstruction module 702 is further configured to reconstruct the phase of the standby clock signal according to the phase difference to generate the first reconstructed clock signal, where the phase difference is the phase difference between the standby clock signal and the main clock signal before the abnormality .

在一种可能的实施方式中,时钟切换装置还包括:In a possible implementation manner, the clock switching device further includes:

第二控制模块,用于在所述主时钟信号异常时,将所述第二重建模块设置为工作状态;A second control module, configured to set the second reconstruction module to a working state when the main clock signal is abnormal;

所述第二控制模块还用于,确定所述第二重建模块生成所述第二重建时钟信号后,将所述第二调整模块设置为工作状态。所述第二控制模块与第二调整模块、第二重建模块的通信方式与所述第一控制模块同所述第一调整模块和所述第一重建模块的通信方式相同,第二控制模块与第二调整模块、第二重建模块的通信方式可以参考所述第一控制模块同所述第一调整模块和所述第一重建模块的通信方式,细节在此不再赘述。The second control module is further configured to set the second adjustment module to a working state after determining that the second reconstruction module generates the second reconstruction clock signal. The communication mode between the second control module, the second adjustment module and the second reconstruction module is the same as the communication mode between the first control module, the first adjustment module and the first reconstruction module, and the second control module communicates with the first reconstruction module. For the communication manner between the second adjustment module and the second reconstruction module, reference may be made to the communication manner between the first control module, the first adjustment module, and the first reconstruction module, and the details will not be repeated here.

本申请实施例另一方面提供一种服务器。该服务器包括一个或多个负载,以及包括与所有负载的数量相同的一个或多个时钟切换装置,所有负载与所有时钟切换装置一一对应连接,时钟切换装置为如上述实施例中任一项所述的时钟切换装置,时钟切换装置的时钟信号输出端口与对应的负载连接,为对应的负载提供时钟信号。Another aspect of the embodiment of the present application provides a server. The server includes one or more loads, and includes one or more clock switching devices with the same number as all loads, and all loads are connected to all clock switching devices in one-to-one correspondence, and the clock switching device is any one of the above-mentioned embodiments In the clock switching device, a clock signal output port of the clock switching device is connected to a corresponding load to provide a clock signal for the corresponding load.

示例性的,该服务器示例性的可以为图1中的节点服务器103,服务器中的负载可以为图1中的处理器105,时钟切换装置为图1中的切换电路104。Exemplarily, the server may be the node server 103 in FIG. 1 , the load in the server may be the processor 105 in FIG. 1 , and the clock switching device is the switching circuit 104 in FIG. 1 .

可选地,本申请实施例另一方面还提供一种时钟系统,如图1所示,包括主时钟电路101、备时钟电路102和至少一个如上述实施例中的服务器,所有服务器的所有时钟切换装置与主时钟电路101和备时钟电路102连接。其中,服务器示例性的可以为图1中的节点服务器103。Optionally, another aspect of this embodiment of the present application also provides a clock system, as shown in FIG. 1 , including a main clock circuit 101, a backup clock circuit 102, and at least one server as in the above embodiment, and all clocks of all servers The switching device is connected to the main clock circuit 101 and the backup clock circuit 102 . Wherein, the server may be, for example, the node server 103 in FIG. 1 .

可选地,如图1所示,服务器的负载包括至少一个处理器105,或服务器的负载包括至少一个处理器105和一个节点控制器106,负载的所有处理器105和节点控制器106与负载对应的时钟切换装置连接,系统的所有服务器的所有节点控制器106相互连接。Optionally, as shown in FIG. 1, the load of the server includes at least one processor 105, or the load of the server includes at least one processor 105 and a node controller 106, and all processors 105 and node controllers 106 of the load are related to the load Corresponding clock switching devices are connected, and all node controllers 106 of all servers in the system are connected to each other.

本申请实施例另一方面还提供一种时钟系统,如图1所示包括第一节点服务器、主时钟电路101和备时钟电路102,第一节点服务器包括第一时钟切换装置和第一处理器;第一时钟切换装置为上述任一可能的实施方式中的时钟切换装置。第一时钟切换装置分别与主时钟电路和备时钟电路连接,用于接收主时钟电路提供的主时钟信号和备时钟电路提供的备时钟信号。第一时钟切换装置还与第一处理器连接,用于向第一处理器提供时钟信号。Another aspect of the embodiment of the present application provides a clock system, as shown in Figure 1, including a first node server, a master clock circuit 101, and a backup clock circuit 102, and the first node server includes a first clock switching device and a first processor ; The first clock switching device is the clock switching device in any possible implementation manner above. The first clock switching device is respectively connected with the main clock circuit and the backup clock circuit, and is used for receiving the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The first clock switching device is also connected to the first processor for providing a clock signal to the first processor.

可选地,第一节点服务器还包括第二时钟切换装置和第二处理器;第二时钟切换装置为上述任一可能的实施方式中的时钟切换装置。第二时钟切换装置分别与主时钟电路和备时钟电路连接,用于接收主时钟电路提供的主时钟信号和备时钟电路提供的备时钟信号。第二时钟切换装置还与第二处理器连接,用于向第二处理器提供时钟信号。Optionally, the first node server further includes a second clock switching device and a second processor; the second clock switching device is the clock switching device in any possible implementation manner above. The second clock switching device is respectively connected with the main clock circuit and the backup clock circuit, and is used for receiving the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The second clock switching device is also connected to the second processor, and is used for providing a clock signal to the second processor.

可选地,第一节点服务器还包括第三处理器和第一节点控制器,第三处理器与第一节点控制器分别和第一时钟切换装置连接,接收第一时钟切换装置提供的时钟信号。第一节点服务器还包括第四处理器和第二节点控制器,第四处理器与第二节点控制器分别和第二时钟切换装置连接,第一节点控制器和第二节点控制器连接,接收第二时钟切换装置提供的时钟信号。Optionally, the first node server further includes a third processor and a first node controller, the third processor and the first node controller are respectively connected to the first clock switching device, and receive the clock signal provided by the first clock switching device . The first node server also includes a fourth processor and a second node controller, the fourth processor and the second node controller are respectively connected to the second clock switching device, the first node controller is connected to the second node controller, and receives The clock signal provided by the second clock switching device.

可选地,时钟系统还包括第二节点服务器,第二节点服务器包括第三时钟切换装置和第五处理器;第三时钟切换装置为上述任一可能的实施方式中的时钟切换装置。第三时钟切换装置分别与主时钟电路和备时钟电路连接,用于接收主时钟电路提供的主时钟信号和备时钟电路提供的备时钟信号。第三时钟切换装置还与第五处理器连接,用于向第五处理器提供时钟信号。Optionally, the clock system further includes a second node server, and the second node server includes a third clock switching device and a fifth processor; the third clock switching device is the clock switching device in any possible implementation manner above. The third clock switching device is respectively connected with the main clock circuit and the backup clock circuit, and is used for receiving the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The third clock switching device is also connected to the fifth processor, and is used for providing a clock signal to the fifth processor.

可选地,第二节点服务器还包括第四时钟切换装置和第六处理器;第四时钟切换装置为上述任一可能的实施方式中的时钟切换装置。第四时钟切换装置分别与主时钟电路和备时钟电路连接,用于接收主时钟电路提供的主时钟信号和备时钟电路提供的备时钟信号。第四时钟切换装置还与第六处理器连接,用于向第六处理器提供时钟信号。可选地,第二节点服务器还包括第七处理器和第三节点控制器,第七处理器与第三节点控制器分别和第四时钟切换装置连接。第二节点服务器还包括第八处理器和第四节点控制器,第八处理器与第四节点控制器分别和第四时钟切换装置连接,第一节点控制器、第二节点控制器、第三节点控制器和第四节点控制器连接。Optionally, the second node server further includes a fourth clock switching device and a sixth processor; the fourth clock switching device is the clock switching device in any possible implementation manner above. The fourth clock switching device is respectively connected with the main clock circuit and the backup clock circuit, and is used for receiving the main clock signal provided by the main clock circuit and the backup clock signal provided by the backup clock circuit. The fourth clock switching device is also connected to the sixth processor, and is used for providing a clock signal to the sixth processor. Optionally, the second node server further includes a seventh processor and a third node controller, and the seventh processor and the third node controller are respectively connected to the fourth clock switching device. The second node server also includes an eighth processor and a fourth node controller, the eighth processor and the fourth node controller are respectively connected to the fourth clock switching device, the first node controller, the second node controller, the third The node controller is connected to the fourth node controller.

需要说明的是,本申请所提供的实施例仅仅是示意性的。所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。在本申请实施例以及附图中揭示的特征可以独立存在也可以组合存在。在本申请实施例中以硬件形式描述的特征可以通过软件来执行,反之亦然。在此不做限定。It should be noted that the embodiments provided in this application are only illustrative. Those skilled in the art can clearly understand that, for the convenience and brevity of description, in the above-mentioned embodiments, the descriptions of each embodiment have their own emphasis. Description of the example. The features disclosed in the embodiments of the present application and the drawings may exist independently or in combination. Features described in the form of hardware in the embodiments of the present application may be implemented by software, and vice versa. It is not limited here.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的方法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the method steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.

在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如软盘、硬盘、磁带)、光介质(例如光盘)、或者半导体介质(例如固态硬盘(solid-state drive,SSD))等各种可以存储程序代码的非短暂性的(non-transitory)机器可读介质。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber) or wireless (eg, infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as an optical disk), or a semiconductor medium (such as a solid-state drive (SSD)) and other non-transitory devices that can store program codes. non-transitory machine-readable media.

另外,需要说明的是,应理解以上主时钟电路、备时钟电路、时钟同步切换电路的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。In addition, it should be noted that it should be understood that the above division of each module of the main clock circuit, backup clock circuit, and clock synchronous switching circuit is only a division of logical functions. In actual implementation, there may be other division methods, such as multiple units Or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。需要说明的是,本申请所提供的实施例仅仅是示意性的。所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。在本申请实施例以及附图中揭示的特征可以独立存在也可以组合存在。在本申请实施例中以硬件形式描述的特征可以通过软件来执行,反之亦然。在此不做限定。In addition, each functional unit in this application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units. It should be noted that the embodiments provided in this application are only illustrative. Those skilled in the art can clearly understand that, for the convenience and brevity of description, in the above-mentioned embodiments, the descriptions of each embodiment have their own emphasis. Description of the example. The features disclosed in the embodiments of the present application and the drawings may exist independently or in combination. Features described in the form of hardware in the embodiments of the present application may be implemented by software, and vice versa. It is not limited here.

Claims (15)

1. A clock switching method, the method comprising:
when a main clock signal is normal, a first circuit receives the main clock signal and then provides the main clock signal to a first load, wherein the main clock signal is provided by a main clock circuit connected with the first circuit;
when the main clock signal is abnormal, the first circuit receives a standby clock signal, and the standby clock signal is provided by a standby clock circuit connected with the first circuit;
the first circuit reconstructs the phase of the standby clock signal to generate a first reconstructed clock signal, and the phase of the first reconstructed clock signal is consistent with the phase of the main clock signal before abnormality;
the first circuit provides the first reconstructed clock signal to the first load;
the first circuit continuously adjusts the phase of the first reestablished clock signal according to the standby clock signal and a preset phase adjustment speed to generate a plurality of adjustment clock signals, the phase of the adjustment clock signal generated last in the plurality of adjustment clock signals is equal to the phase of the standby clock signal, and except for the adjustment clock signal generated last, the phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phase of the first reestablished clock signal and the phase of the standby clock signal;
the first circuit provides the adjusted clock signal generated after adjustment to the first load after each adjustment.
2. The method of claim 1, further comprising:
when a master clock signal is normal, a second circuit receives the master clock signal and then provides the master clock signal for a second load, wherein the master clock signal is provided by the master clock circuit connected with the second circuit;
when the main clock signal is abnormal, the second circuit receives a standby clock signal, and the standby clock signal is provided by the standby clock circuit connected with the second circuit;
the second circuit reconstructs the phase of the standby clock signal to generate a second reconstructed clock signal, and the phase of the second reconstructed clock signal is consistent with the phase of the main clock signal before abnormality;
the second circuit provides the second reconstructed clock signal to the second load;
the second circuit continuously adjusts the phase of the second reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of compensation clock signals, the phase of the last generated compensation clock signal in the plurality of compensation clock signals is equal to the phase of the standby clock signal, and except the last generated compensation clock signal, the phases of other compensation clock signals in the plurality of compensation clock signals are between the phase of the second reconstructed clock signal and the phase of the standby clock signal;
the second circuit provides the compensation clock signal generated after adjustment to the second load after each adjustment.
3. The method of claim 1 or 2, wherein the first circuit comprises a first control circuit and a first phase-locked loop circuit, the first control circuit being connected to the first phase-locked loop circuit;
the method further comprises the following steps: when the main clock signal is abnormal, the first control circuit sets the working state of the first phase-locked loop circuit to be a phase reconstruction state;
the first circuit reconstructs a phase of the standby clock signal to generate a first reconstructed clock signal, and includes:
when the working state of the first phase-locked loop circuit is a phase reconstruction state, reconstructing the phase of the standby clock signal to generate a first reconstruction clock signal;
the method further comprises the following steps: the first control circuit determines that the first phase-locked loop circuit generates the first reestablished clock signal, and sets the working state of the first phase-locked loop circuit to be a phase compensation state;
the first circuit continuously adjusts the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, and the method comprises the following steps:
and when the working state of the first phase-locked loop circuit is a phase compensation state, continuously adjusting the phase of the first reestablished clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjustment clock signals.
4. The method of claim 3, wherein the first circuit provides a clock signal to the first load through a clock signal output port of the first circuit, wherein the clock signal output port of the first circuit is connected to a feedback clock signal input port of the first circuit, and wherein the feedback clock signal input port of the first circuit is connected to a feedback input port of the first phase-locked loop circuit;
the method further comprises the following steps: before the first phase-locked loop circuit reconstructs the phase of the standby clock signal, closing a feedback input port of the first phase-locked loop circuit, and stopping receiving the clock signal output by a clock signal output port of the first circuit from the feedback input port of the first phase-locked loop circuit;
the method further comprises the following steps:
before the first phase-locked loop circuit continuously adjusts the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, closing an oscillator feedback port of the first phase-locked loop circuit, stopping receiving the clock signal provided by the oscillator from the oscillator feedback port of the first phase-locked loop circuit, and opening a feedback input port of the first phase-locked loop circuit;
when the working state of the first phase-locked loop circuit is a phase compensation state, continuously adjusting the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, including:
and when the working state of the first phase-locked loop circuit is a phase compensation state, continuously adjusting the phase of the first reestablished clock signal according to the standby clock signal, the clock feedback signal received from the feedback input port of the phase-locked loop circuit and the preset phase adjustment speed to generate a plurality of adjusted clock signals.
5. The method according to claim 3 or 4, wherein the first phase-locked loop circuit reconstructs the phase of the standby clock signal to generate a first reconstructed clock signal when the operating state is a phase reconstruction state, and comprises:
and when the working state of the first phase-locked loop circuit is a phase reconstruction state, reconstructing the phase of the standby clock signal according to the phase difference to generate a first reconstruction clock signal, wherein the phase difference is the phase difference between the standby clock signal and the main clock signal before abnormality.
6. The method of any of claims 1 to 5, wherein the frequency of the standby clock signal is determined according to an average of the frequencies of the master clock signals provided by the master clock circuit over a preset time period.
7. A clock switching device is characterized by comprising a first circuit, a second circuit and a third circuit, wherein the first circuit is respectively connected with a main clock circuit, a standby clock circuit and a first load;
the first circuit is configured to provide a master clock signal to the first load after receiving the master clock signal when the master clock signal is normal, where the master clock signal is provided by the master clock circuit;
the first circuit is further configured to receive a standby clock signal when the master clock signal is abnormal, the standby clock signal being provided by the standby clock circuit;
the first circuit is further configured to reconstruct a phase of the standby clock signal to generate a first reconstructed clock signal, where the phase of the first reconstructed clock signal is consistent with a phase of the master clock signal before the abnormality;
the first circuit is further configured to provide the first reconstructed clock signal to the first load;
the first circuit is further configured to continuously adjust a phase of the first reconstructed clock signal according to the standby clock signal and a preset phase adjustment speed to generate a plurality of adjustment clock signals, where a phase of a last adjustment clock signal generated in the plurality of adjustment clock signals is equal to a phase of the standby clock signal, and except for the last adjustment clock signal generated in the plurality of adjustment clock signals, phases of other adjustment clock signals in the plurality of adjustment clock signals are between the phase of the first reconstructed clock signal and the phase of the standby clock signal;
the first circuit is further configured to provide the adjusted clock signal generated after adjustment to the first load after each adjustment.
8. The apparatus of claim 7, further comprising: a second circuit; the second circuit is respectively connected with the main clock circuit, the standby clock circuit and a second load;
the second circuit is configured to provide the master clock signal to the second load after receiving the master clock signal when the master clock signal is normal, where the master clock signal is provided by the master clock circuit;
the second circuit is further configured to receive a standby clock signal when the master clock signal is abnormal, the standby clock signal being provided by the standby clock circuit;
the second circuit is further configured to reconstruct a phase of the standby clock signal to generate a second reconstructed clock signal, where the phase of the second reconstructed clock signal is consistent with the phase of the master clock signal before the abnormality;
the second circuit is further configured to provide the second reconstructed clock signal to the second load;
the second circuit is further configured to continuously adjust a phase of the second reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of compensation clock signals, a phase of a last generated compensation clock signal of the plurality of compensation clock signals is equal to a phase of the standby clock signal, and except for the last generated compensation clock signal, phases of other compensation clock signals of the plurality of compensation clock signals are between the phase of the second reconstructed clock signal and the phase of the standby clock signal;
the second circuit is further configured to provide the compensated clock signal generated after the adjustment to the second load after each adjustment.
9. The apparatus of claim 7 or 8, wherein the first circuit comprises a first control circuit and a first phase-locked loop circuit, the first control circuit being connected to the first phase-locked loop circuit;
the first control circuit is used for setting the working state of the first phase-locked loop circuit to be a phase reconstruction state when the main clock signal is abnormal;
the first phase-locked loop circuit is used for reconstructing the phase of the standby clock signal to generate a first reconstructed clock signal when the working state is a phase reconstruction state;
the first control circuit is further configured to determine that the first phase-locked loop circuit generates the first reconstructed clock signal, and set an operating state of the first phase-locked loop circuit to a phase compensation state;
and the first phase-locked loop circuit is further configured to, when the operating state is the phase compensation state, continuously adjust the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjustment clock signals.
10. The apparatus of claim 9, wherein the first circuit provides a clock signal to the first load through a clock signal output port of the first circuit, wherein the clock signal output port of the first circuit is connected to a feedback clock signal input port of the first circuit, and wherein the feedback clock signal input port of the first circuit is connected to a feedback input port of the first phase-locked loop circuit;
the first phase-locked loop circuit is further configured to close a feedback input port of the first phase-locked loop circuit before reconstructing a phase of the standby clock signal, and stop receiving the clock signal output by the clock signal output port of the first circuit from the feedback input port of the first phase-locked loop circuit;
the first phase-locked loop circuit is further configured to, before continuously adjusting the phase of the first reconstructed clock signal according to the standby clock signal and the preset phase adjustment speed to generate a plurality of adjusted clock signals, close an oscillator feedback port of the first phase-locked loop circuit, stop receiving the clock signal provided by the oscillator from the oscillator feedback port of the first phase-locked loop circuit, and open a feedback input port of the first phase-locked loop circuit;
the first phase-locked loop circuit is further configured to, when the operating state is the phase compensation state, continuously adjust the phase of the first reconstructed clock signal according to the standby clock signal, a clock feedback signal received from a feedback input port of the phase-locked loop circuit, and the preset phase adjustment speed to generate a plurality of adjusted clock signals.
11. The apparatus according to claim 9 or 10, wherein the first phase-locked loop circuit is specifically configured to, when the operating state is a phase reconstruction state, reconstruct a phase of the standby clock signal according to a phase difference between the standby clock signal and the master clock signal before the abnormality to generate a first reconstructed clock signal.
12. The apparatus of any of claims 7 to 11, wherein the frequency of the standby clock signal is determined according to an average of the frequencies of the master clock signals provided by the master clock circuit over a preset time period.
13. A server, comprising one or more loads, and comprising one or more clock switching devices having the same number as that of all the loads, all the loads being connected to all the clock switching devices in a one-to-one correspondence, the clock switching devices being as claimed in any one of claims 7 to 12, a clock signal output port of the clock switching device being connected to the corresponding load to provide a clock signal to the corresponding load.
14. A clock system comprising a master clock circuit, a standby clock circuit and at least one server as claimed in claim 13, all clock switching means of all servers being connected to said master clock circuit and said standby clock circuit.
15. The system according to claim 14, wherein the load of the server comprises at least one processor, or the load of the server comprises at least one processor and one node controller, all processors and the node controllers of the load are connected to the clock switching device corresponding to the load, and all node controllers of all servers of the system are connected to each other.
CN201810123462.0A 2018-02-07 2018-02-07 Clock switching method, apparatus, server and clock system Active CN110119331B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810123462.0A CN110119331B (en) 2018-02-07 2018-02-07 Clock switching method, apparatus, server and clock system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810123462.0A CN110119331B (en) 2018-02-07 2018-02-07 Clock switching method, apparatus, server and clock system

Publications (2)

Publication Number Publication Date
CN110119331A true CN110119331A (en) 2019-08-13
CN110119331B CN110119331B (en) 2021-10-01

Family

ID=67520146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810123462.0A Active CN110119331B (en) 2018-02-07 2018-02-07 Clock switching method, apparatus, server and clock system

Country Status (1)

Country Link
CN (1) CN110119331B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112713951A (en) * 2020-08-13 2021-04-27 中车株洲电力机车研究所有限公司 Synchronous clock switching method and device, storage medium and electronic equipment
CN113396553A (en) * 2020-01-06 2021-09-14 华为技术有限公司 Clock switching method, equipment and storage medium
CN115021857A (en) * 2022-08-08 2022-09-06 中汽创智科技有限公司 Clock synchronization method and device, electronic equipment and storage medium
CN116366197A (en) * 2023-03-28 2023-06-30 武汉烽火技术服务有限公司 A fast clock locking method, device and system for active and standby clock switching
US12272315B2 (en) 2022-05-10 2025-04-08 Chengdu Boe Optoelectronics Technology Co., Ltd. Method of driving scan circuit, scan circuit, and display apparatus

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1592134A (en) * 2003-08-27 2005-03-09 华为技术有限公司 Phase alignment method for master and stand-by clocks
CN101162959A (en) * 2007-10-19 2008-04-16 中兴通讯股份有限公司 Clock master-slave phase difference automatic measurement and compensation process
CN102726058A (en) * 2011-11-25 2012-10-10 华为技术有限公司 Optical network switching nodes, optical burst synchronization method and circuit frame of multi-frame cluster
CN104049525A (en) * 2014-03-24 2014-09-17 成都可为科技发展有限公司 Method for eliminating phase differences between multiple time input sources in clock
US20160085263A1 (en) * 2014-09-22 2016-03-24 Intel Corporation Synchronization of domain counters
CN106027040A (en) * 2015-03-31 2016-10-12 美高森美半导体无限责任公司 Hardware Delay Compensation in Digital Phase Locked Loop
CN106160914A (en) * 2016-07-22 2016-11-23 浙江工业大学 IEEE1588 clock synchronization method based on interference observation feedback control technology

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1592134A (en) * 2003-08-27 2005-03-09 华为技术有限公司 Phase alignment method for master and stand-by clocks
CN101162959A (en) * 2007-10-19 2008-04-16 中兴通讯股份有限公司 Clock master-slave phase difference automatic measurement and compensation process
CN102726058A (en) * 2011-11-25 2012-10-10 华为技术有限公司 Optical network switching nodes, optical burst synchronization method and circuit frame of multi-frame cluster
CN104049525A (en) * 2014-03-24 2014-09-17 成都可为科技发展有限公司 Method for eliminating phase differences between multiple time input sources in clock
US20160085263A1 (en) * 2014-09-22 2016-03-24 Intel Corporation Synchronization of domain counters
CN106027040A (en) * 2015-03-31 2016-10-12 美高森美半导体无限责任公司 Hardware Delay Compensation in Digital Phase Locked Loop
CN106160914A (en) * 2016-07-22 2016-11-23 浙江工业大学 IEEE1588 clock synchronization method based on interference observation feedback control technology

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113396553A (en) * 2020-01-06 2021-09-14 华为技术有限公司 Clock switching method, equipment and storage medium
CN113396553B (en) * 2020-01-06 2023-12-08 华为技术有限公司 Clock switching method, device and storage medium
CN112713951A (en) * 2020-08-13 2021-04-27 中车株洲电力机车研究所有限公司 Synchronous clock switching method and device, storage medium and electronic equipment
CN112713951B (en) * 2020-08-13 2021-11-23 中车株洲电力机车研究所有限公司 Synchronous clock switching method and device, storage medium and electronic equipment
US12272315B2 (en) 2022-05-10 2025-04-08 Chengdu Boe Optoelectronics Technology Co., Ltd. Method of driving scan circuit, scan circuit, and display apparatus
CN115021857A (en) * 2022-08-08 2022-09-06 中汽创智科技有限公司 Clock synchronization method and device, electronic equipment and storage medium
CN115021857B (en) * 2022-08-08 2022-12-16 中汽创智科技有限公司 Clock synchronization method and device, electronic equipment and storage medium
CN116366197A (en) * 2023-03-28 2023-06-30 武汉烽火技术服务有限公司 A fast clock locking method, device and system for active and standby clock switching

Also Published As

Publication number Publication date
CN110119331B (en) 2021-10-01

Similar Documents

Publication Publication Date Title
CN110119331B (en) Clock switching method, apparatus, server and clock system
US6239626B1 (en) Glitch-free clock selector
EP1179236B1 (en) System and method for providing master and slave phase-aligned clocks
US20090102534A1 (en) Decentralised fault-tolerant clock pulse generation in vlsi chips
JPH03182947A (en) Memory device
CN113014350A (en) PMC interface-based time synchronization method between simulation devices
US7487377B2 (en) Method and apparatus for fault tolerant time synchronization mechanism in a scaleable multi-processor computer
JP4061273B2 (en) Seamless clock
CN113157046B (en) Method, device and system for managing server BMC time
CN100438361C (en) Method for controlling master spare clock phase for synchronous digital system equipment
US6724850B1 (en) Deterministic hardware behavior between multiple asynchronous clock domains through the novel use of a PLL
CN103403666B (en) Distributed storage control method, Apparatus and system
CN106412011A (en) High-availability cluster system without shared storage among multiple nodes, and implementation
CN105990898A (en) Parallel UPS (Uninterruptible Power Supply) system and phase lock method and device
KR20040104387A (en) Programmable clock management component reconfiguration upon receipt of one or more control signals to be able to process one or more frequency signals
US7809025B2 (en) System and method for distributing clock signals
EP0800136B1 (en) Fault tolerant clock signal source for triplicated data processing system
JPH01267701A (en) Digital controller for controlling power
CN100561906C (en) Method and device for implementing clock master-standby switchover without error
US5745742A (en) Apparatus for coordinating clock distribution in a fully redundant computer system
US20250315351A1 (en) Method and apparatus for node-pair enclosure replacement
JPS62187901A (en) Control method of redundant controller
JPH086664A (en) Computer and its clock switching method
Cheblakov et al. New IT-infrastructure of accelerators at BINP
CN116016141A (en) A control method for a monitoring dual-machine system and a monitoring dual-machine system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant