CN121193362A - Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product - Google Patents
Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program productInfo
- Publication number
- CN121193362A CN121193362A CN202511715579.4A CN202511715579A CN121193362A CN 121193362 A CN121193362 A CN 121193362A CN 202511715579 A CN202511715579 A CN 202511715579A CN 121193362 A CN121193362 A CN 121193362A
- Authority
- CN
- China
- Prior art keywords
- value
- time stamp
- timestamp
- shared memory
- local
- 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.)
- Pending
Links
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The application relates to a method, a device, a chip, a network interface card, equipment, a medium and a program product for synchronizing time stamps of cross-operation levels. The method comprises the steps of obtaining a first value recorded by a system counter and counted by clock cycles started by a system, enabling firmware and application programs running at different running levels to use the same system counter, obtaining a second value and a first local time stamp stored by the application program from a shared memory under the condition that a time stamp synchronization completion mark exists in the shared memory, and obtaining the second local time stamp based on the first value, the second value and the first local time stamp. By adopting the method, the accurate synchronization of the time stamps of different privilege levels can be realized.
Description
Technical Field
The present application relates to the field of chip technologies, and in particular, to a method, an apparatus, a chip, a network interface card, a device, a medium, and a program product for synchronizing timestamps across operation levels.
Background
A processor architecture, such as an ARMv8 architecture, defines 4 exception levels (EL 0-EL 3), wherein each exception level runs a respective program, BL31 is part of ARM Trusted Firmware (ATF), runs on EL3 as a scheduling hub of the Secure and Non-Secure world to provide basic runtime services, such as PSCI, SCMI and the like, BL32 runs on Secure EL1 to provide trusted services, RAS reliability services and the like, and Linux kernel runs on Non-Secure EL1 (or EL2 if virtualization is enabled). The user Application (APP) running level is Non-Secure EL0 (user mode).
In complex chip software systems based on the ARMv8 architecture, multiple runtime services (such as BL31, BL32 and Linux kernels) run at different privilege levels. In such a way, when the system is debugged, fault diagnosis and performance analysis are performed, the synchronous requirements on the time stamps of different privilege levels are higher.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product that enable accurate synchronization of timestamps at different privilege levels.
In a first aspect, the present application provides a method for synchronizing timestamps across operation levels, applied to firmware, the method comprising:
Acquiring a first value recorded by a system counter and counted by clock cycles started by a system, wherein firmware and application programs running at different running levels use the same system counter;
under the condition that a timestamp synchronization completion mark exists in a shared memory, acquiring a second value and a first local timestamp stored by the application program from the shared memory;
a second local timestamp is derived based on the first value, the second value, and the first local timestamp.
In one embodiment, the obtaining the second local timestamp based on the first value, the second value, and the first local timestamp includes:
Determining a number of seconds of system operation since timestamp synchronization based on the first value, the second value, and a frequency of the system counter;
converting the first local timestamp to a second of a first coordinated universal time;
Obtaining the second number of seconds of the second coordinated universal time based on the second number of seconds of the first coordinated universal time and the second number of seconds of the system operation since the time stamp synchronization;
a second local timestamp is obtained based on the second coordinated universal time seconds.
In one embodiment, the method further comprises:
And storing the second local timestamp to an output log.
In one embodiment, the method further comprises:
converting the first value into seconds and nanoseconds when the timestamp synchronization completion flag does not exist in the shared memory;
The seconds and nanoseconds are stored to an output log.
In one embodiment, the second value in the shared memory is the value of the system counter read by the application program, the first local timestamp in the shared memory is obtained by converting the application program based on a timestamp of coordinated universal time of the system, and the timestamp synchronization completion flag in the shared memory is set in the shared memory after the second value and the first local timestamp are stored in the shared memory.
In a second aspect, the present application further provides a cross-running-level timestamp synchronization method, applied to an application program, where the method further includes:
Acquiring a second value recorded by a system counter and counted by a clock cycle started by a system, and writing the second value into a shared memory, wherein the same system counter is used by firmware and application programs running at different running levels;
Acquiring a time stamp of coordinated universal time of a system, converting the time stamp of coordinated universal time into a first local time stamp, and storing the first local time stamp into the shared memory;
Setting a time stamp synchronization completion flag to the shared memory, wherein the time stamp synchronization completion flag is used for indicating that the firmware obtains a second value and a first local time stamp stored by the application program from the shared memory under the condition that the existence of the time stamp synchronization completion flag in the shared memory is determined, and obtaining the second local time stamp based on the first value, the second value and the first local time stamp, wherein the first value is a first value recorded by a system counter and counted from a clock cycle started by the system.
In a third aspect, the present application further provides a cross-run-level timestamp synchronization apparatus, the apparatus comprising:
the first value acquisition module is used for acquiring a first value of clock cycle count which is recorded by a system counter and started by a system, and firmware and application programs running at different running levels use the same system counter;
the reading module is used for acquiring a second value and a first local timestamp stored by the application program from the shared memory under the condition that a timestamp synchronization completion mark exists in the shared memory;
And the second local timestamp generation module is used for obtaining a second local timestamp based on the first value, the second value and the first local timestamp.
In a fourth aspect, the present application further provides a cross-running-level timestamp synchronization apparatus, applied to an application program, where the apparatus further includes:
The second value acquisition module is used for acquiring a second value recorded by the system counter and counted by a clock cycle started by the system, writing the second value into the shared memory, and using the same system counter by firmware and application programs running at different running levels;
The storage module is used for acquiring the time stamp of the coordinated universal time of the system, converting the time stamp of the coordinated universal time into a first local time stamp and storing the first local time stamp into the shared memory;
The system comprises a shared memory, a synchronization module, a system counter and a time stamp synchronization completion flag, wherein the shared memory is used for storing a first local time stamp and a second value stored by the application program, the synchronization module is used for setting the time stamp synchronization completion flag to the shared memory, the time stamp synchronization completion flag is used for indicating the firmware to acquire the second value and the first local time stamp stored by the application program from the shared memory under the condition that the time stamp synchronization completion flag exists in the shared memory, the second local time stamp is acquired based on the first value, the second value and the first local time stamp, and the first value is a first value recorded by the system counter and counted by the clock cycle started by the system.
In a fifth aspect, the present application also provides a chip comprising a memory storing a computer program and a processor implementing the steps of the method of any one of the embodiments described above when the computer program is executed by the processor.
In a sixth aspect, the present application also provides a network interface card comprising a chip and a plurality of interfaces as in any one of the embodiments described above,
The chip processes data or communicates with the outside through the interface.
In a seventh aspect, the present application further provides a computer device, including a network interface card in any one of the foregoing embodiments, where the network interface card is used to process data or communicate externally.
In an eighth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method of any of the embodiments described above.
In a ninth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any of the embodiments described above.
The method, the device, the chip, the network interface card, the equipment, the medium and the program product for synchronizing the timestamp of the cross-operation level acquire a first value recorded by a system counter and counted by a clock cycle started by a system, firmware and an application program which are operated at different operation levels use the same system counter, acquire a second value and a first local timestamp stored by the application program from a shared memory under the condition that a timestamp synchronization completion mark exists in the shared memory, acquire the second local timestamp based on the first value, the second value and the first local timestamp, and ensure that event records among different operation levels and programs can be marked based on a unified time reference, realize the accurate synchronization of the timestamps of different privilege levels, and construct a global time reference based on the system counter without additionally increasing a hardware timer, thereby avoiding the cost of chip area and power consumption.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are needed in the description of the embodiments of the present application or the related technologies will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other related drawings may be obtained according to these drawings without inventive effort to those of ordinary skill in the art.
FIG. 1 is a flow diagram of a method of timestamp synchronization across run levels in one embodiment;
FIG. 2 is a flow chart of a time stamp synchronization step in one embodiment;
FIG. 3 is a flowchart of a firmware timestamp synchronization step in one embodiment;
FIG. 4 is a flow chart of a method of timestamp synchronization across run levels in another embodiment;
FIG. 5 is a block diagram of an embodiment of a cross-run level timestamp synchronization apparatus;
FIG. 6 is a block diagram of another embodiment of a cross-run-level timestamp synchronization apparatus;
fig. 7 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
It should be noted that the terms "first," "second," and the like, as used herein, may be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from a second element. The terms "comprising" and "having," as well as any variations thereof, as used herein, are intended to cover a non-exclusive inclusion. The term "plurality" as used herein refers to two and more than two. The term "and/or" as used herein refers to one of, or any combination of, the various schemes therein.
The cross-operation-level timestamp synchronization method provided by the embodiment of the application can be applied to a processor architecture, such as an ARMv8 architecture. The ARMv8 architecture includes different levels of operation, where the level of operation EL3, BL31 (Boot Loader Stage-1, runtime firmware) is part of ARM Trusted Firmware (ATF, ARM Secure), at which it operates as a dispatch backbone for both Secure and Non-Secure worlds, providing basic runtime services such as PSCI (Power State Coordination Interface ), SCMI (System Control AND MANAGEMENT INTERFACE, system Control and management interface), etc., the level of operation Secure EL1, BL32 (Boot Loader Stage 3-2, viable execution Environment) operating at which it provides trusted services, RAS reliability services, etc., and the Linux kernel level of operation Non-Secure EL1 (or EL2, if virtualization is enabled). Application (APP) running level Non-Secure EL0 (user mode).
Therefore, there are a plurality of runtime services (such as BL31, BL32, linux kernel and application program) running at different privilege levels, and in order to achieve the above-mentioned timestamp synchronization of different running levels, the present application provides a timestamp synchronization method across running levels, wherein BL31 and BL32 implementation schemes are consistent, collectively referred to as firmware, for convenience of description.
In an exemplary embodiment, as shown in fig. 1, a method for synchronizing time stamps across operation levels is provided, and the method is applied to the firmware above as an example, and includes the following steps S102 to S106. Wherein:
S102, acquiring a first value recorded by a system counter and counted by clock cycles started by the system, wherein the same system counter is used by firmware and application programs running at different running levels.
The system counter is a counter of a system corresponding to the ARMv8 architecture, and each firmware, kernel and application program use the same system counter to record the time stamp.
The firmware may obtain the first value of the clock cycle count from the system start recorded by the system counter, for example, read cntpct _el0, and obtain the clock cycle count from the system start when the firmware needs to generate a log or needs to execute other services needing to record a timestamp.
And S104, under the condition that the timestamp synchronization completion mark exists in the shared memory, acquiring the second value and the first local timestamp saved by the application program from the shared memory.
The timestamp synchronization completion flag, the second value, and the first local timestamp are stored in the shared memory. The timestamp synchronization completion flag, the second value, and the first local timestamp are generated when the application is clocked and stored in the shared memory.
In some alternative embodiments, the second value in the shared memory is a value of a system counter read by the application program, the first local timestamp in the shared memory is obtained by converting a timestamp of the coordinated universal time of the application program based on the system, and the timestamp synchronization completion flag in the shared memory is set in the shared memory after the second value and the first local timestamp are stored in the shared memory.
Specifically, when the application program needs to store a log or other business needing a time stamp, the second value of the system counter is read and stored in the shared memory, then the coordinated universal time is read and converted into a first local time stamp, the first local time stamp is stored in the shared memory, and a time stamp synchronization completion flag is set in the shared memory.
If the timestamp synchronization completion flag can be obtained, the synchronization is completed, so that the timestamp synchronization can be performed, that is, the firmware can obtain the second value and the first local timestamp.
And S106, obtaining a second local time stamp based on the first value, the second value and the first local time stamp.
In the case where the firmware determines that the timestamp synchronization completion flag is present, the second local timestamp may be derived based on the first value, the second value, and the first local timestamp.
The method for synchronizing the time stamps of the cross-operation levels comprises the steps of obtaining a first value recorded by a system counter and counted by clock cycles started by a system, enabling firmware and application programs running at different operation levels to use the same system counter, obtaining a second value and a first local time stamp stored by the application programs from a shared memory under the condition that a time stamp synchronization completion mark exists in the shared memory, obtaining the second local time stamp based on the first value, the second value and the first local time stamp, and therefore enabling event records among different operation levels to use the same counter, ensuring that event records among different operation time services and programs can be marked based on a unified time reference, realizing accurate synchronization of the time stamps of different privilege levels, building a global time sequence reference based on the system counter, avoiding the cost of chip area and power consumption without additionally increasing a hardware timer.
In some alternative embodiments, as shown in connection with fig. 2, the above-mentioned step of synchronizing the timestamps, that is, obtaining the second local timestamp based on the first value, the second value, and the first local timestamp, includes:
S202, determining the number of seconds of system operation since the time stamp synchronization based on the first value, the second value and the frequency of the system counter.
The obtained first value of the system counter is denoted as current_timer, the second value of the system counter reserved in the shared memory is subtracted, the obtained second value is denoted as base_timer, the clock cycle number of the system running since the time stamp synchronization is obtained, the obtained clock cycle number is denoted as delta_timer, the delta_timer is divided by the counter frequency, the obtained clock cycle number is denoted as freq, the obtained second number of the system running since the time stamp synchronization is denoted as delta_sec, and the formula is as follows:
delta_sec=(current_timer-base_timer)/freq
S204, converting the first local time stamp into seconds of the first coordinated universal time.
S206, obtaining the second coordinated universal time based on the second number of the first coordinated universal time and the second number of the system operation since the time stamp synchronization.
In this embodiment, call mktime converts the first local timestamp in the shared memory into UTC seconds, i.e., the seconds of the first coordinated universal time, and then adds delta_sec to obtain the seconds of the second coordinated universal time.
And S208, obtaining a second local timestamp based on the second time of the second coordinated universal time.
In this embodiment, the current UTC seconds is converted to a second local timestamp by invoking time_to_tm.
In some alternative embodiments, the method further comprises storing the second local timestamp in an output log, i.e., the second local timestamp may be converted to a string in the present application for output along with the log.
In the embodiment, in the ARMv8 multi-level security system, the synchronization function of log time stamps between various running programs and services such as firmware, linux and the like is realized, and the system debugging efficiency and the online fault diagnosis capability are obviously improved. The scheme ensures that event records between different runtime services and programs can be marked based on a unified time reference by using the same counter at multiple running levels. The time stamp synchronization mechanism not only can accurately position the interaction time sequence problem between different services and programs, but also can track the event causal relationship between different services, thereby greatly shortening the system fault investigation period and improving the system reliability. In addition, the scheme also supports a dynamic time stamp adjustment synchronization strategy so as to adapt to performance requirements in different application scenes, and provides powerful technical support for development and maintenance of the complex multi-stage security system.
In some of these alternative embodiments, the method further includes converting the first value to seconds and nanoseconds in the absence of the timestamp synchronization completion flag in the shared memory, and storing the seconds and nanoseconds to the output log.
If the time stamps are not synchronized, the local time stamp cannot be output, and therefore the value of the system counter is converted into seconds and nanoseconds and output together with the log.
Specifically, total time (seconds) =counter difference/counter frequency (Hz), to obtain higher accuracy, nanoseconds are generally calculated first, total time (nanoseconds) = (counter difference 10≡9)/counter frequency (Hz), and then seconds and nanoseconds can be separated from nanoseconds, second=total time (nanoseconds)/1000000000, and the remaining nanoseconds=total time (nanoseconds)% 1000000000.
And finally, storing the obtained seconds and nanoseconds into an output log.
For ease of understanding, in conjunction with the illustration of FIG. 3, FIG. 3 is a flow chart of firmware timestamp synchronization steps in one embodiment, after entering a firmware log print entry, comprising the steps of:
A first value of the system counter is obtained, read cntpct _ el0, and a clock cycle count from system start (corresponding to the flowchart).
The timestamp synchronization completion flag is obtained from the shared memory.
If the time stamps are not synchronized, the system counter value is converted into seconds and nanoseconds and output with the log.
If the time stamps are synchronized, the second value of the system counter and the first local time stamp stored by the application program are obtained from the shared memory.
Converting a first value of a system counter to a local time for printing with a log, comprising:
Subtracting the value of the system counter (denoted as base_timer) reserved in the shared memory from the first value (denoted as current_timer) of the acquired counter to obtain the number of clock cycles of the system running since the time stamp synchronization, denoted as delta_timer, and dividing the delta_timer by the counter frequency (denoted as freq) to obtain the number of seconds of the system running since the time stamp synchronization (denoted as delta_sec). The formula is as follows:
the obtained first value of the system counter is denoted as current_timer, the second value of the system counter reserved in the shared memory is subtracted, the first value is denoted as base_timer, the number of clock cycles of the system running since the time stamp synchronization is obtained, the first value is denoted as delta_timer, the delta_timer is divided by the counter frequency, the second value is denoted as freq, and the number of seconds of the system running since the time stamp synchronization is obtained, the second value is denoted as delta_sec, and the formula is as follows:
delta_sec=(current_timer-base_timer)/freq
the call mktime converts the first local timestamp in the shared memory to UTC seconds, i.e., the seconds of the first coordinated universal time, and then adds delta_sec to obtain the seconds of the second coordinated universal time.
The current UTC seconds is converted to a second local timestamp by invoking time_to_tm.
The second local timestamp is converted into a string, which is output along with the log.
In an exemplary embodiment, as shown in fig. 4, a method for synchronizing time stamps across operation levels is provided, and an application to which the method is applied is described as an example, including the following steps S402 to S406. Wherein:
S402, acquiring a second value recorded by a system counter and counted by a clock cycle started by the system, writing the second value into a shared memory, and using the same system counter by firmware and application programs running at different running levels.
When the application program needs to print the log, the application program obtains the second value of the coefficient counter, reads cntvct _el0, obtains the clock cycle count from the system start, and writes the second value of the system counter into the shared memory.
S404, acquiring a time stamp of the coordinated universal time of the system, converting the time stamp of the coordinated universal time into a first local time stamp, and storing the first local time stamp into the shared memory.
The coordinated universal time stamp of the system is obtained, for example, the clock_gettime is called to obtain the high-precision UTC time stamp of the system.
The coordinated universal time stamp is converted into a first local time stamp struct tm through localtime _r, and the converted struct tm time structure is written into the shared memory area.
Specifically, the timestamp of coordinated universal time, namely UTC seconds, is converted into a determined UTC time (including years, months, days, hours, minutes and seconds). And then adding, subtracting and adjusting the UTC time according to the offset of the local time zone to obtain a final first local time stamp.
And S406, setting a timestamp synchronization completion flag to the shared memory, wherein the timestamp synchronization completion flag is used for indicating that the firmware acquires a second value and a first local timestamp stored by the application program from the shared memory under the condition that the timestamp synchronization completion flag exists in the shared memory, and acquiring the second local timestamp based on the first value, the second value and the first local timestamp, wherein the first value is a first value recorded by a system counter and counted from a clock cycle started by the system.
After the second value and the first local timestamp are stored in the shared memory, a timestamp synchronization completion flag is set in the shared memory, so that the firmware can realize timestamp synchronization.
For ease of understanding, examples of time-stamped synchronized and unsynchronized logs are given:
the time stamps are not synchronized:
firmware log samples are, for example, as follows, showing only the absolute time since the system was started.
After the time stamp synchronization:
the firmware log shows the local time as follows.
The Linux kernel log is as follows, showing the local time:
In general, when the firmware detects that an event needs to be reported to the Linux kernel, by adopting the cross-operation-level timestamp synchronization method provided by the application, after the cross-operation-level timestamps of the firmware and the Linux kernel are synchronized, the event recorded by the firmware and the kernel can be ensured to be synchronous, so that the problem can be conveniently positioned.
In the above embodiment, the global timing reference is constructed based on the armv architecture native system counter cntpct _el0, without adding an additional hardware timer, so as to avoid chip area and power consumption overhead. Log timestamp synchronization between a variety of different run levels and a variety of different runtime services and programs may also be achieved.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages. It is understood that the steps in the different embodiments may be freely combined according to the needs, and various contradictory schemes formed by combining all fall within the protection scope of the present application.
Based on the same inventive concept, the embodiment of the application also provides a cross-operation-level time stamp synchronization device for realizing the cross-operation-level time stamp synchronization method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of one or more cross-run-level timestamp synchronization devices provided below may be referred to the limitation of the cross-run-level timestamp synchronization method hereinabove, and will not be repeated herein.
In one exemplary embodiment, as shown in FIG. 5, a cross-run level timestamp synchronization apparatus is provided, comprising a first value acquisition module 501, a reading module 502, and a second local timestamp generation module 503, wherein:
A first value obtaining module 501, configured to obtain a first value of a clock cycle count recorded by a system counter and started from a system, where firmware and an application running at different running levels use the same system counter;
the reading module 502 is configured to obtain, from the shared memory, a second value and a first local timestamp stored in the application program when the timestamp synchronization completion flag exists in the shared memory;
The second local timestamp generation module 503 is configured to obtain a second local timestamp based on the first value, the second value, and the first local timestamp.
In some alternative embodiments, the second local timestamp generation module 503 is specifically configured to determine a second number of seconds of system operation since the timestamp synchronization, convert the first local timestamp to the first coordinated universal time second, obtain the second coordinated universal time second based on the first coordinated universal time second and the second number of seconds of system operation since the timestamp synchronization, and obtain the second local timestamp based on the second coordinated universal time second.
In some alternative embodiments, the apparatus further comprises a log generation module configured to store the second local timestamp to the output log.
In some alternative embodiments, the log generation module is further configured to convert the first value to seconds and nanoseconds if the timestamp synchronization completion flag is not present in the shared memory, and store the seconds and nanoseconds to the output log.
In some alternative embodiments, the second value in the shared memory is a value of a system counter read by the application program, the first local timestamp in the shared memory is obtained by converting the application program based on a timestamp of a coordinated universal time of the system, and the timestamp synchronization completion flag in the shared memory is set in the shared memory after the second value and the first local timestamp are stored in the shared memory.
In an exemplary embodiment, as shown in fig. 6, there is provided a timestamp synchronization apparatus across operation levels, including a second value acquisition module 601, a storage module 602, and a synchronization module 603, wherein:
the second value obtaining module 601 is configured to obtain a second value of a clock cycle count recorded by a system counter and started from a system, and write the second value into the shared memory, and firmware and an application running at different running levels use the same system counter;
the storage module 602 is configured to obtain a timestamp of a coordinated universal time of the system, convert the timestamp of the coordinated universal time into a first local timestamp, and store the first local timestamp to the shared memory;
The synchronization module 603 is configured to set a timestamp synchronization completion flag to the shared memory, where the timestamp synchronization completion flag is configured to instruct the firmware to obtain, from the shared memory, a second value stored in the application program and a first local timestamp when it is determined that the timestamp synchronization completion flag exists in the shared memory, and obtain the second local timestamp based on the first value, the second value, and the first local timestamp, where the first value is a first value recorded by a system counter and counted from a clock cycle of system start.
The various modules in the above cross-run level timestamp synchronization apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 7. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The Communication interface of the computer device, such as a network interface card, is used to perform wired or wireless Communication with an external terminal, where the wireless Communication may be implemented through WIFI, a mobile cellular network, near Field Communication (NFC) or other technologies. The computer program, when executed by a processor, implements a method of timestamp synchronization across run levels. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 7 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an exemplary embodiment, a chip is provided, comprising a memory storing a computer program and a processor implementing the steps of the method of any of the embodiments described above when the processor executes the computer program.
In one exemplary embodiment, a network interface card is provided, including a chip and a plurality of interfaces as in any of the embodiments above, through which the chip processes data or communicates externally.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile memory and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (RESISTIVE RANDOM ACCESS MEMORY, reRAM), magneto-resistive Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computation, an artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) processor, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the present application.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.
Claims (13)
1. A method of cross-run level timestamp synchronization, applied to firmware, the method comprising:
Acquiring a first value recorded by a system counter and counted by clock cycles started by a system, wherein firmware and application programs running at different running levels use the same system counter;
under the condition that a timestamp synchronization completion mark exists in a shared memory, acquiring a second value and a first local timestamp stored by the application program from the shared memory;
a second local timestamp is derived based on the first value, the second value, and the first local timestamp.
2. The method of claim 1, wherein the deriving a second local timestamp based on the first value, the second value, and the first local timestamp comprises:
Determining a number of seconds of system operation since timestamp synchronization based on the first value, the second value, and a frequency of the system counter;
converting the first local timestamp to a second of a first coordinated universal time;
Obtaining the second number of seconds of the second coordinated universal time based on the second number of seconds of the first coordinated universal time and the second number of seconds of the system operation since the time stamp synchronization;
a second local timestamp is obtained based on the second coordinated universal time seconds.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
And storing the second local timestamp to an output log.
4. The method according to claim 1 or 2, characterized in that the method further comprises:
converting the first value into seconds and nanoseconds when the timestamp synchronization completion flag does not exist in the shared memory;
The seconds and nanoseconds are stored to an output log.
5. The method according to claim 1 or 2, wherein the second value in the shared memory is the value of the system counter read by the application program, the first local timestamp in the shared memory is obtained by converting the application program based on a timestamp of a coordinated universal time of a system, and the timestamp synchronization completion flag in the shared memory is set in the shared memory after the second value and the first local timestamp are stored in the shared memory.
6. A method of cross-run level timestamp synchronization, for application to an application, the method further comprising:
Acquiring a second value recorded by a system counter and counted by a clock cycle started by a system, and writing the second value into a shared memory, wherein the same system counter is used by firmware and application programs running at different running levels;
Acquiring a time stamp of coordinated universal time of a system, converting the time stamp of coordinated universal time into a first local time stamp, and storing the first local time stamp into the shared memory;
Setting a time stamp synchronization completion flag to the shared memory, wherein the time stamp synchronization completion flag is used for indicating that the firmware obtains a second value and a first local time stamp stored by the application program from the shared memory under the condition that the existence of the time stamp synchronization completion flag in the shared memory is determined, and obtaining the second local time stamp based on the first value, the second value and the first local time stamp, wherein the first value is a first value recorded by a system counter and counted from a clock cycle started by the system.
7. A cross-run level timestamp synchronization apparatus, the apparatus comprising:
the first value acquisition module is used for acquiring a first value of clock cycle count which is recorded by a system counter and started by a system, and firmware and application programs running at different running levels use the same system counter;
the reading module is used for acquiring a second value and a first local timestamp stored by the application program from the shared memory under the condition that a timestamp synchronization completion mark exists in the shared memory;
And the second local timestamp generation module is used for obtaining a second local timestamp based on the first value, the second value and the first local timestamp.
8. A cross-run level timestamp synchronization apparatus for application to an application, the apparatus further comprising:
The second value acquisition module is used for acquiring a second value recorded by the system counter and counted by a clock cycle started by the system, writing the second value into the shared memory, and using the same system counter by firmware and application programs running at different running levels;
The storage module is used for acquiring the time stamp of the coordinated universal time of the system, converting the time stamp of the coordinated universal time into a first local time stamp and storing the first local time stamp into the shared memory;
The system comprises a shared memory, a synchronization module, a system counter and a time stamp synchronization completion flag, wherein the shared memory is used for storing a first local time stamp and a second value stored by the application program, the synchronization module is used for setting the time stamp synchronization completion flag to the shared memory, the time stamp synchronization completion flag is used for indicating the firmware to acquire the second value and the first local time stamp stored by the application program from the shared memory under the condition that the time stamp synchronization completion flag exists in the shared memory, the second local time stamp is acquired based on the first value, the second value and the first local time stamp, and the first value is a first value recorded by the system counter and counted by the clock cycle started by the system.
9. A chip comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
10. A network interface card comprising a chip and a plurality of interfaces as claimed in claim 9,
The chip processes data or communicates with the outside through the interface.
11. A computer device comprising the network interface card of claim 10 for processing data or communicating externally.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
13. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202511715579.4A CN121193362A (en) | 2025-11-21 | 2025-11-21 | Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202511715579.4A CN121193362A (en) | 2025-11-21 | 2025-11-21 | Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN121193362A true CN121193362A (en) | 2025-12-23 |
Family
ID=98087954
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202511715579.4A Pending CN121193362A (en) | 2025-11-21 | 2025-11-21 | Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN121193362A (en) |
Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20020039370A1 (en) * | 2000-04-20 | 2002-04-04 | Mark Elliot | Precise network time transfer |
| US20050180429A1 (en) * | 1999-02-23 | 2005-08-18 | Charlie Ghahremani | Multi-service network switch with independent protocol stack architecture |
| CN101904205A (en) * | 2007-12-20 | 2010-12-01 | 高通股份有限公司 | UMB cell site modem architecture and methods |
| CN102346687A (en) * | 2011-09-21 | 2012-02-08 | 南京航空航天大学 | Real-time system based on Windows driver |
| EP4092532A1 (en) * | 2021-05-17 | 2022-11-23 | Bayerische Motoren Werke Aktiengesellschaft | Generating a timestamp at a control unit |
| CN119884000A (en) * | 2024-12-31 | 2025-04-25 | 亿咖通(湖北)技术有限公司 | Cross-domain time synchronization system, method and electronic medium |
| CN119966561A (en) * | 2025-01-15 | 2025-05-09 | 南方电网数字电网科技(广东)有限公司 | Time synchronization method, device, electronic equipment and medium based on multi-channel timing signal |
| CN120658338A (en) * | 2025-05-26 | 2025-09-16 | 阿波罗智能技术(北京)有限公司 | Time synchronization method and device and time synchronization system of intelligent driving system |
| US20250317233A1 (en) * | 2022-12-22 | 2025-10-09 | Huawei Technologies Co., Ltd. | Clock synchronization method, apparatus, chip, chip module, system, and storage medium |
-
2025
- 2025-11-21 CN CN202511715579.4A patent/CN121193362A/en active Pending
Patent Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20050180429A1 (en) * | 1999-02-23 | 2005-08-18 | Charlie Ghahremani | Multi-service network switch with independent protocol stack architecture |
| US20020039370A1 (en) * | 2000-04-20 | 2002-04-04 | Mark Elliot | Precise network time transfer |
| CN101904205A (en) * | 2007-12-20 | 2010-12-01 | 高通股份有限公司 | UMB cell site modem architecture and methods |
| CN102346687A (en) * | 2011-09-21 | 2012-02-08 | 南京航空航天大学 | Real-time system based on Windows driver |
| EP4092532A1 (en) * | 2021-05-17 | 2022-11-23 | Bayerische Motoren Werke Aktiengesellschaft | Generating a timestamp at a control unit |
| US20250317233A1 (en) * | 2022-12-22 | 2025-10-09 | Huawei Technologies Co., Ltd. | Clock synchronization method, apparatus, chip, chip module, system, and storage medium |
| CN119884000A (en) * | 2024-12-31 | 2025-04-25 | 亿咖通(湖北)技术有限公司 | Cross-domain time synchronization system, method and electronic medium |
| CN119966561A (en) * | 2025-01-15 | 2025-05-09 | 南方电网数字电网科技(广东)有限公司 | Time synchronization method, device, electronic equipment and medium based on multi-channel timing signal |
| CN120658338A (en) * | 2025-05-26 | 2025-09-16 | 阿波罗智能技术(北京)有限公司 | Time synchronization method and device and time synchronization system of intelligent driving system |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN102982085B (en) | Data mover system and method | |
| CN101937721A (en) | Method for testing memory device | |
| CN114245892A (en) | Data race analysis based on altering function internal loading during time travel debugging | |
| CN111158999A (en) | Method and device for calculating formatting time | |
| CN102736957A (en) | Resetting method and device | |
| CN121193362A (en) | Cross-run-level timestamp synchronization method, apparatus, chip, network interface card, device, medium, and program product | |
| CN104636271B (en) | The data stored in visit order/address register device | |
| CN117785281A (en) | Method for transplanting NFC function based on operating system | |
| CN117056059B (en) | Timer realizing method and device, storage medium and electronic equipment | |
| CN116541336B (en) | Software running method of multi-core chip and coprocessor | |
| CN115599402A (en) | Mirror image packaging method and device and electronic equipment | |
| CN101964845B (en) | Method and device for recovering terminal operation | |
| CN116226145A (en) | Data interaction method, device, computer equipment and storage medium | |
| CN116938380B (en) | Time stamp management method, device, computer equipment, time stamp manager | |
| CN117200922A (en) | Time synchronization method, device, computer equipment and storage medium | |
| CN112364382A (en) | Credible time domain determination method of business record based on credible account book database | |
| CN115543853B (en) | Mobile terminal native SDK debugging method and system | |
| CN111078714A (en) | Data processing method and device | |
| CN112364010B (en) | Method and device for verifying existence of important business record | |
| CN117472772A (en) | Test methods and devices, equipment, storage media | |
| HK40034910A (en) | Transaction storage method based on centralized blockchain type account book | |
| CN117215946A (en) | Account following test result comparison method and device, processor and storage medium | |
| CN119828972A (en) | Disk self-management method, data writing method and data reading method | |
| CN119759533A (en) | A multi-source fusion acquisition method and device based on LINUX and RTOS | |
| CN119580806A (en) | Storage device testing method, device and equipment, storage medium, and program product |
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 |