Clock synchronization method, device, equipment, medium and product
By obtaining external clock signals, synchronizing the naked running system and operating system in the CPU system, the problem of clock synchronization in distribution terminal devices is solved, and the precise synchronization of clocks and real-time requirements are achieved.
Patent Information
- Application Number
- CN202410960621.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-11-12
AI Technical Summary
In distribution terminal devices, clock synchronization between multiple systems is difficult to achieve, resulting in the inability to meet real-time requirements. Especially in control systems that operate independently within multi-core CPUs in AMP architecture mode, clock synchronization challenges exist.
By obtaining external clock signals, such as main station clock signals, SNTP clock signals, GPS clock signals and set pattern clock signals, these signals are used to synchronize the naked running system and operating system in the central processor CPU system to achieve clocking Precise synchronization.
It realizes accurate synchronization of clocks in the CPU system, meets real-time requirements, and improves the system's clock consistency and accuracy.
Smart Images

Figure CN118944795A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of clock synchronization technology, and in particular to a clock synchronization method, apparatus, device, medium and product. Background Art
[0002] Distribution network terminal equipment has services that require real-time performance. Therefore, many distribution network terminal equipment run in AMP architecture mode. Multiple control systems are independently running in the multi-core CPU, some of which run real-time services such as protection actions, and some run non-real-time services such as communication. The clocks of multiple systems need to be synchronized. Summary of the invention
[0003] The embodiments of the present disclosure provide a clock synchronization method, apparatus, device, medium and product, which realize accurate synchronization of clocks in a CPU system.
[0004] In a first aspect, a clock synchronization method is provided, comprising:
[0005] Acquire an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type;
[0006] The external clock signal is used to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system.
[0007] In a second aspect, a clock synchronization device is provided, comprising:
[0008] A clock signal acquisition module, used to acquire an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type;
[0009] The synchronization module is used to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system using the external clock signal.
[0010] According to a third aspect, an electronic device is provided, the electronic device comprising:
[0011] one or more processors;
[0012] a storage device for storing one or more programs,
[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the clock synchronization method as described in the first aspect above.
[0014] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the clock synchronization method as described in the first aspect is implemented.
[0015] In a fifth aspect, a computer program product is provided, the computer program product comprising a computer program, and the computer program, when executed by a processor, implements the clock synchronization method as described in the first aspect above.
[0016] The disclosed embodiment discloses a clock synchronization method, device, equipment, medium and product, the method comprising: obtaining an external clock signal, the external clock signal comprising a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type; using the external clock signal to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system. The technical solution synchronizes the clocks of the naked running system and the operating system in the central processing unit CPU system using an external clock signal, thereby achieving accurate synchronization of the clocks in the CPU system.
[0017] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the embodiments of the present disclosure. Other features of the embodiments of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 is a flow chart of a clock synchronization method provided in Embodiment 1 of the present disclosure;
[0020] Figure 2 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system through a master station clock signal and / or an SNTP clock signal provided in Embodiment 1 of the present disclosure;
[0021] Figure 3 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system using a GPS clock signal provided in Embodiment 1 of the present disclosure;
[0022] Figure 4 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system using a B-code clock signal provided in the first embodiment of the present disclosure;
[0023] Figure 5 This is another schematic diagram of synchronizing a dual-core CPU+FPGA system by using a B-code clock signal provided in the first embodiment of the present disclosure;
[0024] Figure 6 This is a schematic diagram of clock synchronization of a dual-core CPU provided in the first embodiment of the present disclosure;
[0025] Figure 7 This is a schematic diagram of clock synchronization of a quad-core CPU provided in the first embodiment of the present disclosure;
[0026] Figure 8 is a structural diagram of a clock synchronization device provided in Embodiment 2 of the present disclosure;
[0027] Fig. 9 It is a structural diagram of an electronic device provided in Embodiment 3 of the present disclosure. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the solutions of the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only embodiments of a part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the embodiments of the present disclosure.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0030] Embodiment 1
[0031] Figure 1This is a flowchart of a clock synchronization method provided in the first embodiment of the present disclosure. This embodiment is applicable to the case of synchronizing clocks. The method can be executed by a clock synchronization device. The clock synchronization device can be implemented in the form of hardware and / or software. The clock synchronization device can be configured in an electronic device, including but not limited to computers, computers, terminals, servers and other devices with data processing capabilities. Figure 1 As shown, the method includes:
[0032] S110, obtaining an external clock signal, where the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type.
[0033] In this embodiment, an external clock signal can be obtained, and the external clock signal comes from a clock signal outside the central processing unit (CPU) system. For example, the external clock signal may include a master station clock signal, a simple network time protocol (SNTP) clock signal, a global positioning system (GPS) clock signal and / or a clock signal of a set code type.
[0034] Among them, the master station clock signal can be a central server or device in some specific network or system as a source of time, providing time synchronization signals to other devices. In this case, the master station clock signal can be sent by this device to ensure that the time of all devices in the entire network or system is consistent; in the distribution network (distribution network system), the "master station" usually refers to the core part of the distribution management system (DMS), which is responsible for the monitoring, control and data management of the entire distribution network; SNTP can be a network protocol used to simplify the time synchronization process. The SNTP client can request time from the SNTP server to ensure that its system time is synchronized with the server time; the GPS clock signal can be a time signal sent by a GPS satellite; the clock signal of the set code type can be a clock signal with a specific encoding rule, and the clock signal of the set code type can include a B code clock signal, a PPS (Pulse Per Second) code, an MSF (Multiplexed Synchronous Format) code and / or an SBS (Straight Binary Seconds) code, etc.
[0035] S120, synchronizing the clocks of the naked running system and the operating system in the central processing unit CPU system using an external clock signal.
[0036] Specifically, after obtaining the external clock signal, the clocks of the naked running system and the operating system in the CPU system can be synchronized according to the external clock signal. It should be noted that, depending on the different external clock signals, when the CPU system is synchronized using the external clock signal, the synchronization method can also be different.
[0037] In this embodiment, the CPU system may include a bare-metal system (BSM) and an operating system (OS). The bare-metal system and the operating system are two different system environments. The bare-metal system refers to software that runs directly on the hardware without the intervention of the operating system. In this configuration, the software interacts directly with the hardware to perform the required tasks. The bare-metal system is usually used in embedded systems, real-time systems, or other occasions that require high performance and low latency.
[0038] Continuing with the above description, an operating system is a set of software that manages computer hardware resources and provides services to users and other software. It provides an interface between users and computer hardware. The main functions of an operating system include process management, memory management, file system management, input / output device management, etc.
[0039] This embodiment provides a clock synchronization method, including: obtaining an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type; using the external clock signal to synchronize the clocks of a naked running system and an operating system in a central processing unit CPU system, thereby achieving accurate synchronization of the clock in the CPU system.
[0040] As an optional implementation, the use of the external clock signal to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system includes:
[0041] a1) when the external clock signal is a master station clock signal and / or an SNTP clock signal, adjusting the clock of the operating system using the time in the master station clock signal and / or the SNTP clock signal to obtain a precise clock of the operating system, wherein the time delay is the delay time for the master station clock signal and / or the SNTP clock signal to be transmitted to the operating system;
[0042] Specifically, when the external clock signal is a master station clock signal and / or an SNTP clock signal, the operating system in the CPU system can be used to receive the master station clock signal and / or the SNTP clock signal, so as to adjust the clock of the operating system using the time in the master station clock signal and / or the SNTP clock signal; it should be explained that the master station clock signal and / or the SNTP clock signal can include not only time but also delay, so as to adjust the clock of the operating system using the time and delay in the master station clock signal and / or the SNTP clock signal, thereby obtaining the precise clock of the operating system, wherein the delay is the delay time for the master station clock signal and / or the SNTP clock signal to be transmitted to the operating system.
[0043] For example, the time of the master station clock signal and / or SNTP clock signal received by the operating system is 8:00:00, and the delay is 1 second, then the clock of the operating system can be adjusted to 8:00:01.
[0044] b1) after the operating system receives a pulse-per-second signal sent by a field programmable gate array FPGA, trigger an interrupt using an interrupt processing function, and calculate the difference between the current system time of the operating system and the pulse-per-second signal, wherein the FPGA is used to provide the pulse-per-second signal for the CPU system;
[0045] In this embodiment, the Field-Programmable Gate Array (FPGA) can be a programmable semiconductor device. In this embodiment, the FPGA can output a pulse per second signal (Pulse Per Second, PPS) to the CPU system through timing at fixed time intervals. After the operating system completes the time synchronization to obtain an accurate clock, when the operating system receives the pulse per second signal sent by the FPGA, the operating system can use the interrupt processing function to trigger an interrupt, wherein the interrupt processing function can save the current CPU state, including register values and program counters, so that it can be restored to the state before the interrupt occurs after the interrupt processing is completed. The pulse per second signal can be a periodic signal with a period of 1 second, that is, the pulse per second signal is repeated once every second for a whole second.
[0046] Following the above description, after the operating system triggers an interrupt using the interrupt processing function, the current system time of the operating system can be obtained, and the difference between the current system time of the operating system and the second pulse signal received by the operating system can be calculated.
[0047] c1) correcting the pulse-per-second signal of the field programmable gate array FPGA according to the difference to obtain a corrected pulse-per-second signal;
[0048] Specifically, by calculating the difference between the current system time of the operating system and the second pulse signal received by the operating system, the second pulse signal of the FPGA can be corrected according to the difference between the current system time of the operating system and the second pulse signal received by the operating system to obtain a corrected second pulse signal, wherein the corrected second pulse signal can be a corrected second pulse signal emitted by the FPGA.
[0049] Specifically, after obtaining the difference, the trigger time of the second pulse can be adjusted according to the difference. For example, if the current system time of the operating system is slower than the second pulse time, the second pulse signal can be delayed according to the value of the difference; if the current system time of the operating system is faster than the second pulse time, the second pulse signal can be sent in advance according to the value of the difference.
[0050] d1) Correcting the time of the setting unit of the treadmill system according to the corrected second pulse signal to synchronize the clocks of the treadmill system and the operating system, wherein the setting unit includes a time unit smaller than a second.
[0051] It should be noted that the running system in the CPU system and the operating system can achieve clock synchronization by memory sharing. Therefore, after obtaining the precise clock of the operating system using an external clock signal, the operating system can achieve clock synchronization with the running system. However, due to memory sharing, the time of the running system is not completely synchronized with the time of the operating system. Therefore, the FPGA's corrected second pulse signal is required to accurately adjust the clock of the running system.
[0052] In this embodiment, after correcting the second pulse signal of the FPGA, the corrected second pulse signal of the FPGA can be used to correct the time of the set unit of the naked running system in the CPU system to synchronize the clocks of the naked running system and the operating system, wherein the set unit includes a time unit less than a second, such as: the corrected second pulse signal can be used to correct the time less than a second of the naked running system.
[0053] Figure 2 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system using a master station clock signal and / or an SNTP clock signal provided in this embodiment. Figure 2 As shown, Core0 runs a naked system and Core1 runs an operating system. When the external clock signal is a master station clock signal and / or an SNTP clock signal, the clock of Core1 is accurately adjusted by the master station clock signal and / or the SNTP clock signal, and Core0 and Core1 can share the clock by sharing memory. Core1 is used to adjust the second pulse signal of FPGA to obtain a modified second pulse signal, and FPGA can adjust the set unit time of Core0 by modifying the second pulse signal.
[0054] As an optional implementation, the use of the external clock signal to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system includes:
[0055] a2) when the external clock signal is a GPS clock signal, the current system time of the operating system is modified to the time of the GPS clock signal, and the current system time of the operating system is transmitted to the naked running system by means of memory sharing;
[0056] In this embodiment, when the external signal is a GPS clock signal, the GPS clock signal can be received by the operating system in the CPU system, and the current system time of the operating system in the CPU system can be modified to the time of the GPS clock signal. It should be noted that the naked running system and the operating system in the CPU system can achieve clock synchronization through memory sharing. Therefore, the current system time of the operating system can be transmitted to the naked running system through memory sharing to achieve clock synchronization between the operating system and the naked running system.
[0057] b2) receiving the second pulse signal in the GPS clock signal through FPGA, and transmitting the second pulse signal to the treadmill system and the operating system, so as to correct the set unit time in the current system time of the treadmill system and the operating system; wherein the set unit is a time unit less than a second; the FPGA is used to provide the second pulse signal for the CPU system.
[0058] It should be noted that the GPS clock signal may also include a second pulse signal, and the second pulse signal in the CPS clock signal may be received by the FPGA, that is, it can be understood that the FPGA may be used to provide a second pulse signal for the CPU system. Specifically, the clock synchronization of the operating system and the naked running system using memory sharing is not accurate, therefore, the second pulse signal in the GPS clock signal received by the FPGA may be used to accurately adjust the clocks of the operating system and the naked running system.
[0059] Specifically, the second pulse signal in the GPS clock signal received by the FPGA can be transmitted to the naked running system and the operating system to correct the set unit time in the current system time of the naked running system and the operating system; wherein the set unit is a time unit smaller than a second.
[0060] Exemplarily, after the treadmill system and the operating system receive the second pulse signal transmitted by the FPGA, the treadmill system and the operating system can trigger an interrupt processing function and use the second pulse to adjust the current system time of the treadmill system and the operating system, such as: the treadmill system receives the second pulse signal transmitted by the FPGA when the current system time is 8:00:01:600, and the current millisecond is already halfway through, so the current system time can be adjusted to 8:00:02:000; the treadmill system receives the second pulse signal transmitted by the FPGA when the current system time is 8:00:01:400, and the current millisecond is not yet halfway through, so the current system time can be adjusted to 8:00:01:000.
[0061] Figure 3 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system using a GPS clock signal provided in this embodiment. Figure 3 As shown in the figure, Core0 runs the bare-metal system and Core1 runs an operating system. When the external clock signal is a GPS clock signal, the clock of Core1 is accurately adjusted by the time of the GPS clock signal, and Core0 and Core1 can share the clock by sharing memory. FPGA can receive the second pulse signal in the GPS clock signal and use the second pulse signal to adjust the time of the set unit of Core0 and Core1.
[0062] As an optional implementation, the use of the external clock signal to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system includes:
[0063] a3) receiving a clock signal of a set code pattern through FPGA, and analyzing the clock signal of the set code pattern to obtain the time and second pulse signal of the clock signal of the set code pattern;
[0064] In this embodiment, the FPGA can also receive a clock signal of a set pattern, such as a B-code clock signal. After receiving the clock signal of the set pattern, the FPGA can analyze the clock of the set pattern to obtain the time and second pulse signal of the clock signal of the set pattern.
[0065] b3) transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system, so that the operating system and the naked running system are synchronized;
[0066] Specifically, after the FPGA analyzes the clock signal of the set code type to obtain the time and second pulse signal of the clock signal of the set code type, the time of the clock signal of the set code type can be transmitted to the operating system or the naked running system in the CPU system, so that the operating system and the naked running system can be synchronized.
[0067] c3) transmitting the second pulse signal to the streaking system and the operating system simultaneously to correct the set unit time in the current system time of the streaking system and the operating system; wherein the set unit is a time unit less than a second; and the FPGA is used to provide the second pulse signal for the CPU system.
[0068] Specifically, after the FPGA analyzes the clock signal of the set code type to obtain the time and second pulse signal of the clock signal of the set code type, the FPGA is used to provide the second pulse signal for the CPU system, that is, the FPGA can simultaneously transmit the second pulse signal of the clock signal of the set code type to the naked running system and the operating system to correct the time of the set unit in the current system time of the naked running system and the operating system; wherein the set unit is a time unit less than a second.
[0069] Optionally, the transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system so that the operating system and the naked running system are synchronized includes:
[0070] a4) transmitting the time of the clock signal of the set code pattern to the streaking system to correct the current system time of the streaking system;
[0071] Specifically, after the FPGA analyzes the clock signal of the set code type to obtain the time and second pulse signal of the clock signal of the set code type, the time of the clock signal of the set code type can be transmitted to the naked running system in the CPU system to correct the current system time of the naked running system.
[0072] Exemplarily, the time of the clock signal of the set pattern may be 8:00:02:678, and the current system time in the operating system may be modified to 8:00:02:678.
[0073] b4) transmitting the current system time of the naked running system to the operating system by means of memory sharing, so that the operating system and the naked running system are synchronized;
[0074] In this embodiment, after the current system time of the naked running system is corrected, the current system time of the naked running system can be transmitted to the operating system through memory sharing, so that the operating system and the naked running system can be synchronized.
[0075] Alternatively, the step of transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system so that the operating system and the naked running system are synchronized may further include:
[0076] a5) transmitting the time of the clock signal of the set code pattern to the operating system to correct the current system time of the operating system;
[0077] Specifically, after the FPGA analyzes the clock signal of the set code type to obtain the time and second pulse signal of the clock signal of the set code type, the time of the clock signal of the set code type can be transmitted to the operating system in the CPU system to correct the current system time of the operating system.
[0078] Exemplarily, the time of the clock signal of the set code type may be 8:00:03:222, and the current system time in the naked running system may be modified to 8:00:03:222.
[0079] b5) transmitting the current system time of the operating system to the naked running system by means of memory sharing, so that the naked running system can synchronize time with the operating system.
[0080] In this embodiment, after the current system time of the naked running system is corrected, the current system time of the naked running system can be transmitted to the operating system through memory sharing, so that the operating system and the naked running system can be synchronized.
[0081] Figure 4 This is a schematic diagram of synchronizing a dual-core CPU+FPGA system using a B-code clock signal provided in this embodiment. Figure 4 As shown in the figure, Core0 runs the bare-metal system and Core1 runs an operating system. When the external clock signal is a B-code clock signal, the B-code clock signal is parsed by FPGA to obtain the time and pulse-per-second signal of the B-code clock signal, and the clock of Core0 is accurately adjusted by the time of the B-code clock signal. At the same time, Core0 and Core1 can share the clock by sharing memory. The pulse-per-second signal is sent to Core0 and Core1 at the same time, and the time of the set unit of Core0 and Core1 is adjusted by the pulse-per-second signal.
[0082] Figure 5 Another schematic diagram of synchronizing a dual-core CPU+FPGA system using a B-code clock signal provided in this embodiment. Figure 5As shown in the figure, Core0 runs the bare-metal system and Core1 runs an operating system. When the external clock signal is a B-code clock signal, the B-code clock signal is parsed by FPGA to obtain the time and pulse-per-second signal of the B-code clock signal, and the clock of Core1 is accurately adjusted by the time of the B-code clock signal. At the same time, Core0 and Core1 can share the clock by sharing memory. The pulse-per-second signal is sent to Core0 and Core1 at the same time, and the time of the set unit of Core0 and Core1 is adjusted by the pulse-per-second signal.
[0083] As an optional implementation, the clock synchronization method provided in this embodiment may further include: the naked running system and the operating system achieve clock synchronization through memory sharing at preset time intervals.
[0084] It should be noted that the operating system and the naked running system in the CPU system can achieve clock synchronization at a preset time interval and through memory sharing, wherein the preset time interval can be a pre-set time interval, and exemplarily, the preset time interval can be 100 microseconds.
[0085] It should be noted that if no particular synchronization method is selected during the synchronization process and all synchronization methods are selected, the synchronization can be performed in the following order: B code synchronization, GPS synchronization, SNTP synchronization, and master station synchronization.
[0086] Take a dual-core CPU as an example to describe the technical solution: Figure 6 This is a schematic diagram of clock synchronization of a dual-core CPU provided in this embodiment, such as Figure 6 As shown, Figure 6 It is a dual-core CPU + FPGA system architecture. In the CPU, Core0 runs the bare-metal system and Core1 runs an operating system. The bare-metal system plus an operating system running non-real-time services, a total of two control systems, need to be clock synchronized.
[0087] The Core1 system is responsible for the non-real-time business of external communication, directly responsible for external network, serial port and other communications, directly completing the master station time synchronization, GPS time synchronization, SNTP time synchronization, etc., and correcting its own system time. That is, the Core1 system time in the calibration diagram, and at the same time, Core1 shares the time with the Core0 control system through memory sharing at regular intervals (such as 100us).
[0088] The master station synchronization, SNTP synchronization and other network synchronization methods synchronize Core1 through the master station and SNTP, and correct the second pulse signal of FPGA after Core1 completes the synchronization. In order to improve the synchronization accuracy, the second pulse signal is output to the CPU through the FPGA timing. Core0 corrects the time value of its own system time less than seconds according to the second pulse signal of FPGA, thereby improving the accuracy of Core0 system time. The method for Core1 system to correct the second pulse signal to FPGA: Core1 triggers an interrupt when receiving the second pulse signal of FPGA, obtains the current system time in the interrupt processing function, and calculates the difference between the current system time and the whole second, that is, the correction value required for the second pulse in FPGA, and then writes the correction value to FPGA. FPGA corrects its own second pulse signal according to the difference, and can obtain an accurate second pulse signal.
[0089] The GPS time synchronization method has a second pulse signal and serial data access device. The Core1 system reads the GPS serial data to correct the time above a second. The GPS second pulse signal (GPS-PPS) is connected to the FPGA and then transferred to the CPU. Both the Core0 and Core1 systems use the second pulse signal to correct the time value less than a second (less than a second) in their own system time. When Core0 and Core1 receive the second pulse signal from the FPGA, they each trigger an interrupt and correct their own system time in their respective interrupts.
[0090] When aligning the B code, the system time of each core in the CPU is calibrated through the second pulse. The FPGA parses the B code and generates a PPS second pulse to generate a second pulse interrupt signal to the Core0 and Core1 systems. Each core system in the CPU completes the whole second time calibration in the second pulse interrupt. The FPGA-parsed B code is read by Core0, and Core0 synchronizes the read B code time (timestamps above seconds) to the Core1 system through memory sharing. The FPGA-parsed B code can also be read by Core1, and Core1 synchronizes the read B code time (timestamps above seconds) to the Core0 system through memory sharing.
[0091] This technical solution is described using a quad-core CPU as an example: Figure 7 This is a schematic diagram of clock synchronization for a quad-core CPU provided in this embodiment, such as Figure 7 As shown, Figure 7 It is a quad-core CPU + FPGA system architecture. Some cores run real-time services, such as Core0 and Core1 running their own bare-metal systems. Some core systems run non-real-time services, such as Core2 and Core3 running an operating system together. Two bare-metal systems running real-time services and one operating system running non-real-time services, a total of three control systems need to be synchronized.
[0092] Core2 and Core3 are responsible for the non-real-time business of external communication, directly responsible for external network and serial port communication, directly completing the master station time synchronization, GPS time synchronization, SNTP time synchronization, etc., and correcting their own system time. That is, the Core2 and Core3 system time in the calibration diagram, at the same time, Core2 and Core3 share the time with the control system of Core0 and Core1 through memory sharing at regular intervals (for example, 100us).
[0093] To improve the accuracy of time synchronization, the master station time synchronization and SNTP time synchronization output the second pulse signal to the CPU through the FPGA through timing. Core0 and Core1 correct the time value less than a second in their own system time according to the second pulse signal of the FPGA, thereby improving the accuracy of the Core0 and Core1 system time. The network time synchronization methods such as the master station time synchronization and SNTP time synchronization correct the second pulse signal to the FPGA after Core2 and 3 complete the time synchronization. The method for the Core2 and 3 systems to correct the second pulse signal to the FPGA: Core2 and 3 trigger an interrupt when receiving the second pulse signal from the FPGA, obtain the current system time in the interrupt processing function, and calculate the difference between the current system time and the whole second, that is, the correction value required for the second pulse in the FPGA, and then write the correction value to the FPGA (or send it to core0 through shared memory, and forward it to the FPGA through Core0). The FPGA corrects its own second pulse signal according to the difference, and can obtain an accurate second pulse signal.
[0094] The GPS time synchronization method has a second pulse signal and serial data access device. Core2 and 3 systems read the GPS serial data to correct the time above a second. The second pulse signal of GPS is connected to the FPGA and then transferred to the CPU. The three systems of Core0, Core1, Core2, and 3 all use the second pulse signal to correct the time value of their own system time less than a second. Core0, Core1, Core2, and 3 trigger interrupts when receiving the second pulse signal of FPGA, and correct their own system time in their respective interrupts.
[0095] When aligning the B code, the system time of each core is calibrated by the second pulse. The FPGA parses the B code and generates a PPS second pulse to generate a second pulse interrupt signal to the Core0, Core1, Core2, and 3 systems. Each core system completes the whole second time calibration in the second pulse interrupt. The FPGA parses the B code and is read by core0. Core0 synchronizes the read B code time (timestamps above seconds) to the Core2 and 3 systems through memory sharing.
[0096] When the service does not select a certain time synchronization mode but selects all time synchronization modes, the time synchronization modes are selected in the following order: B code time synchronization, GPS time synchronization, SNTP time synchronization, and master station time synchronization.
[0097] Embodiment 2
[0098] Figure 8 is a schematic diagram of the structure of a clock synchronization device provided in the second embodiment of the present disclosure; Figure 8 As shown, the device includes: a clock signal acquisition module 210 and a synchronization module 220.
[0099] The clock signal acquisition module 210 is used to acquire an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type;
[0100] The synchronization module 220 is used to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system using the external clock signal.
[0101] A second embodiment of the present disclosure provides a clock synchronization device, which realizes accurate synchronization of the clock in the CPU system.
[0102] Furthermore, the synchronization module 220 may also be used to:
[0103] When the external clock signal is a master station clock signal and / or an SNTP clock signal, the clock of the operating system is adjusted using the time in the master station clock signal and / or the SNTP clock signal to obtain a precise clock of the operating system, wherein the time delay is the delay time for the master station clock signal and / or the SNTP clock signal to be transmitted to the operating system;
[0104] After the operating system receives the second pulse signal sent by the field programmable gate array FPGA, an interrupt processing function is used to trigger an interrupt, and the difference between the current system time of the operating system and the second pulse signal is calculated, wherein the FPGA is used to provide the second pulse signal for the CPU system.
[0105] Correcting the pulse-per-second signal of the field programmable gate array FPGA according to the difference to obtain a corrected pulse-per-second signal;
[0106] The time of the setting unit of the treadmill system is corrected according to the corrected second pulse signal to synchronize the clocks of the treadmill system and the operating system, wherein the setting unit includes a time unit smaller than a second.
[0107] Furthermore, the synchronization module 220 may also be used to:
[0108] When the external clock signal is a GPS clock signal, the current system time of the operating system is modified to the time of the GPS clock signal, and the current system time of the operating system is transmitted to the naked running system by means of memory sharing;
[0109] Receiving the second pulse signal in the GPS clock signal through FPGA, and transmitting the second pulse signal to the naked running system and the operating system, so as to correct the time of the set unit in the current system time of the naked running system and the operating system;
[0110] Wherein, the setting unit is a time unit less than a second;
[0111] The FPGA is used to provide a pulse-per-second signal for the CPU system.
[0112] Furthermore, the synchronization module 220 may also include:
[0113] A parsing unit, used for receiving a clock signal of a set code pattern through an FPGA, and parsing the clock signal of the set code pattern to obtain a time and a second pulse signal of the clock signal of the set code pattern;
[0114] A time synchronization unit, used for transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system, so that the operating system and the naked running system are synchronized;
[0115] A time correction unit is used to transmit the second pulse signal to the streaking system and the operating system at the same time, so as to correct the set unit time in the current system time of the streaking system and the operating system; wherein the set unit is a time unit less than a second; and the FPGA is used to provide the second pulse signal for the CPU system.
[0116] Furthermore, the timing unit can also be used for:
[0117] Transmitting the time of the clock signal of the set code pattern to the naked running system to correct the current system time of the naked running system;
[0118] The current system time of the naked running system is transmitted to the operating system by means of memory sharing, so that the operating system and the naked running system are synchronized;
[0119] or,
[0120] Transmitting the time of the clock signal of the set code pattern to the operating system to correct the current system time of the operating system;
[0121] The current system time of the operating system is transmitted to the naked running system by means of memory sharing, so that the naked running system and the operating system are synchronized.
[0122] Furthermore, the naked running system and the operating system realize clock synchronization by memory sharing at a preset time interval.
[0123] The clock synchronization device provided in the embodiments of the present disclosure can execute the clock synchronization method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0124] Embodiment 3
[0125] Fig. 9 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present disclosure described and / or claimed herein.
[0126] like Fig. 9 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0127] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0128] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microprocessor, etc. The processor 11 performs the various methods and processes described above, such as a clock synchronization method.
[0129] In some embodiments, the clock synchronization method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the clock synchronization method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the clock synchronization method in any other appropriate manner (e.g., by means of firmware).
[0130] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0131] The computer programs for implementing the methods of the embodiments of the present disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0132] In the context of the disclosed embodiments, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0133] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0134] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0135] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0136] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the embodiments of the present disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions of the embodiments of the present disclosure can be achieved, and this document does not limit this.
[0137] The above specific implementations do not constitute a limitation on the protection scope of the embodiments of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present disclosure shall be included in the protection scope of the embodiments of the present disclosure.
[0138] The embodiments of the present disclosure also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implements a clock synchronization method as provided in any embodiment of the present application.
[0139] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to write computer program codes for performing the operation of the disclosed embodiments, the programming languages including object-oriented programming languages, such as Java, Smalltalk, C++, and also including conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0140] Note that the above are only preferred embodiments of the embodiments of the present disclosure and the technical principles used. Those skilled in the art will understand that the embodiments of the present disclosure are not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the embodiments of the present disclosure. Therefore, although the embodiments of the present disclosure are described in more detail through the above embodiments, the embodiments of the present disclosure are not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the embodiments of the present disclosure, and the scope of the embodiments of the present disclosure is determined by the scope of the attached claims.
Claims
1. A clock synchronization method, It is characterized in that include: Acquire an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type; The external clock signal is used to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system.
2. The method according to claim 1, It is characterized in that The method of synchronizing the clocks of the naked running system and the operating system in the central processing unit CPU system by using the external clock signal includes: When the external clock signal is a master station clock signal and / or an SNTP clock signal, the clock of the operating system is adjusted using the time in the master station clock signal and / or the SNTP clock signal to obtain a precise clock of the operating system, wherein the time delay is the delay time for the master station clock signal and / or the SNTP clock signal to be transmitted to the operating system; After the operating system receives the second pulse signal sent by the field programmable gate array FPGA, an interrupt is triggered by using an interrupt processing function, and a difference between the current system time of the operating system and the second pulse signal is calculated, wherein the FPGA is used to provide the second pulse signal for the CPU system; Correcting the pulse-per-second signal of the field programmable gate array FPGA according to the difference to obtain a corrected pulse-per-second signal; The time of the setting unit of the treadmill system is corrected according to the corrected second pulse signal to synchronize the clocks of the treadmill system and the operating system, wherein the setting unit includes a time unit smaller than a second.
3. The method according to claim 1, It is characterized in that The method of synchronizing the clocks of the naked running system and the operating system in the central processing unit CPU system by using the external clock signal includes: When the external clock signal is a GPS clock signal, the current system time of the operating system is modified to the time of the GPS clock signal, and the current system time of the operating system is transmitted to the naked running system by means of memory sharing; Receiving the second pulse signal in the GPS clock signal through FPGA, and transmitting the second pulse signal to the naked running system and the operating system, so as to correct the time of the set unit in the current system time of the naked running system and the operating system; Wherein, the setting unit is a time unit less than a second; The FPGA is used to provide a pulse-per-second signal for the CPU system.
4. The method according to claim 1, It is characterized in that The method of synchronizing the clocks of the naked running system and the operating system in the central processing unit CPU system by using the external clock signal includes: Receiving a clock signal of a set code type through FPGA, and analyzing the clock signal of the set code type to obtain the time and second pulse signal of the clock signal of the set code type; Transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system, so that the operating system and the naked running system are synchronized; The pulse-per-second signal is transmitted to the treadmill system and the operating system simultaneously, so as to correct the time of the current system time setting unit of the treadmill system and the operating system; Wherein, the setting unit is a time unit less than a second; The FPGA is used to provide a pulse-per-second signal for the CPU system.
5. The method according to claim 4, It is characterized in that The step of transmitting the time of the clock signal of the set code pattern to the operating system or the naked running system so that the operating system and the naked running system are synchronized includes: Transmitting the time of the clock signal of the set code pattern to the naked running system to correct the current system time of the naked running system; The current system time of the naked running system is transmitted to the operating system by means of memory sharing, so that the operating system and the naked running system are synchronized; or, Transmitting the time of the clock signal of the set code pattern to the operating system to correct the current system time of the operating system; The current system time of the operating system is transmitted to the naked running system by means of memory sharing, so that the naked running system and the operating system are synchronized.
6. The method according to any one of claims 1 to 5, It is characterized in that The naked running system and the operating system achieve clock synchronization through memory sharing at preset time intervals.
7. A clock synchronization device, It is characterized in that include: A clock signal acquisition module, used to acquire an external clock signal, wherein the external clock signal includes a master station clock signal, a simple network time protocol SNTP clock signal, a global positioning system GPS clock signal and / or a clock signal of a set code type; The synchronization module is used to synchronize the clocks of the naked running system and the operating system in the central processing unit CPU system using the external clock signal.
8. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the clock synchronization method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the clock synchronization method as described in any one of claims 1 to 6 is implemented.
10. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the clock synchronization method according to any one of claims 1 to 6.
Citation Information
Cited By
Centralized power distribution terminal high-precision time synchronization system
CN119758697A
A high-precision time synchronization system for centralized power distribution terminals
CN119758697B
