CN114003091B - Time synchronization method, device, equipment and storage medium - Google Patents

Time synchronization method, device, equipment and storage medium Download PDF

Info

Publication number
CN114003091B
CN114003091B CN202111277392.2A CN202111277392A CN114003091B CN 114003091 B CN114003091 B CN 114003091B CN 202111277392 A CN202111277392 A CN 202111277392A CN 114003091 B CN114003091 B CN 114003091B
Authority
CN
China
Prior art keywords
time
virtual
clock
hardware
virtual machine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111277392.2A
Other languages
Chinese (zh)
Other versions
CN114003091A (en
Inventor
刘建德
梁宏建
贾承晖
曾庆祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Consys Technology Co ltd
Original Assignee
Shenzhen Consys Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Consys Technology Co ltd filed Critical Shenzhen Consys Technology Co ltd
Priority to CN202111277392.2A priority Critical patent/CN114003091B/en
Publication of CN114003091A publication Critical patent/CN114003091A/en
Application granted granted Critical
Publication of CN114003091B publication Critical patent/CN114003091B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/12Synchronisation of different clock signals provided by a plurality of clock generators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Electric Clocks (AREA)

Abstract

The invention discloses a time synchronization method, a time synchronization device, time synchronization equipment and a storage medium, and belongs to the field of time synchronization. The time synchronization method can acquire the clock change instruction and the memory call instruction; generating virtual hardware according to the memory call instruction; generating a time modification value according to the clock modification instruction; inputting the time change value into the virtual hardware to control the physical machine to acquire the time change value; acquiring a synchronous instruction fed back by a physical machine according to the time change value; according to the method, the time modification value is input to the time hardware equipment according to the synchronization instruction, so that the rapid time synchronization between the physical machine and the virtual machine without network support is realized, and the precision of the time synchronization can be improved while the cost is reduced.

Description

Time synchronization method, device, equipment and storage medium
Technical Field
The present invention relates to the field of time synchronization, and in particular, to a method, an apparatus, a device, and a storage medium for time synchronization.
Background
In the related art, time synchronization is often performed by acquiring time through networking of a network protocol, or by adopting customized hardware, the former has lower precision and needs network support, and the latter has harsh use environment and high cost. Therefore, how to provide a simple and highly accurate time synchronization method is a problem to be solved.
Disclosure of Invention
The present invention aims to solve at least one of the technical problems existing in the prior art. Therefore, the invention provides a time synchronization method which can reduce the cost and improve the precision of time synchronization.
The invention also provides a time synchronization device with the time synchronization method.
The invention also provides time synchronization equipment with the time synchronization method.
The invention also proposes a computer readable storage medium.
According to an embodiment of the first aspect of the present invention, a time synchronization method includes:
acquiring a clock change instruction and a memory call instruction;
generating virtual hardware according to the memory call instruction;
generating a time modification value according to the clock modification instruction;
inputting the time modification value into the virtual hardware to control a physical machine to acquire the time modification value;
acquiring a synchronous instruction fed back by the physical machine according to the time change value;
and inputting the time modification value to a time hardware device according to the synchronous instruction.
The time synchronization method according to the embodiment of the invention has at least the following beneficial effects: by the method, the virtual machine system can acquire time change operation performed by a user in virtual machine software, namely, a clock change instruction and a memory call instruction, and virtual hardware is generated according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, thereby effectively realizing the time synchronization between the physical machine and the virtual machine, effectively avoiding the problem of low time synchronization precision caused by the time delay generated by the network transmission mode and the like without adding other hardware equipment, and improving the time synchronization precision while reducing the cost.
According to some embodiments of the invention, the method further comprises:
time acquisition: acquiring a first time of the time hardware device and a second time of the virtual machine at the current moment;
performing one of the following steps according to the first time and the second time:
if the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time;
and if the time interval between the first time and the second time is smaller than or equal to the first time interval, returning to the time acquisition step after the second time interval.
According to some embodiments of the invention, the generating a time-modified value from the clock-modification instruction includes:
virtual clock acquisition: acquiring a first virtual clock of the virtual machine;
according to the clock change instruction, the clock of the virtual machine is adjusted to a second virtual clock;
comparing the first virtual clock with the second virtual clock;
if the first virtual clock is not equal to the second virtual clock, generating a time modification value according to the clock modification instruction;
and if the first virtual clock is equal to the second virtual clock, returning to the virtual clock acquisition step.
According to some embodiments of the invention, the inputting the time-modified value into the virtual hardware to control a physical machine to obtain the time-modified value includes:
inputting the time modification value into the virtual hardware, and detecting the storage state of the virtual hardware;
and if the time modification value is stored in the virtual hardware, generating interrupt information to control a physical machine to acquire the time modification value according to the interrupt information.
According to an embodiment of the second aspect of the present invention, a time synchronization apparatus includes:
the virtual hardware generation module is used for acquiring the memory call instruction and generating virtual hardware according to the memory call instruction;
the time modification value generation module is used for acquiring a clock modification request and generating a time modification value according to the clock modification request;
a time-modified value writing module for writing the time-modified value into the virtual hardware;
a time modification value acquisition module, configured to acquire the time modification value and access a time hardware device;
and the time synchronization module is used for writing the time modification value into the time hardware equipment.
The time synchronization device according to the embodiment of the invention at least comprises the following steps: by the time synchronization device provided by the invention, the virtual machine system can acquire time change operation performed in the user virtual machine software, namely, a clock change instruction and a memory call instruction, and virtual hardware is generated according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, thereby realizing the time synchronization between the physical machine and the virtual machine, effectively avoiding the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improving the time synchronization precision while reducing the cost.
According to some embodiments of the invention, the apparatus further comprises:
the first loop module is used for executing the time acquisition step: acquiring a first time of the time hardware device and a second time of the virtual machine at the current moment;
the first judging module is used for executing one of the following steps according to the first time and the second time:
if the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time;
and if the time interval between the first time and the second time is smaller than or equal to the first time interval, returning to the time acquisition step after the second time interval.
According to some embodiments of the invention, the time modification value generation module includes:
a second loop unit configured to execute the clock change request acquisition step: acquiring the clock change request and acquiring a first virtual clock of the virtual machine;
the second judging unit is used for changing the clock of the virtual machine to a second virtual clock according to the clock changing request, and executing one of the following steps:
if the first virtual clock is not equal to the second virtual clock, generating a time modification value according to the clock modification request;
or,
and if the first virtual clock is equal to the second virtual clock, returning to the clock change request acquisition step.
According to some embodiments of the invention, the time-varying value writing module includes:
the interrupt information generation unit is used for detecting the storage state of the virtual hardware, and generating interrupt information when the time modification value is stored in the virtual hardware;
and the communication unit is used for acquiring the interrupt information and establishing communication interaction with the time hardware equipment.
An embodiment of the time synchronization device according to the third aspect of the present invention includes: the virtual machine is provided with virtual machine software, and the virtual machine software is used for executing the time synchronization method according to the embodiment of the first aspect of the invention;
the physical machine is used for providing an operation platform of the virtual machine and is also used for carrying out data interaction with the virtual machine.
The time synchronization device according to the embodiment of the invention has at least the following beneficial effects: the time synchronization device provided by the invention can acquire the time change operation performed in the user virtual machine software through the virtual machine, namely, acquire the clock change instruction and the memory call instruction, and generate virtual hardware according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, so as to realize the time synchronization between the physical machine and the virtual machine, effectively avoid the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improve the time synchronization precision while reducing the cost.
According to a fourth aspect of the present invention, there is provided a computer readable storage medium storing computer executable instructions operable to perform a time synchronisation method according to an embodiment of the first aspect of the present invention.
The computer-readable storage medium according to the embodiment of the invention has at least the following advantageous effects: the computer readable storage medium of the embodiment of the present invention may be used to execute the time synchronization method according to the embodiment of the first aspect of the present invention, so as to obtain, through the virtual machine, a time modification operation performed in the user virtual machine software, that is, obtain a clock modification instruction and a memory call instruction, and generate virtual hardware according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, so as to realize the time synchronization between the physical machine and the virtual machine, effectively avoid the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improve the time synchronization precision while reducing the cost.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The invention is further described with reference to the accompanying drawings and examples, in which:
fig. 1 is a flowchart of a time synchronization method according to an embodiment of the invention.
Fig. 2 is a flowchart of a time synchronization method according to an embodiment of the invention.
Fig. 3 is a specific flowchart of step S300 in fig. 1.
Fig. 4 is a specific flowchart of step S400 in fig. 1.
Fig. 5 is a schematic structural diagram of a time synchronization device according to an embodiment of the invention.
Fig. 6 is a schematic diagram of another structure of a time synchronization apparatus according to an embodiment of the invention.
Fig. 7 is a specific structural diagram of the time-modified value generation module 300 in fig. 6.
Fig. 8 is a specific structural diagram of the time-modified value writing module 400 in fig. 6.
Reference numerals: 100. an instruction acquisition module; 200. a virtual hardware generation module; 300. a time change value generation module; 400. A time-varying value writing module; 500. a time change value acquisition module; 600. a time synchronization module; 710. a first circulation module; 720. a first judgment module; 310. a second circulation module; 320. a second judging module; 410. an interrupt information generation unit; 420. and a communication unit.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
In the description of the present invention, it should be understood that references to orientation descriptions such as upper, lower, front, rear, left, right, etc. are based on the orientation or positional relationship shown in the drawings, are merely for convenience of description of the present invention and to simplify the description, and do not indicate or imply that the apparatus or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the present invention.
In the description of the present invention, the meaning of a number is one or more, the meaning of a number is two or more, and greater than, less than, exceeding, etc. are understood to exclude the present number, and the meaning of a number is understood to include the present number. The description of the first and second is for the purpose of distinguishing between technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless explicitly defined otherwise, terms such as arrangement, installation, connection, etc. should be construed broadly and the specific meaning of the terms in the present invention can be reasonably determined by a person skilled in the art in combination with the specific contents of the technical scheme.
In the description of the present invention, the descriptions of the terms "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
In a first aspect, referring to fig. 1, the present invention provides a time synchronization method, including:
s100, acquiring a clock change instruction and a memory call instruction;
s200, generating virtual hardware according to the memory call instruction;
s300, generating a time modification value according to a clock modification instruction;
s400, inputting the time change value into the virtual hardware to control the physical machine to acquire the time change value;
s500, acquiring a synchronous instruction fed back by the physical machine according to the time change value;
s600, inputting the time modification value into the time hardware device according to the synchronous instruction.
According to the time synchronization method, the clock changing instruction and the memory calling instruction are obtained, the instruction for changing the clock in software running on the virtual machine by a user can be obtained, the virtual machine system is informed of calling the system memory through the memory calling instruction, and virtual hardware is generated through the memory calling instruction. According to the acquired clock change instruction, the method can control the virtual machine system to generate a time change value according to the clock change instruction, and change the time into the input value virtual hardware, so that the time of the physical machine is modified. When the physical machine is changed according to the time change value, the method can control the virtual machine system to acquire the synchronous instruction fed back by the physical machine according to the time change value, and input the synchronous instruction into the time hardware equipment so as to realize time synchronization between the physical machine and the virtual machine. By the method, the virtual machine system can acquire time change operation performed in the user virtual machine software, namely, a clock change instruction and a memory call instruction, and virtual hardware is generated according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method that the precision is reduced due to the time delay generated by the network synchronization time, thereby effectively realizing the time synchronization between the physical machine and the virtual machine, effectively avoiding the problem of low time synchronization precision caused by the time delay generated by the network transmission mode and the like without adding other hardware equipment.
Referring to fig. 2, in some embodiments, a time synchronization method provided by the present invention further includes:
s710, time acquisition: acquiring a first time of a time hardware device at a current moment and a second time of a virtual machine;
s720, executing one of the following steps according to the first time and the second time:
s730, if the time interval between the first time and the second time is greater than the first time interval, adjusting the time of the virtual machine to the first time;
s740, if the time interval between the first time and the second time is less than or equal to the first time interval, returning to the time acquisition step after the second time interval.
In the method, the time obtaining step is executed to obtain the current time of the time hardware device and the virtual machine at the current time, compare the first time corresponding to the time hardware device with the second time corresponding to the virtual machine, and perform different operations according to the comparison result. Specifically, by comparing the time interval between the first time and the second time, if the time interval between the first time and the second time is larger than the first time interval, the method can control the virtual machine to adjust the virtual machine time to the first time; if the time interval between the first time and the second time is less than or equal to the first time interval, the method can control the virtual machine to re-execute the time acquisition step after the second time interval so as to re-acquire the first time and the second time. The method comprises the steps of controlling the virtual machine to execute steps S710 to S740, enabling the virtual machine to be in a state of monitoring the time of the virtual machine and the time of the physical machine, comparing the first time with the second time, judging whether the difference between the current time of the virtual machine and the time of the physical machine is larger than a preset first time interval, and controlling the virtual machine to adjust the time of the virtual machine to be in a state of synchronizing the physical machine if the difference is larger than the first time interval, so that abnormal time of the virtual machine caused by running errors or other faults of the virtual machine is prevented, and time synchronization between the virtual machine and the physical machine is realized; and if the time interval is smaller than or equal to the first time interval, controlling the virtual machine to reacquire the first time of the time hardware equipment and the second time of the virtual machine after a preset second time interval, so as to prepare for next round of synchronous time checking. By presetting the second time interval, the method can effectively reduce the running load of the virtual machine, and after the second time interval is acceptable, the steps S710 to S740 are executed again, so that the accuracy of the time synchronization method can be ensured.
In addition, in some embodiments, since the virtual machine software can directly run on the physical machine, the virtual machine software can directly access the time hardware device, thereby obtaining the time value of the physical machine, and further directly modifying the time of the virtual machine, so as to avoid calling the system resources of the virtual machine, and effectively reduce the risk of insufficient time synchronization precision caused by the resource load of the virtual machine system.
Referring to fig. 3, in some embodiments, step S300 includes:
s310, virtual clock acquisition: acquiring a first virtual clock of a virtual machine;
s320, adjusting the clock of the virtual machine to a second virtual clock according to the clock change instruction;
s330, comparing the first virtual clock with the second virtual clock;
s340, if the first virtual clock is not equal to the second virtual clock, generating a time modification value according to the clock modification instruction;
s350, if the first virtual clock is equal to the second virtual clock, returning to the virtual clock acquisition step.
In the method, through step S310, the virtual machine system may acquire the first virtual clock, change the clock of the virtual machine to the second virtual clock according to the clock change instruction, and compare the first virtual clock with the second virtual clock, so that the virtual machine system may acquire the time change value, or may avoid the risk of error of the generated time change value caused by the instruction acquisition error or other transmission errors. Specifically, when the virtual machine system detects that the first virtual clock and the second virtual clock are not equal, generating a time modification value according to the clock modification instruction; if the virtual machine system detects that the first virtual clock is equal to the second virtual clock, returning to the virtual clock acquisition step, and thus obtaining an accurate time modification value.
Referring to fig. 4, in some embodiments, S400 includes:
s410, inputting the time change value into the virtual hardware, and detecting the storage state of the virtual hardware;
and S420, if the time modification value is stored in the virtual hardware, generating interrupt information to control the physical machine to acquire the time modification value according to the interrupt information.
In the method, the virtual machine system inputs the obtained time modification value into the virtual hardware, the storage state of the virtual hardware can be obtained through monitoring the virtual hardware, and when the time modification value stored in the virtual hardware is detected, the virtual machine software on the virtual machine can monitor the terminal information and obtain the time modification value according to the terminal information. Through step S410 and step S420, the virtual machine can effectively acquire the time-varying value. By monitoring interrupt information generated by a change in the storage state of the virtual hardware, the virtual machine system can efficiently acquire a time-modified value. In some specific embodiments, the method modifies the virtual machine software, so that the modified virtual machine software has the authority to access the virtual hardware, and when the virtual machine software obtains the time modification value, the time modification value stored in the virtual hardware is obtained according to the generated interrupt information, thereby effectively realizing the obtaining and storing of the time modification value.
In a second aspect, referring to fig. 5, the present invention provides a time synchronization apparatus, comprising:
the virtual hardware generation module 100 is configured to obtain the memory call instruction, and generate virtual hardware according to the memory call instruction
A time change value generation module 200 for acquiring the clock change request and generating a time change value according to the clock change request
A time-modified value writing module 300 for writing a time-modified value into virtual hardware
A time modification value acquisition module 400 for acquiring the time modification value and accessing the time hardware device
A time synchronization module 500 for writing time modification value into time hardware device
The time synchronization device provided by the invention comprises a virtual hardware generation module 100, a time modification value generation module 200, a time modification value writing module 300, a time modification value acquisition module 400 and a time synchronization module 500. The virtual hardware generation module 100 may obtain a memory call instruction, and access a corresponding memory space according to the memory call instruction, thereby generating virtual hardware; the time modification value generation module 200 may obtain the clock modification request and generate a specific time modification value according to the time modification request; the time-modified value writing module 300 may write the time-modified value into the virtual hardware, the time-modified value obtaining module 400 may obtain the time-modified value, and access the time hardware device; the time synchronization module 500 may write the time modification value to the time hardware device, thereby implementing time synchronization of the physical machine and the virtual machine. By the time synchronization device provided by the invention, the virtual machine system can acquire time change operation performed in the user virtual machine software, namely, a clock change instruction and a memory call instruction, and virtual hardware is generated according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, thereby realizing the time synchronization between the physical machine and the virtual machine, effectively avoiding the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improving the time synchronization precision while reducing the cost.
Referring to fig. 6, in some embodiments, the time synchronization apparatus further includes:
a first loop module 710, configured to perform a time acquisition step: acquiring a first time of a time hardware device at a current moment and a second time of a virtual machine;
the first determining module 720 is configured to perform one of the following steps according to the first time and the second time:
if the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time;
if the time interval between the first time and the second time is smaller than or equal to the first time interval, returning to the time acquisition step after the second time interval.
According to the time synchronization device provided by the invention, the current time of the virtual machine and the current time stored by the time hardware equipment in the physical machine can be obtained through the first circulation module 710, the second time in the first time virtual machine in the time hardware equipment is compared through the first judgment module 720, and when the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time; when the time interval between the first time and the second time is smaller than or equal to the first time interval, the time acquisition step is returned after the second time interval, and the time deviation between the virtual machine and the physical machine is effectively corrected, wherein when the first judgment module 720 judges that the time interval between the first time and the second time is smaller than the first time interval, the waiting time with the duration of the second time interval is delayed, and then the time acquisition step is returned to correct the time deviation between the physical machine and the virtual machine for the next time, and the accuracy of the time synchronization device can be ensured and the resource load of the time synchronization device can be effectively reduced to ensure the stability of the device through presetting the second time interval.
Referring to fig. 7, in some embodiments, the time modification value generation module 200 includes:
a second loop unit 210 for executing a clock change request acquisition step: acquiring a clock change request and acquiring a first virtual clock of a virtual machine
The second judging unit 220 is configured to change the clock of the virtual machine to the second virtual clock according to the clock change request, and perform one of the following steps:
if the first virtual clock is not equal to the second virtual clock, generating a time change value according to the clock change request
Or,
and if the first virtual clock is equal to the second virtual clock, returning to the clock change request acquisition step.
In the time synchronization device provided by the invention, the second circulation unit 210 can acquire the clock change request, detect the current time of the virtual machine, and define the detection result as the first virtual clock, so that the second judgment unit 220 adjusts the clock of the virtual machine to the second virtual clock according to the clock change request. In order to avoid unexpected errors in the process of changing the clock of the virtual machine, the second judging unit 220 provided by the device can also compare the first virtual clock with the second virtual clock, and when the first virtual clock is not equal to the second virtual clock, a time change value is generated according to the clock change request; or when the first virtual clock is equal to the second virtual clock, returning to the clock change request acquisition step, thereby reacquiring the time change request to re-change the virtual machine clock. The time synchronization device provided by the invention can change the current clock of the virtual machine through the second circulation unit 210 and the second judgment unit 220, and detect the changed clock of the virtual machine, so that the accuracy of clock change is ensured, the cost is reduced, and the accuracy of time synchronization is improved.
Referring to fig. 8, in some embodiments, the time-modified value writing module 300 includes:
an interrupt information generation unit 310 for detecting the storage state of the virtual hardware, and generating interrupt information when the time-varying value is stored in the virtual hardware
And the communication unit 320 is configured to obtain the interrupt information and establish communication interaction with the time hardware device.
In the time synchronization apparatus provided by the present invention, the interrupt information generating unit 310 may detect a storage state of the virtual hardware, and generate interrupt information when a time modification value is stored in the virtual hardware. Specifically, the virtual machine system may call the time monitoring hook, and the time monitoring hook may acquire the change of the virtual machine software to the virtual machine system time in real time, and because in this embodiment, the virtual hardware may store the time change value, the time synchronization apparatus provided by the present invention may control the interrupt information generating unit 310 to output the interrupt information according to the storage state change in the virtual hardware, so as to prompt the virtual machine system that the time change occurs in the virtual machine software, and establish the communication interaction between the virtual machine system and the time hardware device through the communication unit 320, so as to complete the output of the time change value.
In a third aspect, the present invention provides a time synchronization apparatus comprising:
a virtual machine, on which virtual machine software is provided, the virtual machine software being configured to execute the time synchronization method as in the first aspect;
the physical machine is used for providing an operation platform of the virtual machine and is also used for carrying out data interaction with the virtual machine.
The virtual machine in the time synchronization device provided by the invention can execute the time synchronization method according to the embodiment of the first aspect of the invention, the time synchronization device can change time according to the user instruction through the virtual machine software running on the virtual machine, interrupt information can be obtained through the virtual hardware, and the time change value is synchronized from the virtual machine to the time hardware device according to the interrupt information. The physical machine in the time synchronization device provided by the invention can provide an operation platform of the virtual machine and complete time synchronization according to data interaction with the virtual machine. The time synchronization device provided by the invention can acquire the time change operation performed in the user virtual machine software through the virtual machine, namely, acquire the clock change instruction and the memory call instruction, and generate virtual hardware according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, so as to realize the time synchronization between the physical machine and the virtual machine, effectively avoid the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improve the time synchronization precision while reducing the cost.
In a fourth aspect, the present invention provides a computer readable storage medium, where computer executable instructions are stored, where the computer readable storage medium is configured to perform a time synchronization method according to an embodiment of the first aspect of the present invention, so as to obtain, by a virtual machine, a time change operation performed in user virtual machine software, that is, obtain a clock change instruction and a memory call instruction, and generate virtual hardware according to the memory call instruction; generating a time modification value according to the clock modification instruction, and directly storing the time modification value through virtual hardware generated by the virtual machine. Because the virtual machine directly operates on the physical machine, the method can directly input the time change value generated on the virtual machine into the time hardware equipment of the physical machine, and avoid the problem of the time synchronization method precision reduction caused by the time delay generated by the network synchronization time, so as to realize the time synchronization between the physical machine and the virtual machine, effectively avoid the problem of low time synchronization precision caused by the time delay generated by the modes of network transmission and the like without adding other hardware equipment, and improve the time synchronization precision while reducing the cost.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of one of ordinary skill in the art without departing from the spirit of the present invention. Furthermore, embodiments of the invention and features of the embodiments may be combined with each other without conflict.

Claims (10)

1. A method of time synchronization comprising:
acquiring a clock change instruction and a memory call instruction;
generating virtual hardware according to the memory call instruction;
generating a time modification value according to the clock modification instruction;
inputting the time modification value into the virtual hardware to control a physical machine to acquire the time modification value;
acquiring a synchronous instruction fed back by the physical machine according to the time change value;
and inputting the time modification value to a time hardware device according to the synchronous instruction.
2. The time synchronization method according to claim 1, characterized in that the method further comprises:
time acquisition: acquiring the first time of the time hardware equipment and the second time of the virtual machine at the current moment;
performing one of the following steps according to the first time and the second time:
if the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time;
and if the time interval between the first time and the second time is smaller than or equal to the first time interval, returning to the time acquisition step after the second time interval.
3. The method of claim 1, wherein generating a time-modified value from the clock-modification instruction comprises:
virtual clock acquisition: acquiring a first virtual clock of a virtual machine;
according to the clock change instruction, the clock of the virtual machine is adjusted to a second virtual clock;
comparing the first virtual clock with the second virtual clock;
if the first virtual clock is not equal to the second virtual clock, generating a time modification value according to the clock modification instruction;
and if the first virtual clock is equal to the second virtual clock, returning to the virtual clock acquisition step.
4. The method of claim 1, wherein the inputting the time-modified value into the virtual hardware to control a physical machine to obtain the time-modified value comprises:
inputting the time modification value into the virtual hardware, and detecting the storage state of the virtual hardware;
and if the time modification value is stored in the virtual hardware, generating interrupt information to control a physical machine to acquire the time modification value according to the interrupt information.
5. A time synchronization device, comprising:
the virtual hardware generation module is used for acquiring the memory call instruction and generating virtual hardware according to the memory call instruction;
the time modification value generation module is used for acquiring a clock modification request and generating a time modification value according to the clock modification request;
a time-modified value writing module for writing the time-modified value into the virtual hardware;
a time modification value acquisition module, configured to acquire the time modification value and access a time hardware device;
and the time synchronization module is used for writing the time modification value into the time hardware equipment.
6. The time synchronization device of claim 5, further comprising:
the first loop module is used for executing the time acquisition step: acquiring the first time of the time hardware equipment and the second time of the virtual machine at the current moment;
the first judging module is used for executing one of the following steps according to the first time and the second time:
if the time interval between the first time and the second time is larger than the first time interval, the time of the virtual machine is adjusted to be the first time;
and if the time interval between the first time and the second time is smaller than or equal to the first time interval, returning to the time acquisition step after the second time interval.
7. The time synchronization device of claim 5, wherein the time modification value generation module comprises:
a second loop unit configured to execute the clock change request acquisition step: acquiring the clock change request and acquiring a first virtual clock of the virtual machine;
the second judging unit is used for changing the clock of the virtual machine to a second virtual clock according to the clock changing request, and executing one of the following steps:
if the first virtual clock is not equal to the second virtual clock, generating a time modification value according to the clock modification request;
or,
and if the first virtual clock is equal to the second virtual clock, returning to the clock change request acquisition step.
8. The time synchronization device of claim 5, wherein the time-modified value writing module comprises:
the interrupt information generation unit is used for detecting the storage state of the virtual hardware, and generating interrupt information when the time modification value is stored in the virtual hardware;
and the communication unit is used for acquiring the interrupt information and establishing communication interaction with the time hardware equipment.
9. A time synchronization apparatus, comprising:
a virtual machine on which virtual machine software is provided for executing the time synchronization method according to any one of claims 1 to 4;
the physical machine is used for providing an operation platform of the virtual machine and is also used for carrying out data interaction with the virtual machine.
10. Computer readable storage medium, characterized in that it stores computer executable instructions for performing the time synchronization method according to any one of claims 1 to 4.
CN202111277392.2A 2021-10-29 2021-10-29 Time synchronization method, device, equipment and storage medium Active CN114003091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111277392.2A CN114003091B (en) 2021-10-29 2021-10-29 Time synchronization method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111277392.2A CN114003091B (en) 2021-10-29 2021-10-29 Time synchronization method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114003091A CN114003091A (en) 2022-02-01
CN114003091B true CN114003091B (en) 2024-01-30

Family

ID=79925710

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111277392.2A Active CN114003091B (en) 2021-10-29 2021-10-29 Time synchronization method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114003091B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107544619A (en) * 2017-06-27 2018-01-05 新华三云计算技术有限公司 Method for synchronizing time and device
CN108829493A (en) * 2018-06-22 2018-11-16 山东超越数控电子股份有限公司 A kind of virtual machine method for synchronizing time and device
CN110932839A (en) * 2018-09-20 2020-03-27 中兴通讯股份有限公司 Network card, time synchronization method, equipment and computer storage medium
CN111857237A (en) * 2020-07-27 2020-10-30 山东超越数控电子股份有限公司 Clock synchronization method, system, device and medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080196043A1 (en) * 2007-02-08 2008-08-14 David Feinleib System and method for host and virtual machine administration
CN102081552A (en) * 2009-12-01 2011-06-01 华为技术有限公司 Method, device and system for transferring from physical machine to virtual machine on line

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107544619A (en) * 2017-06-27 2018-01-05 新华三云计算技术有限公司 Method for synchronizing time and device
CN108829493A (en) * 2018-06-22 2018-11-16 山东超越数控电子股份有限公司 A kind of virtual machine method for synchronizing time and device
CN110932839A (en) * 2018-09-20 2020-03-27 中兴通讯股份有限公司 Network card, time synchronization method, equipment and computer storage medium
CN111857237A (en) * 2020-07-27 2020-10-30 山东超越数控电子股份有限公司 Clock synchronization method, system, device and medium

Also Published As

Publication number Publication date
CN114003091A (en) 2022-02-01

Similar Documents

Publication Publication Date Title
US20130179554A1 (en) Method, apparatus and electronic device for application display
US9594820B2 (en) Apparatus, and associated method, for synchronizing a group of data objects
CN113746821A (en) Intelligent device control method and device, storage medium and electronic device
CN114003091B (en) Time synchronization method, device, equipment and storage medium
CN113452770B (en) Data synchronization method, device, computer equipment and storage medium
CN111245071B (en) Parameter management method, system and device of modular charger
CN111090442B (en) Application updating method, device and storage medium
US10467358B2 (en) Simulation apparatus and operating method thereof
CN112346933B (en) Malicious file scanning method, device, equipment and medium
CN112732548B (en) Interface testing method and device
US8966504B2 (en) Information processing apparatus, electrical power control method, and computer product
CN116886845B (en) Adaptive parameter updating method, device, computer equipment and storage medium
CN114764379A (en) Access switching method and device for application software and computer readable storage medium
CN115239289B (en) Digital engineering supervision method and system based on BIM
CN115934736A (en) Data docking method, device, equipment and storage medium
CN117596184B (en) Communication connection detection method and device
WO2023236806A1 (en) Data burning method and apparatus, and computer device and computer-readable storage medium
CN117041414A (en) Picture jitter compensation method and device, electronic equipment and computer storage medium
CN114415877A (en) Multi-window interaction method, device, equipment and storage medium
CN118172954A (en) Traffic light control method, system, storage medium and electronic equipment
CN115348201A (en) Calibration scheduling method and related device
CN113706010A (en) Linkage processing method and device, equipment and storage medium
JP3542745B2 (en) Design support system
CN117033084A (en) Virtual machine backup method and device, electronic equipment and storage medium
CN113687929A (en) Exception handling method and related device

Legal Events

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