A Time Protection Method, Device and Storage Medium Based on Time Calibration of a Time Synchronization Card
By monitoring the interrupt signal and calibration signal of the time card, the guardian time is created and the consistency of the time card is judged, the system time instability caused by the time card jump is solved, and the accurate calibration of the system time is achieved.
Patent Information
- Application Number
- CN202210506698.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-05-07
AI Technical Summary
When the time of the system card jumps, using its time to directly proofread the system time will lead to the problem of jumping the system system.
By creating a guardian time and monitoring the interrupt signal of the card and the calibration signal of the card, we can determine whether the card time is consistent. If it is consistent, the calibration will be allowed. Otherwise, the calibration will be rejected and the log will be recorded and the alarm will be reported to ensure the stability of the system time.
It effectively prevents system time jumps caused by time jumps in the system card, and ensures the accuracy and stability of system time.
Smart Images

Figure CN115129647B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to system time calibration technology, and in particular to a time protection method, device and storage medium based on time and frequency card calibration. Background Art
[0002] A time and frequency card is a plug-in product based on a computer bus (PCI Express), which can receive externally input time and frequency and interrupt signals, and provide high-precision synchronized time and frequency signals to devices such as computers and servers through the PCI-E bus. It uses a single-chip solution to implement a small on-chip dedicated system, with high integration and scalability.
[0003] For a device installed with a time and frequency card, a time and frequency calibration service needs to be installed. This service listens to the multicast information of the time server. When receiving the calibration signal sent by the time server through multicast, it creates a calibration thread to perform calibration. The calibration thread reads the time of the local time and frequency card through the time and frequency card driver API to calibrate the system time, and records the log. The log time is the time of the local time and frequency card obtained by calling the time and frequency card driver API. Once the time read by the time and frequency card is incorrect, it will lead to incorrect calibration time and log time. Summary of the Invention
[0004] In view of the above problems, the object of the present invention is to provide a time protection method based on time and frequency card calibration. By creating a guard time and updating the guard time by monitoring the interrupt signal, and then, judging whether the time of the time and frequency card has a jump or an abnormality according to whether the guard time is consistent with the time of the time and frequency card, and further determining whether to allow the system time to be calibrated with the time of the time and frequency card, so as to solve the problem that when the time of the time and frequency card has a jump or other problems, directly calibrating the system time with the time of the time and frequency card causes the system time of the device to jump.
[0005] To achieve the above object of the invention, the present invention provides the following technical solutions:
[0006] A time protection method based on time and frequency card calibration, comprising the following steps:
[0007] After the calibration service is started, continuously monitor the interrupt signal periodically output by the time and frequency card;
[0008] Wherein, when the first interrupt signal output by the time and frequency card is monitored, the current time of the time and frequency card is used as the initial value of the guard time; and after the first interrupt signal is monitored, each time the interrupt signal output by the time and frequency card is monitored, the period time of the interrupt signal output by the time and frequency card is added to the current guard time to update the guard time;
[0009] In addition, continuously monitor the time calibration signal sent by the time server through multicast. When the time calibration signal is received, determine whether the current time of the time synchronization card is consistent with the guard time. If they are consistent, allow the time calibration service to use the time of the time synchronization card to calibrate the system time. Otherwise, reject the time calibration service from using the time of the time synchronization card to calibrate the system time, and record a log and report an alarm.
[0010] According to a specific embodiment, in the time protection method based on time synchronization card calibration of the present invention, when continuously monitoring the interrupt signal periodically output by the time synchronization card, it is also determined whether the time difference between the times of the time synchronization card corresponding to two consecutive interrupt signals is equal to the cycle time. If it is not equal to the cycle time, record a log and report an alarm.
[0011] According to a specific embodiment, in the time protection method based on time synchronization card calibration of the present invention, by reading the register flag bit of the time synchronization card, it is determined whether there is an external clock source input to the time synchronization card. If there is no external clock source input, record a log and report an alarm.
[0012] On the other hand of the specific implementation of the present invention, there is also provided a time protection device based on time synchronization card calibration, which includes:
[0013] An interrupt signal monitoring module, configured to continuously monitor the interrupt signal periodically output by the time synchronization card after the time calibration service is started;
[0014] A guard time management module, configured to use the current time of the time synchronization card as the initial value of the guard time when the first interrupt signal output by the time synchronization card is detected; and after the first interrupt signal is detected, each time an interrupt signal output by the time synchronization card is detected, add a cycle time of the interrupt signal output by the time synchronization card to the current guard time to update the guard time;
[0015] A time calibration signal monitoring module, configured to continuously monitor the time calibration signal sent by the time server through multicast;
[0016] A time calibration management module, configured to determine whether the current time of the time synchronization card is consistent with the guard time after receiving the time calibration signal. If they are consistent, allow the time calibration service to use the time of the time synchronization card to calibrate the system time. Otherwise, reject the time calibration service from using the time of the time synchronization card to calibrate the system time;
[0017] An early warning module, configured to record a log and report an alarm when the current time of the time synchronization card is inconsistent with the guard time.
[0018] According to a specific embodiment, the time protection device based on time synchronization card time calibration of the present invention further includes a periodic time judgment module, configured to judge whether the time difference between the time synchronization cards corresponding to two consecutive interruption signals is equal to the periodic time; moreover, the warning module is configured to record a log and report a warning when the time difference between the time synchronization cards corresponding to two consecutive interruption signals is not equal to the periodic time.
[0019] According to a specific embodiment, the time protection device based on time synchronization card time calibration of the present invention further includes an external time source input monitoring module, configured to judge whether there is an external clock source input to the time synchronization card by reading the flag bit of the time synchronization card register when judging whether the time difference between the time synchronization cards corresponding to two consecutive interruption signals is equal to the periodic time; moreover, the warning module is configured to record a log and report a warning when there is no external clock source input to the time synchronization card.
[0020] On the other hand of the specific implementation of the present invention, there is also provided a computer-readable storage medium, on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the time protection method based on time synchronization card time calibration of the present invention is implemented.
[0021] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0022] The time protection method based on time synchronization card time calibration of the present invention creates a guard time, updates the guard time by monitoring interruption signals, and then judges whether the time of the time synchronization card has jumped or is abnormal according to whether the guard time is consistent with the time of the time synchronization card, and further determines whether to allow the system time to be calibrated with the time of the time synchronization card. Therefore, the present invention can solve the problem that when the time of the time synchronization card jumps or other problems occur, directly calibrating the system time with the time of the time synchronization card causes the device system time to jump. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic flow chart of the time synchronization card time calibration service;
[0024] Figure 2 It is a schematic flow chart of the guard time management;
[0025] Figure 3 It is a schematic flow chart of the time calibration management process;
[0026] Figure 4 It is a schematic diagram of the functional modules of the device of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. However, it should not be understood that the scope of the above-mentioned subject matter of the present invention is limited to the following embodiments, and all technologies implemented based on the content of the present invention belong to the scope of the present invention.
[0028] For the devices with unified cards during installation, there is a unified calibration service during installation. This service listens for the multicast information of the time server. When it receives the calibration signal sent by the time server through multicast, it creates a calibration thread to perform calibration. The calibration process is as follows Figure 1 shown. The time synchronization computer room device outputs a B code signal, which is sent to the time synchronization terminal and the time server. The time synchronization terminal accesses the B code and decodes and displays it according to the set mode and distributes it to the time synchronization card of the server. The network time service of the time server periodically sends calibration commands to each server through the network. After the calibration service on the server receives the calibration command, it determines whether the time of the time synchronization card has jumped. If it has jumped, an alarm is given and no calibration is performed. If it has not jumped, the time of the time synchronization card is obtained through the time synchronization card driver to calibrate the local time.
[0029] The time protection method based on time synchronization card calibration of the present invention includes the following steps:
[0030] After the calibration service is started, continuously monitor the interrupt signal periodically output by the time synchronization card;
[0031] Among them, when the first interrupt signal output by the time synchronization card is detected, the current time of the time synchronization card is used as the initial value of the guard time; and, after the first interrupt signal is detected, every time the interrupt signal output by the time synchronization card is detected, the current guard time is increased by a cycle time of the interrupt signal output by the time synchronization card to update the guard time;
[0032] And, continuously monitor the calibration signal sent by the time server through multicast; among them, when the calibration signal is received, determine whether the current time of the time synchronization card is consistent with the guard time. If they are consistent, allow the calibration service to use the time of the time synchronization card to calibrate the system time. Otherwise, reject the calibration service from using the time of the time synchronization card to calibrate the system time, and record the log and report the alarm.
[0033] Specifically, as Figure 2As shown in the figure, for Thread 1 used to manage the daemon time, taking the 1Hz interrupt signal output by the time synchronization card as an example, after Thread 1 detects the first 1Hz interrupt signal of the time synchronization card, it obtains the current time T0 of the time synchronization card as the initial value of the daemon time Currenttime, Currenttime = T0. After that, every time a 1Hz interrupt signal is received, the daemon time Currenttime is incremented by 1. During time calibration, the time of the time synchronization card is compared with the daemon time Currenttime to determine whether time calibration is required. In the specific code implementation, when Thread 1 obtains the first interrupt of the time synchronization card, it obtains the current time of the time synchronization card getAbsTime(&abstime), denoted as start_time, which is the initial value of the daemon time. A counter variable changSecondes is created. Every time a 1Hz interrupt signal is received, changSecondes is automatically incremented by 1. The daemon time described in the steps is the sum of the daemon time initial value start_time and the counter variable changSecondes. For the simplicity of program implementation, the daemon time variable is not directly set in the program, and start_time and changSecondes are directly used for comparison and calculation in the subsequent time comparison.
[0034] At the same time, in the time protection method based on time synchronization card calibration of the present invention, when continuously monitoring the interrupt signals periodically output by the time synchronization card, it also judges whether the time difference between the times corresponding to two consecutive interrupt signals of the time synchronization card is equal to the cycle time; if it is not equal to the cycle time, a log is recorded and an alarm is reported. Specifically, during implementation, in Thread 1, every time a 1Hz interrupt signal is received, the time of the time synchronization card getAbsTime(&abstime) is obtained once and assigned to time (absolute seconds), time = time2sec(abstim.year,abstim.month,abstim.day,abstim.hour,abstim.minute,abstim.second). The time of the time synchronization card obtained by the previous interrupt signal is assigned to lasttimesec, lasttimesec = time. In this way, it is judged whether the time difference between the two times is 1 second (the cycle time corresponding to the 1Hz interrupt signal is 1 second). If the difference between the two is not equal to 1, a log is recorded and an alarm is reported.
[0035] Specifically, such as Figure 3As shown in the figure, for thread 2 used for time calibration management, the time synchronization calibration service listens to the multicast information of the time server. When receiving the calibration signal sent by the time server through multicast, thread 2 is created for calibration. When thread 2 waits until the first 1Hz interrupt signal, it obtains the current time of the time synchronization card getAbsTime(&abstime), and takes the absolute second sec = time2sec(abstim.year, abstim.month, abstim.day, abstim.hour, abstim.minute, abstim.second). The difference between this time and the initial value of the daemon time start_time in the first step is calculated, and it is judged whether this difference is equal to the current counter variable value changSecondes, that is, the time is compared with the daemon time. If the difference between the current time of the time synchronization card and the initial value of the daemon time is equal to the counter variable value, that is, the daemon time is consistent with the current time of the time synchronization card, then the system time is calibrated with the time of the time synchronization card and the log is recorded. startsec = start_time, changesec = changSecondes, if(sec - startsec == changesec) ret = setRTtime. If they are inconsistent, no calibration is performed, only the log is recorded and an alarm is reported to prevent the system time from jumping when directly calibrating the system time after the time of the time synchronization card jumps.
[0036] In addition, during the execution of thread 1 for daemon time management and thread 2 for calibration management, the execution situation and possible abnormal situations are judged and recorded, and the abnormal situations are uploaded to the operation and maintenance platform through the interface provided by the operation and maintenance platform using the HTTP protocol.
[0037] In the time protection method based on time synchronization card calibration of the present invention, if there is no external time source input, the time of the time synchronization card will keep time for a period of time by itself, and then will slowly drift. Monitor whether there is an external time source input to the time synchronization card to ensure that there is always an external time source input to the time synchronization card. If there is no external input, an alarm is generated and manual intervention is timely. If not intervened in time, the time of the time synchronization card will drift after a period of time. Therefore, by judging whether the time difference between the time synchronization cards corresponding to two consecutive interrupt signals is equal to the cycle time, the purpose is to judge whether the time of the time synchronization card used by the calibration service to calibrate the system time has jumped, and monitor whether the time of the time synchronization card moves second by second. And the time of the time synchronization card may come from the external time source input of the time synchronization card. If there is no external time source input, it is the self-keeping time of the time synchronization card.
[0038] Therefore, when determining whether the time difference between two consecutive interruption signals corresponding to the time synchronization card is equal to the cycle time, by reading the flag bit of the time synchronization card register, it is judged whether there is an external clock source input to the time synchronization card; if there is no external clock source input, a log is recorded and an alarm is reported. During implementation, the monitoring content of thread 1 for daemon time management includes: whether the time difference of the time synchronization card obtained when two consecutive interruptions arrive is 1s, and by reading the flag bit of the time synchronization card register, it is judged whether there is an external clock source input to the time synchronization card. If the time difference of the time synchronization card is not 1 or there is no external clock source input to the time synchronization card, the log function is called to record the log and report it to the operation and maintenance platform.
[0039] During implementation, the monitoring content of thread 2 for time calibration management includes whether the time calibration is successful, whether the time synchronization interruption is normal, and whether the time calibration service calls the driver interface normally. If the time calibration is successful, only a log is recorded. If the time calibration stops, the time synchronization interruption is abnormal, or the time calibration service calls the driver interface fails, a log is recorded and reported to the operation and maintenance alarm system. When an alarm occurs, problems can be promptly troubleshot through the log manually, and corresponding measures can be taken to prevent problems such as long-term time calibration stop causing system time drift.
[0040] As Figure 4 shown, the present invention also provides a time protection device based on time synchronization card time calibration, which includes:
[0041] An interruption signal monitoring module, which is used to continuously monitor the interruption signals periodically output by the time synchronization card after the time calibration service is started;
[0042] A daemon time management module, which is used to take the current time of the time synchronization card as the initial value of the daemon time when the first interruption signal output by the time synchronization card is monitored; and, after the first interruption signal is monitored, every time an interruption signal output by the time synchronization card is monitored, a cycle time of the interruption signal output by the time synchronization card is added to the current daemon time to update the daemon time;
[0043] A time calibration signal monitoring module, which is used to continuously monitor the time calibration signals multicast by the time server;
[0044] A time calibration management module, which is used to judge whether the current time of the time synchronization card is consistent with the daemon time after receiving the time calibration signal. If they are consistent, the time calibration service is allowed to use the time of the time synchronization card to calibrate the system time; otherwise, the time calibration service is refused to use the time of the time synchronization card to calibrate the system time;
[0045] An early warning module, which is used to record a log and report an alarm when the current time of the time synchronization card is inconsistent with the daemon time.
[0046] Specifically, the time protection device based on time synchronization card time calibration of the present invention further includes a periodic time judgment module, which is used to judge whether the time difference between the time synchronization cards corresponding to two consecutive interruption signals is equal to the periodic time; moreover, the warning module is used to record a log and report a warning when the time difference between the time synchronization cards corresponding to two consecutive interruption signals is not equal to the periodic time.
[0047] Furthermore, the time protection device based on time synchronization card time calibration of the present invention further includes an external time source input monitoring module, which is used to judge whether there is an external clock source input to the time synchronization card by reading the flag bit of the time synchronization card register when judging whether the time difference between the time synchronization cards corresponding to two consecutive interruption signals is equal to the periodic time; moreover, the warning module is used to record a log and report a warning when there is no external clock source input to the time synchronization card.
[0048] On the other hand, in a specific implementation of the present invention, a computer-readable storage medium is further provided, on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the time protection method based on time synchronization card time calibration of the present invention is implemented.
[0049] It should be understood that the system disclosed by the present invention can be implemented in other ways. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the communication connection between the modules can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be in an electrical or other form.
[0050] In addition, in each embodiment of the present invention, each functional module can be integrated in a processing unit, or each module can exist physically alone, or two or more modules can be integrated in a processing unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0051] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs.
[0052] The foregoing is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A time protection method based on time synchronization card time correction, characterized in that, It includes the following steps: After the in-school service starts, continuously monitor the interrupt signal periodically output by the time synchronization card; Among them, when the first interrupt signal output by the time synchronization card is detected, take the current time of the time synchronization card as the initial value of the guard time; and, after the first interrupt signal is detected, every time the interrupt signal output by the time synchronization card is detected, add a cycle time of the interrupt signal output by the time synchronization card to the current guard time to update the guard time; And continuously monitor the time calibration signal multicast by the time server; among them, when the time calibration signal is received, judge whether the current time of the time synchronization card is consistent with the guard time. If they are consistent, allow the time calibration service to use the time of the time synchronization card to calibrate the system time. Otherwise, reject the time calibration service from using the time of the time synchronization card to calibrate the system time, and record the log and report an alarm.
2. The time protection method based on time synchronization card time calibration as described in claim 1, characterized in that When continuously monitoring the interrupt signal periodically output by the time synchronization card, also judge whether the time difference between the time of the time synchronization card corresponding to two consecutive interrupt signals is equal to the cycle time; if it is not equal to the cycle time, record the log and report an alarm.
3. A time protection method based on time synchronization card time calibration as claimed in claim 2, characterized in that When judging whether the time difference between the time of the time synchronization card corresponding to two consecutive interrupt signals is equal to the cycle time, judge whether there is an external clock source input to the time synchronization card by reading the flag bit of the time synchronization card register; if there is no external clock source input, record the log and report an alarm.
4. A time protection device based on time calibration by a time synchronization card, characterized in that, It includes: An interrupt signal monitoring module, which is used to continuously monitor the interrupt signal periodically output by the time synchronization card after the time calibration service starts; A guard time management module, which is used to take the current time of the time synchronization card as the initial value of the guard time when the first interrupt signal output by the time synchronization card is detected; and, after the first interrupt signal is detected, every time the interrupt signal output by the time synchronization card is detected, add a cycle time of the interrupt signal output by the time synchronization card to the current guard time to update the guard time; A time calibration signal monitoring module, which is used to continuously monitor the time calibration signal multicast by the time server; A time calibration management module, which is used to judge whether the current time of the time synchronization card is consistent with the guard time after receiving the time calibration signal. If they are consistent, allow the time calibration service to use the time of the time synchronization card to calibrate the system time. Otherwise, reject the time calibration service from using the time of the time synchronization card to calibrate the system time; An early warning module, which is used to record the log and report an alarm when the current time of the time synchronization card is inconsistent with the guard time.
5. The time protection device based on time synchronization card time calibration as claimed in claim 4, wherein, It also includes a cycle time judgment module, which is used to judge whether the time difference between the time of the time synchronization card corresponding to two consecutive interrupt signals is equal to the cycle time; moreover, the early warning module is used to record the log and report an alarm when the time difference between the time of the time synchronization card corresponding to two consecutive interrupt signals is not equal to the cycle time.
6. The time protection device based on time synchronization card time calibration according to claim 5, characterized in that, It also includes an external time source input monitoring module, which is used to judge whether there is an external clock source input to the time synchronization card by reading the flag bit of the time synchronization card register when judging whether the time difference between the time of the time synchronization card corresponding to two consecutive interrupt signals is equal to the cycle time; moreover, the early warning module is used to record the log and report an alarm when there is no external clock source input to the time synchronization card.
7. A computer-readable storage medium having one or more programs stored thereon, characterized in that, When the one or more programs are executed by one or more processors, the time protection method based on time synchronization card time calibration described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Time unification card virtualization method and system and medium
CN110377106A
Method and device for receiving timing signal
CN114201216A