Time synchronization method and device, equipment and storage medium

By simplifying the clock selection message format between RPU and APU and using static configuration compensation values, the problem of insufficient RPU processor capabilities is solved, and efficient and low-cost time synchronization is achieved, which is suitable for cross-domain time synchronization in complex scenarios.

CN120357991APending Publication Date: 2025-07-22IMOTION AUTOMOTIVE TECH (SUZHOU) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510668933.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

Time synchronization cannot be effectively implemented between RPU and APU because the RPU runs with low processor capabilities of MCU or CP operating system and does not support the GPTP2D protocol.

Method used

By removing the dynamic calculation fields in the clock selection message of the real-time processing unit, the clock selection message is selected using a fixed-length and binary format, and the static configuration compensation value of the application processing unit is used to simplify the clock selection message, determine the main clock and perform time synchronization.

Benefits of technology

It realizes efficient time synchronization between RPU and APU, reduces time synchronization costs, is suitable for low-power scenarios, adapts to RPU resource limitations, and improves the reliability and accuracy of cross-domain time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120357991A_ABST
    Figure CN120357991A_ABST
Patent Text Reader

Abstract

The invention discloses a time synchronization method, device and equipment and a storage medium, relates to the technical field of time synchronization, is applied to a first target system configured with an application processing unit and a first clock source, and comprises the following steps: acquiring a clock selection message sent by a second target system by using a preset clock information sending program; a real-time processing unit and a second clock source are configured in the second target system, and the clock selection message is generated by the second target system based on clock information of the second clock source; determining master clocks of the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message; and performing time synchronization between the main clock and the second target system by using the main clock and based on a locally preset time synchronization compensation value. By removing the dynamic field in the clock selection message of the real-time processing unit, the clock selection message is simplified, so that cross-domain time synchronization can be realized between the real-time processing unit and the application processing unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of time synchronization, and particularly relates to a time synchronization method, device, equipment and storage medium. Background Art

[0002] In two Linux systems, GPTP2D (Generalized Precision Time Protocol for Multi-Domain, an extended version of the generalized precision time protocol for multiple domains) can run well to achieve cross-domain time synchronization. However, in the actual production environment, cross-domain time synchronization mostly occurs between an APU (Application Processing Unit) and an RPU (Real-time Processing Unit). Most APUs run the Linux operating system, and most RPUs run an MCU (Microcontroller Unit) or a CP (Control Program) operating system. Their systems are all restricted operating systems with low processor capabilities and few cores. The compiler and the adapted third-party libraries do not support the operation of GPTP2D. Therefore, the GPTP2D program cannot run on the RPU, so the open-source GPTP2D program is usually not used between the RPU and the APU. Therefore, how to use GPTP2D between the RPU and the APU to achieve time synchronization between the APU and the RPU has become a problem to be solved in this field. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a time synchronization method, device, equipment and storage medium. By removing the dynamic calculation field in the clock selection message of the real-time processing unit, the clock selection message is simplified, so that time synchronization can be quickly performed between the real-time processing unit and the application processing unit. The specific scheme is as follows:

[0004] In a first aspect, the present application provides a time synchronization method, which is applied to a first target system configured with an application processing unit and a corresponding first clock source, and includes:

[0005] Obtain a clock selection message sent by a second target system using a preset clock information sending program; the second target system is configured with a real-time processing unit and a corresponding second clock source, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message is composed of a clock priority, a clock level, a clock source type, and a clock offset. The clock selection message is a message generated based on a fixed message length and message format, and the message format is a binary format;

[0006] Determine a master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message;

[0007] The master clock is used to perform time synchronization between the system and the second target system based on a locally preset time synchronization offset value.

[0008] Optionally, the clock source type in the clock selection message is a virtual clock source predetermined by the second target system;

[0009] Accordingly, determining the master clock between the first target system and the second target system includes:

[0010] Determine a first clock priority corresponding to the first clock source and a second clock priority corresponding to the virtual clock source; the first clock source is a physical clock source;

[0011] The master clock between the first target system and the second target system is determined according to the first clock priority and the second clock priority; the first clock priority is higher than the second clock priority.

[0012] Optionally, the step of obtaining a clock selection message sent by the second target system using a preset clock information sending program includes:

[0013] Using the local target port, receive the clock selection message sent by the second target system using the preset clock information sending program through unicast; the target port is only used to receive the clock selection message constructed based on the clock information of the second clock source corresponding to the real-time processing unit.

[0014] Optionally, before obtaining the clock selection message sent by the second target system using the preset clock information sending program, the method further includes:

[0015] Detecting a target task currently being processed by the application processing unit, and determining whether a task type of the target task satisfies a preset time synchronization condition;

[0016] Using the application processing unit, recording a clock offset between the first target system and the second target system, and determining whether the clock offset is greater than a preset clock offset threshold;

[0017] If the task type meets the preset time synchronization condition, or the clock offset is greater than the preset clock offset threshold, the time synchronization task between the first target system and the second target system is triggered to obtain the clock selection message based on the time synchronization task.

[0018] Optionally, the time synchronization method further includes:

[0019] If the task type of the target task does not meet the preset time synchronization condition and the clock offset is not greater than the preset clock offset threshold, the application processing unit is used to send a preset time synchronization message to the real-time processing unit in the second target system based on a preset time synchronization period, so that the real-time processing unit can perform its own time synchronization according to the preset time synchronization message.

[0020] In a second aspect, the present application provides a time synchronization method, which is applied to a second target system configured with a real-time processing unit and a corresponding second clock source, and includes:

[0021] Determine the clock information corresponding to the second clock source locally, and generate a clock selection message based on the clock information of the second clock source;

[0022] Use a preset clock information sending program to send the clock selection message to the first target system, so that the first target system can determine the master clock between the first target system and the second target system based on the clock information of the first clock source locally and the clock information of the second clock source in the clock selection message, and use the master clock and based on a locally preset time synchronization compensation value, perform time synchronization between itself and the second target system;

[0023] Wherein, the first target system is configured with an application processing unit and a corresponding first clock source.

[0024] In a third aspect, the present application provides a time synchronization device, which is applied to a first target system configured with an application processing unit and a corresponding first clock source, and includes:

[0025] A message acquisition module, configured to acquire a clock selection message sent by a second target system using a preset clock information sending program; the second target system is configured with a real-time processing unit and a corresponding second clock source, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message consists of a clock priority, a clock level, a clock source type, and a clock offset, the clock selection message is a message generated based on a fixed message length and message format, and the message format is a binary format;

[0026] A master clock determination module, configured to determine the master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message;

[0027] A time synchronization module, configured to perform time synchronization between itself and the second target system by using the master clock and based on a locally preset time synchronization compensation value.

[0028] In a fourth aspect, the present application provides a time synchronization device, which is applied to a second target system configured with a real-time processing unit and a corresponding second clock source, and includes:

[0029] A message generation module, configured to determine clock information corresponding to the local second clock source, and generate a clock selection message based on the clock information of the second clock source;

[0030] A message sending module, configured to send the clock selection message to a first target system by using a preset clock information sending program, so that the first target system determines a master clock between the first target system and the second target system based on the clock information of the local first clock source and the clock information of the second clock source in the clock selection message, and perform time synchronization between itself and the second target system by using the master clock and based on a locally preset time synchronization compensation value;

[0031] wherein, the first target system is configured with an application processing unit and the corresponding first clock source.

[0032] In a fifth aspect, the present application provides an electronic device, which includes a processor and a memory; wherein, the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the foregoing time synchronization method.

[0033] In a sixth aspect, the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program implements the foregoing time synchronization method when being executed by a processor.

[0034] This application is applied to a first target system configured with an application processing unit and a corresponding first clock source. First, a clock selection message sent by a second target system using a preset clock information sending program is obtained. The second target system is configured with a real-time processing unit and a corresponding second clock source. The clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message consists of a clock priority, a clock level, a clock source type, and a clock offset. The clock selection message is a message generated based on a fixed message length and a binary format. Then, based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message, the master clock between the first target system and the second target system is determined, and time synchronization is performed between itself and the second target system using the master clock and based on a locally preset time synchronization compensation value. By removing the dynamic calculation fields in the clock selection message generated by the real-time processing unit and performing static configuration compensation using the compensation value preconfigured locally by the application processing unit, this application simplifies the clock selection message of the real-time processing unit, enabling cross-domain time synchronization between the real-time processing unit and the application processing unit using an open-source program of the multi-domain extended version of the generalized precise time protocol, greatly reducing the time synchronization cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings according to the provided drawings without creative efforts.

[0036] Figure 1 It is a flowchart of a time synchronization method provided by this application;

[0037] Figure 2 It is a schematic structural diagram of a time synchronization system provided by this application;

[0038] Figure 3 It is a schematic diagram of a simplified message provided by this application;

[0039] Figure 4 It is a flowchart of a time synchronization method provided by this application;

[0040] Figure 5 It is a schematic structural diagram of a time synchronization device provided by this application;

[0041] Figure 6 It is a schematic structural diagram of a time synchronization device provided by this application;

[0042] Figure 7 It is a structural diagram of an electronic device provided by this application. Detailed implementation manners

[0043] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0044] In two Linux systems, cross-domain time synchronization can be achieved through GPTP2D. However, in an actual production environment, cross-domain time synchronization mostly occurs between an APU and an RPU. Most of the APUs run the Linux operating system, and most of the RPUs run the MCU or CP operating system. Their system processor capabilities are relatively low and do not support the operation of GPTP2D. However, this application can remove the dynamic calculation fields (such as path delay compensation) in the clock selection message of the RPU, simplify the clock selection message, and enable the use of the open-source program of GPTP2D for time synchronization between the APU and the RPU.

[0045] See Figure 1 As shown, an embodiment of the present invention discloses a time synchronization method, which is applied to a first target system configured with an application processing unit and a corresponding first clock source, and includes:

[0046] Step S11: Obtain a clock selection message sent by a second target system using a preset clock information sending program; a real-time processing unit and a corresponding second clock source are configured in the second target system, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message is composed of a clock priority, a clock level, a clock source type, and a clock offset. The clock selection message is a message generated based on a fixed message length and message format, and the message format is a binary format.

[0047] In this embodiment, it should be pointed out first that GPTP2D realizes cross-domain time synchronization by improving the master-slave clock architecture, path delay compensation algorithm, and inter-domain coordination mechanism, solves the problems of heterogeneous network structures, different clock sources (GPS (Global Positioning System), atomic clocks, crystal oscillators, etc.), and dynamic topology changes in different domains, and solves problems such as inter-domain delay asymmetry and clock drift accumulation. If two different domains need to perform time synchronization based on GPTP2D, the following steps are required:

[0048] 1. Initialization stage:

[0049] Each domain elects a DMC (Domain Main Clock) through the BMC (Best Master Clock) algorithm and establishes an initial synchronization with the GMC (Grand Master Clock); the boundary clock completes the cross-domain link delay baseline measurement.

[0050] 2. Periodic synchronization phase:

[0051] The DMC broadcasts Sync / Follow_Up messages to the devices within the domain to complete the in-domain synchronization; the boundary clock forwards the cross-domain Sync messages and attaches the inter-domain delay compensation value (ΔD).

[0052] 3. Dynamic calibration phase:

[0053] According to the changes in the network state (such as topology update, link congestion), trigger on-demand probing and delay recalculation; if the master clock failure is detected, start the redundancy switching process.

[0054] Moreover, if the initialization phase cannot be carried out and the best clock cannot be elected, GPTP2D cannot work. BMCA (Best Master Clock Algorithm) is the master clock selection mechanism of gPTP (generalized Precision Time Protocol). At the beginning of system startup, all devices can participate in the "election" of the Grandmaster by sending Announce messages. The Announce message contains the clock information of the candidate device (equivalent to the election manifesto). Once a candidate device finds that its clock does not have an advantage, it will actively withdraw from the master clock election. Through the BMCA mechanism, the elected Grandmaster has a more accurate local clock and can be synchronized with the universal time (such as GPS synchronization). Therefore, the core problem in this embodiment is how to make the RPU send an Announce message and carry the clock information to elect the best clock.

[0055] This embodiment can first obtain the clock selection message (Announce message) sent by the second target system using the preset clock information sending program. It should be noted that the first target system in this embodiment, that is Figure 2 the system configured with the application processing unit and the corresponding first clock source as shown. Correspondingly, the second target system is the system configured with the real-time processing unit and the corresponding second clock source, and the clock selection message in this embodiment specifically refers to the message generated by the second target system based on the clock information of the second clock source corresponding to the real-time processing unit (RPU).

[0056] In this embodiment, when obtaining the clock selection message sent by the second target system using the preset clock information sending program, the target port of the local device can be used to receive the clock selection message unicast by the second target system using the preset clock information sending program. It should be noted that the above target port is only used to receive the clock selection message constructed based on the clock information of the second clock source corresponding to the real-time processing unit. That is to say, in the first target system of this embodiment, an interface dedicated to receiving the message generated by the second clock source corresponding to the real-time processing unit (RPU) is configured, and the unicast mode is used. The GPTPRD (GPTPRPU Domain) directly sends the message to the specified port of the APU, avoiding the complexity of the multicast protocol and improving the success rate of message sending. In this embodiment, a simple clock information sending program GPTPRD is pre-implemented in the RPU of the second target system. Its function is to obtain the configuration information of the system by reading the configuration, and form these information into a virtual clock information and send it out through this program, so that the GPTP2D in the APU of the first target system can receive the virtual clock information, and select a suitable clock source as the master clock for synchronization through BMCA. At the same time, the above virtual clock information will be encapsulated into a data packet with a fixed length and transmitted lightly based on UDP (User Datagram Protocol), avoiding fragmentation and recombination of data packets.

[0057] It should also be noted that the RPU (MCU / CP (Microcontroller Unit, Central Processing Unit) system) has limited resources and cannot generate complex messages of standard GPTP2D (such as complete clock quality fields, redundancy checks, etc.). There may be no complete IP protocol stack. Therefore, in this embodiment, it is necessary to streamline the above problems of the Announce message. That is to say, the clock selection message in this embodiment is a message generated based on a fixed message length and message format; among them, the message format is a binary format, and the clock selection message is composed of clock priority, clock class, clock source type, and clock offset. Specifically, the Announce message in this embodiment only retains the core fields: including Priority, ClockClass, TimeSource, and UTC-Offset. It can be understood that the above core fields can also be adjusted accordingly according to the actual situation. In this way, the Announce message in this embodiment removes the dynamically calculated fields (such as path delay compensation), and the APU side compensates the value through static configuration, and uses a fixed-length binary format (for example: 16 bytes), avoiding parsing overheads such as JSON / XML (JavaScript Object Notation / Extensible Markup Language). In this way, through the lightweight Announce message design, specifically through field trimming and fixed format, low-overhead communication of MCU-level devices is achieved. A specific message example is Figure 3 shown, consisting of field name, length (bytes), and description.

[0058] It should also be noted that in the second target system of this embodiment, the clock source type in the clock selection message can be pre-determined as a virtual clock source. That is to say, in this embodiment, by extending the BMCA algorithm, a "virtual clock source" category is added to the GPTP2D of the APU, and its default priority is reduced (for example: the priority value is set to 255), which can ensure that the physical clock source is preferentially elected, so that the clock sent from the RPU is a slave clock, avoiding the subsequent time synchronization problem that the standard GPTP2D cannot recognize the simplified message of the RPU.

[0059] Step S12, based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message, determine the master clock between the first target system and the second target system.

[0060] In this embodiment, the first target system can determine the master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source obtained from the acquired clock selection message. Specifically, the first clock priority corresponding to the first clock source and the second clock priority corresponding to the virtual clock source can be determined first, and then the master clock between the first target system and the second target system can be determined according to the first clock priority and the second clock priority. The above first clock source is a physical clock source, and the first clock priority is higher than the second clock priority.

[0061] Step S13: Use the master clock and based on the locally preset time synchronization compensation value, perform time synchronization between itself and the second target system.

[0062] In this embodiment, as shown in the above steps, the Announce message in this embodiment removes the dynamically calculated fields (such as path delay compensation), and the APU side configures the compensation value statically. Therefore, the first target system can use the master clock and based on the locally preset time synchronization compensation value, perform time synchronization between itself and the second target system.

[0063] Specifically, in order to further solve the problem of insufficient RPU resources, this embodiment further sets up an on-demand synchronization mechanism based on event triggering. That is, before obtaining the clock selection message sent by the second target system using the preset clock information sending program, it is also possible to detect the target task currently processed by the application processing unit and determine whether the task type of the target task meets the preset time synchronization condition; and use the application processing unit to record the clock offset between the first target system and the second target system, and determine whether the clock offset is greater than the preset clock offset threshold. If the task type of the above target task meets the preset time synchronization condition, or the clock offset is greater than the preset clock offset threshold, then trigger the time synchronization task between the first target system and the second target system, so as to obtain the clock selection message for time synchronization based on the time synchronization task.

[0064] Moreover, if the task type of the target task does not meet the preset time synchronization condition and the clock offset is not greater than the preset clock offset threshold, then use the application processing unit and based on the preset time synchronization period, send a preset time synchronization message to the real-time processing unit in the second target system, so that the real-time processing unit can perform its own time synchronization according to the preset time synchronization message.

[0065] That is to say, in this embodiment, a time synchronization period can be preset. When there are no critical tasks, a low-frequency synchronization period is adopted. The RPU receives the synchronized time message information from the APU, and an event-driven mode is introduced in the APU. The synchronized message is sent only when a critical task (such as sensor data acquisition) is detected, rather than being broadcast periodically. And in another specific embodiment, the synchronization process can also be started by configuring a threshold (such as the clock offset exceeding ±1 ms). Specifically, the amplitude of the time jump can be recorded in the APU. When the amplitude of the time jump is greater than 1 ms, the synchronization process is actively started without waiting for periodic synchronization. In this way, through the event-triggered on-demand synchronization mechanism, the communication frequency of the RPU is greatly reduced, the resource occupancy is reduced, and GPTP2D is applicable to ultra-low power consumption scenarios.

[0066] Through the above technical solution, in this embodiment, first, a clock selection message sent by the second target system using a preset clock information sending program can be obtained; a real-time processing unit and a corresponding second clock source are configured in the second target system, and the clock selection message is a message generated by the second target system based on the clock information of the second clock source; then, based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message, the master clock between the first target system and the second target system is determined, and time synchronization is performed between itself and the second target system using the master clock and based on the locally preset time synchronization compensation value. In this way, in order to adapt to a low-power processor such as the RPU, a variety of methods are adopted to reduce the power consumption of the central processing unit. The dynamic calculation field in the clock selection message generated by the real-time processing unit can be removed, and the compensation value is statically configured by the compensation value pre-configured locally by the application processing unit, simplifying the clock selection message of the real-time processing unit, enabling the APU and the RPU to also use the open-source program of GPTP2D, greatly reducing the time synchronization cost, and enjoying the realization of high-precision, high-reliability, and low-overhead cross-domain global time synchronization in complex scenarios through multi-domain collaboration, dynamic delay compensation, and security enhancement.

[0067] See Figure 4 As shown, an embodiment of the present application also discloses a time synchronization method, which is applied to a second target system configured with a real-time processing unit and a corresponding second clock source, and includes:

[0068] Step S21, determine the clock information corresponding to the local second clock source, and generate a clock selection message based on the clock information of the second clock source.

[0069] Step S22: Use a preset clock information sending program to send the clock selection message to the first target system, so that the first target system determines the master clock between the first target system and the second target system based on the clock information of the first clock source locally and the clock information of the second clock source in the clock selection message, and performs time synchronization between itself and the second target system by using the master clock and based on the locally preset time synchronization compensation value; wherein, an application processing unit and the corresponding first clock source are configured in the first target system.

[0070] It can be understood that the above method has the same beneficial effects as the time synchronization method applied to the first target system. For details, please refer to the above embodiments and will not be elaborated here.

[0071] See Figure 5 As shown, an embodiment of the present application discloses a time synchronization device, which is applied to a first target system configured with an application processing unit and a corresponding first clock source, and includes:

[0072] A message acquisition module 11, configured to acquire a clock selection message sent by a second target system by using a preset clock information sending program; a real-time processing unit and a corresponding second clock source are configured in the second target system, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message is composed of a clock priority, a clock level, a clock source type, and a clock offset, the clock selection message is a message generated based on a fixed message length and a message format, and the message format is a binary format;

[0073] A master clock determination module 12, configured to determine the master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message;

[0074] A time synchronization module 13, configured to perform time synchronization between itself and the second target system by using the master clock and based on a locally preset time synchronization compensation value.

[0075] This embodiment first obtains the clock selection message sent by the second target system using the preset clock information sending program; the above-mentioned second target system is configured with a real-time processing unit and a corresponding second clock source, and the clock selection message is a message generated by the second target system based on the clock information of the second clock source; then based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message, the master clock between the first target system and the second target system is determined, and the master clock and the time synchronization compensation value preset locally are used to synchronize time between itself and the second target system. Through the above technical solution, this embodiment can remove the dynamically calculated field in the clock selection message generated by the real-time processing unit, and statically configure the compensation value by the compensation value pre-configured locally by the application processing unit, thereby simplifying the clock selection message of the real-time processing unit, so that the real-time processing unit and the application processing unit can also use the open source program of the multi-domain extended version of the generalized precise time protocol for time synchronization, which greatly reduces the time synchronization cost.

[0076] In some specific embodiments, the clock source type in the clock selection message is a virtual clock source predetermined by the second target system;

[0077] Accordingly, the master clock determination module 12 specifically includes:

[0078] a priority determination unit, configured to determine a first clock priority corresponding to the first clock source and a second clock priority corresponding to the virtual clock source; the first clock source being a physical clock source;

[0079] A master clock determination unit is used to determine the master clock between the first target system and the second target system according to the first clock priority and the second clock priority; the first clock priority is higher than the second clock priority.

[0080] In some specific embodiments, the message acquisition module 11 specifically includes:

[0081] A message receiving unit is used to use a local target port to receive the clock selection message sent by the second target system using the preset clock information sending program through unicast; the target port is only used to receive the clock selection message constructed based on the clock information of the second clock source corresponding to the real-time processing unit.

[0082] In some specific embodiments, the time synchronization device further includes:

[0083] A task monitoring module, used to detect the target task currently processed by the application processing unit, and determine whether the task type of the target task meets the preset time synchronization condition;

[0084] An offset recording module, configured to use the application processing unit to record the clock offset between the first target system and the second target system, and determine whether the clock offset is greater than a preset clock offset threshold;

[0085] A task triggering module, configured to trigger a time synchronization task between the first target system and the second target system if the task type meets the preset time synchronization condition or the clock offset is greater than the preset clock offset threshold, so as to obtain the clock selection message based on the time synchronization task.

[0086] In some specific embodiments, the time synchronization device further includes:

[0087] A signal sending module, configured to use the application processing unit and based on a preset time synchronization period, send a preset time synchronization message to the real-time processing unit in the second target system if the task type of the target task does not meet the preset time synchronization condition and the clock offset is not greater than the preset clock offset threshold, so that the real-time processing unit performs its own time synchronization according to the preset time synchronization message.

[0088] See Figure 6 As shown, an embodiment of the present application further discloses a time synchronization device, which is applied to a second target system configured with a real-time processing unit and a corresponding second clock source, and includes:

[0089] A message generation module 21, configured to determine the clock information corresponding to the local second clock source, and generate a clock selection message based on the clock information of the second clock source;

[0090] A message sending module 22, configured to use a preset clock information sending program to send the clock selection message to the first target system, so that the first target system determines the master clock between the first target system and the second target system based on the clock information of the local first clock source and the clock information of the second clock source in the clock selection message, and perform time synchronization between itself and the second target system by using the master clock and based on a locally preset time synchronization compensation value; wherein, the first target system is configured with an application processing unit and a corresponding first clock source.

[0091] It can be understood that the above device has the same beneficial effects as the time synchronization device applied to the first target system. For specific details, please refer to the above embodiments and will not be elaborated here.

[0092] Furthermore, an embodiment of the present application further discloses an electronic device, Figure 7It is a structural diagram of an electronic device 20 shown according to an exemplary embodiment. The content in the figure should not be regarded as any limitation on the scope of use of this application.

[0093] Figure 7 This is a schematic structural diagram of an electronic device 30 provided by an embodiment of this application. The electronic device 30 may specifically include: at least one processor 31, at least one memory 32, a power supply 33, a communication interface 34, an input / output interface 35, and a communication bus 36. Among them, the memory 32 is used to store a computer program, and the computer program is loaded and executed by the processor 31 to implement the relevant steps in the time synchronization method disclosed in any of the foregoing embodiments. In addition, the electronic device 30 in this embodiment may specifically be an electronic computer.

[0094] In this embodiment, the power supply 33 is used to provide working voltage for each hardware device on the electronic device 30; the communication interface 34 can create a data transmission channel between the electronic device 30 and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of this application, and no specific limitation is imposed on it here; the input / output interface 35 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.

[0095] In addition, as a carrier for resource storage, the memory 32 may be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon may include an operating system 321, a computer program 322, etc., and the storage method may be temporary storage or permanent storage.

[0096] Among them, the operating system 321 is used to manage and control each hardware device and the computer program 322 on the electronic device 30, and it may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the time synchronization method executed by the electronic device 30 disclosed in any of the foregoing embodiments, the computer program 322 may further include computer programs that can be used to complete other specific tasks.

[0097] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the time synchronization method disclosed above. For the specific steps of this method, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not repeated here.

[0098] In this specification, the various embodiments are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the similarities or identical parts among the embodiments, reference can be made to each other. For the apparatuses disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple. For the relevant parts, reference can be made to the descriptions in the method section.

[0099] Those skilled in the art can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered as exceeding the scope of this application.

[0100] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be directly implemented by hardware, software modules executed by a processor, or a combination of both. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.

[0101] Finally, it should also be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0102] The technical solutions provided in this application have been introduced in detail above. Specific examples are used herein to elaborate on the principles and implementation manners of this application. The descriptions of the above embodiments are only used to help understand the method and its core idea of this application. At the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.

Claims

1. A time synchronization method, characterized in that, The method is applied to a first target system configured with an application processing unit and a corresponding first clock source, comprising: Acquire a clock selection message sent by the second target system using a preset clock information sending program; the second target system is configured with a real-time processing unit and a corresponding second clock source, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message is composed of a clock priority, a clock level, a clock source type, and a clock offset, and the clock selection message is a message generated based on a fixed message length and message format, and the message format is a binary format; Determine a master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message; The master clock is used to perform time synchronization between the system and the second target system based on a locally preset time synchronization offset value.

2. The time synchronization method according to claim 1, characterized in that, The clock source type in the clock selection message is a virtual clock source predetermined by the second target system; Accordingly, determining the master clock between the first target system and the second target system includes: Determine a first clock priority corresponding to the first clock source and a second clock priority corresponding to the virtual clock source; the first clock source is a physical clock source; The master clock between the first target system and the second target system is determined according to the first clock priority and the second clock priority; the first clock priority is higher than the second clock priority.

3. The time synchronization method according to claim 1, wherein The obtaining of the clock selection message sent by the second target system using a preset clock information sending program includes: Using the local target port, receive the clock selection message sent by the second target system using the preset clock information sending program through unicast; the target port is only used to receive the clock selection message constructed based on the clock information of the second clock source corresponding to the real-time processing unit.

4. The time synchronization method according to any one of claims 1 to 3, characterized in that, Before obtaining the clock selection message sent by the second target system using the preset clock information sending program, the method further includes: Detecting a target task currently being processed by the application processing unit, and determining whether a task type of the target task satisfies a preset time synchronization condition; Using the application processing unit, recording a clock offset between the first target system and the second target system, and determining whether the clock offset is greater than a preset clock offset threshold; If the task type meets the preset time synchronization condition, or the clock offset is greater than the preset clock offset threshold, the time synchronization task between the first target system and the second target system is triggered to obtain the clock selection message based on the time synchronization task.

5. The time synchronization method according to claim 4, wherein Also includes: If the task type of the target task does not meet the preset time synchronization condition and the clock offset is not greater than the preset clock offset threshold, the application processing unit is used to send a preset time synchronization message to the real-time processing unit in the second target system based on the preset time synchronization period, so that the real-time processing unit performs its own time synchronization according to the preset time synchronization message.

6. A time synchronization method, characterized in that, Applied to a second target system configured with a real-time processing unit and a corresponding second clock source, including: Determine the clock information corresponding to the local second clock source, and generate a clock selection message based on the clock information of the second clock source; Use the preset clock information sending program to send the clock selection message to the first target system, so that the first target system determines the master clock between the first target system and the second target system based on the clock information of the local first clock source and the clock information of the second clock source in the clock selection message, and uses the master clock and based on the locally preset time synchronization compensation value, perform time synchronization between itself and the second target system; Wherein, the first target system is configured with an application processing unit and the corresponding first clock source.

7. A time synchronization device, characterized in that, Applied to a first target system configured with an application processing unit and a corresponding first clock source, including: A message acquisition module, configured to acquire a clock selection message sent by a second target system using a preset clock information sending program; the second target system is configured with a real-time processing unit and a corresponding second clock source, the clock selection message is a message generated by the second target system based on the clock information of the second clock source, and the clock selection message consists of a clock priority, a clock level, a clock source type, and a clock offset, the clock selection message is a message generated based on a fixed message length and message format, and the message format is a binary format; A master clock determination module, configured to determine the master clock between the first target system and the second target system based on the clock information of the first clock source and the clock information of the second clock source in the clock selection message; A time synchronization module, configured to use the master clock and based on the locally preset time synchronization compensation value, perform time synchronization between itself and the second target system.

8. A time synchronization device, characterized in that, Applied to a second target system configured with a real-time processing unit and a corresponding second clock source, including: A message generation module, configured to determine the clock information corresponding to the local second clock source, and generate a clock selection message based on the clock information of the second clock source; A message sending module, configured to use the preset clock information sending program to send the clock selection message to the first target system, so that the first target system determines the master clock between the first target system and the second target system based on the clock information of the local first clock source and the clock information of the second clock source in the clock selection message, and uses the master clock and based on the locally preset time synchronization compensation value, perform time synchronization between itself and the second target system; Among them, an application processing unit and the corresponding first clock source are configured in the first target system.

9. An electronic device, characterized in that, The electronic device includes a processor and a memory; among them, the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the time synchronization method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, For saving a computer program, the computer program implements the time synchronization method according to any one of claims 1 to 6 when being executed by a processor.

Citation Information

Cited By

  • Compensation method and platform for adaptive reference clock of solid state disk

    CN120973610A