Relative timestamp generation method, embedded system, electronic device and storage medium
By introducing a time difference transmission interface into the microcontroller, determining the target timestamp and calculating the relative timestamp, the logical judgment abnormality caused by timestamp overflow is solved, and the logical efficiency of the application layer's time judgment is improved.
Patent Information
- Application Number
- CN202210607735.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-05-31
AI Technical Summary
In microcontrollers, due to the limited storage range of timestamps, timestamp overflow is prone to occur, resulting in abnormal logical judgments of the application layer when calculating the time difference.
The time difference acquisition request of the application layer is received through the time difference transmission interface, and the two target timestamps are determined based on the interface type and timestamp identification, the relative timestamp is calculated, and it is returned to the application layer.
This avoids the application layer directly obtains the timestamp from the system layer for time difference calculation, and the logical judgment abnormality caused by the timestamp overflow is improved, and the efficiency of the application layer's execution time judgment logic is improved.
Smart Images

Figure CN115033219B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development, and in particular to a relative timestamp generation method, an embedded system, an electronic device and a storage medium. Background Art
[0002] In the operating system, the application layer often needs to obtain the relative timestamp between two timestamps, that is, the time difference, when performing some logical judgments. Currently, when the application layer obtains the relative timestamp, it can obtain the required two timestamps through the timestamp interface provided by the system layer and calculate the time difference based on the two timestamps.
[0003] In a single-chip microcomputer, the system layer usually uses a 32-bit unsigned variable to store timestamps. The range of the stored timestamps is limited, and there is a timestamp overflow phenomenon. When the stored timestamp overflows, since the application layer calculates the time difference in a different way, it is easy to cause logical judgment abnormalities due to the timestamp overflow.
[0004] Therefore, how to avoid logical judgment anomalies caused by timestamp overflow at the application layer has become an urgent problem that needs to be solved. Summary of the invention
[0005] The present application provides a relative timestamp generation method, an embedded system, an electronic device and a storage medium. By determining two target timestamps based on the interface type of a time difference transmission interface and at least one timestamp identifier, and calculating the time difference based on the two timestamps, the relative timestamp can be returned to the application layer through the time difference transmission interface, thereby solving the problem that the application layer directly obtains the timestamp from the system layer to calculate the time difference, which causes abnormal logic judgment due to timestamp overflow.
[0006] In a first aspect, the present application provides a relative timestamp generation method, the method comprising:
[0007] Receiving a time difference acquisition request sent by the application layer through a time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier;
[0008] Determine two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp;
[0009] Calculate the time difference between the two target timestamps to obtain a relative timestamp;
[0010] The relative timestamp is returned to the application layer through the time difference transmission interface, so that the application layer executes a preset duration judgment logic based on the relative timestamp.
[0011] In a second aspect, the present application further provides an embedded system, the embedded system comprising a system layer and an application layer;
[0012] The system layer provides a time difference transmission interface to the application layer;
[0013] The system layer receives the time difference acquisition request sent by the application layer through the time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier;
[0014] The system layer determines two target timestamps based on the type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp;
[0015] The system layer calculates the time difference according to the two target timestamps to obtain a relative timestamp;
[0016] The system layer returns the relative timestamp to the application layer through the time difference transmission interface;
[0017] The application layer executes a preset duration determination logic based on the relative timestamp.
[0018] In a third aspect, the present application further provides an electronic device, the electronic device comprising a memory and a processor;
[0019] The memory is used to store computer programs;
[0020] The processor is used to execute the computer program and implement the relative timestamp generation method as described above when executing the computer program, or load the embedded system as described above.
[0021] In a fourth aspect, the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the relative timestamp generation method as described above, or loads the embedded system as described above.
[0022] The present application discloses a relative timestamp generation method, an embedded system, an electronic device and a storage medium. The method receives a time difference acquisition request sent by an application layer through a time difference transmission interface, and determines two target timestamps based on the interface type of the time difference transmission interface and at least one timestamp identifier carried in the time difference acquisition request. The method allows the application layer to acquire the relative timestamp through the time difference transmission interface, thereby avoiding the application layer from directly acquiring the timestamp from the system layer through the existing timestamp interface. The method calculates the time difference according to the two target timestamps, and returns the obtained relative timestamp to the application layer through the time difference transmission interface, so that the application layer executes a preset duration judgment logic based on the relative timestamp. The method implements the method that the application layer does not need to perform the time difference calculation according to the timestamp, and can directly use the received relative timestamp to execute the duration judgment logic, thereby avoiding the problem that when the timestamp overflows, the application layer causes abnormal logic judgment due to the inconsistent timestamp calculation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 is a schematic flow chart of a relative timestamp generation method provided in an embodiment of the present application;
[0025] Figure 2 is a schematic diagram of a timestamp array provided in an embodiment of the present application;
[0026] Figure 3 It is a schematic flowchart of the sub-steps of applying for a timestamp cache area provided in an embodiment of the present application;
[0027] Figure 4 It is a schematic diagram of an application timestamp buffer area provided in an embodiment of the present application;
[0028] Figure 5 It is a schematic flowchart of another sub-step of applying for a timestamp cache area provided in an embodiment of the present application;
[0029] Figure 6 It is a schematic diagram of a refresh timestamp buffer area provided in an embodiment of the present application;
[0030] Figure 7 is a schematic flowchart of sub-steps of determining a target timestamp provided in an embodiment of the present application;
[0031] Figure 8is a schematic flowchart of another sub-step of determining a target timestamp provided in an embodiment of the present application;
[0032] Fig. 9 This is a schematic diagram of obtaining a relative timestamp provided in an embodiment of the present application;
[0033] Fig.10 is another schematic diagram of obtaining a relative timestamp provided in an embodiment of the present application;
[0034] Fig.11 It is a schematic diagram of a release timestamp buffer area provided in an embodiment of the present application;
[0035] Fig.12 is a schematic diagram of an embedded system provided by an embodiment of the present application;
[0036] Fig.13 This is a schematic diagram of the interaction between the application layer and the system layer provided in an embodiment of the present application;
[0037] Fig.14 It is a schematic block diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0039] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0040] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0041] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0042] The embodiment of the present application provides a relative timestamp generation method, an embedded system, an electronic device and a storage medium. Among them, the electronic device is installed with an embedded system, and the embedded system includes a system layer and an application layer. The relative timestamp generation method can be applied to the embedded system, by determining two target timestamps based on the interface type of the time difference transmission interface and at least one timestamp identifier, and performing time difference calculation based on the two timestamps, it is possible to return the relative timestamp to the application layer through the time difference transmission interface, thereby solving the problem that the application layer directly obtains the timestamp from the system layer for time difference calculation, and the logic judgment is abnormal due to the timestamp overflow.
[0043] It should be noted that an embedded system is a dedicated computer system installed inside an electronic device and designed for a specific application. The system layer refers to the operating system in the embedded system, which may include but is not limited to the system interface and the driver interface; the application layer refers to the application that implements specific functions through the system interface and the driver interface.
[0044] Exemplarily, the electronic device can be a server or a terminal. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal can be an electronic device such as a smartphone, tablet computer, laptop computer, and desktop computer.
[0045] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0046] like Figure 1 As shown, the relative timestamp generation method includes steps S10 to S40.
[0047] Step S10: receiving a time difference acquisition request sent by the application layer through a time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier.
[0048] It should be noted that in the prior art, the application layer usually directly obtains two timestamps through the timestamp interface provided by the system layer, then calculates the relative timestamp based on the two timestamps, and executes the duration judgment logic based on the relative timestamp. However, when the timestamp overflows, since different applications in the application layer calculate the time difference in a different way, the problem of abnormal logic judgment is caused by the timestamp overflow. In the embodiment of the present application, the system layer does not provide a timestamp interface to the application layer, but provides a time difference transmission interface to the application layer. The application layer can obtain the relative timestamp through the time difference transmission interface, thereby solving the problem that the application layer directly obtains the timestamp from the system layer to calculate the time difference, and the problem of abnormal logic judgment is caused by the timestamp overflow.
[0049] See also Figure 2 , Figure 2 is a schematic diagram of a timestamp array provided in an embodiment of the present application. Figure 2 As shown, the system layer can define two one-dimensional arrays, for example, a first array and a second array; each element in the first array represents a timestamp, which is stored in a timestamp buffer. The timestamp buffer where each timestamp is located can be used as a timestamp identifier, and the timestamp identifier can be the number or name of the timestamp buffer, or the base address of the timestamp buffer plus the cache size, etc. The elements in the second array are used to represent the allocation status corresponding to the timestamp buffer in the first array, where the allocation status can be unallocated / allocated. Exemplarily, when the timestamp buffer of an element in the first array is allocated to the application layer, the allocation status corresponding to the timestamp buffer in the second array is marked as allocated. The array sizes of the first array and the second array are the same, but the bit widths can be different. For example, each array has a length of 32 and has 32 elements. The bit width of each element in the first timestamp array can be 32 bits, which is the bit width of a normal timestamp, and the bit width of each element in the second timestamp array can be 8 bits. Of course, a two-dimensional array can also be defined to represent the timestamp and the allocation status of the corresponding timestamp buffer, and the two-dimensional array is actually a combination of the first array and the second array.
[0050] It should be noted that in the embodiment of the present application, when the application layer needs to use a relative timestamp to perform duration judgment logic, it is necessary to initiate a time difference acquisition request to the system layer through the time difference transmission interface based on a pre-assigned timestamp identifier. The system layer determines the two target timestamps based on the timestamp identifier sent by the application layer and the type of the time difference transmission interface, and then calculates the relative timestamp based on the two timestamps, and returns the relative timestamp to the application layer through the time difference transmission interface.
[0051] In some embodiments, a time difference acquisition request sent by an application layer is received through a time difference transmission interface, and the time difference acquisition request carries at least one timestamp identifier.
[0052] It should be noted that, in the embodiment of the present application, the system layer provides a time difference transmission interface to the application layer, so that the application layer requests a relative timestamp from the system layer through the time difference transmission interface.
[0053] Exemplarily, when a time difference acquisition request sent by the application layer is received through the time difference transmission interface, at least one timestamp identifier carried in the time difference acquisition request can be extracted; then, two target timestamps can be determined based on the time difference transmission interface and at least one timestamp, and then the time difference can be calculated based on the two target timestamps to obtain a relative timestamp.
[0054] The time difference transmission interface receives the time difference acquisition request sent by the application layer, and subsequently determines the target timestamp according to at least one timestamp identifier carried in the time difference acquisition request, thereby avoiding the application layer directly obtaining the timestamp from the system layer through the existing timestamp interface.
[0055] It should be noted that before the application layer obtains the relative timestamp through the timestamp identifier, the application layer also needs to apply for a timestamp cache and refresh the applied timestamp cache to record the current timestamp corresponding to the current moment in the timestamp cache. In the embodiment of the present application, how to apply for a timestamp cache and refresh the timestamp cache will be described in detail.
[0056] See also Figure 3 , Figure 3 It is a schematic flowchart of the sub-steps of applying for a timestamp cache area provided in an embodiment of the present application, which may specifically include the following steps S101 to S104.
[0057] Step S101: when a timestamp application request sent by the application layer is received through a timestamp application interface, query the allocation status of each timestamp buffer area.
[0058] In an embodiment of the present application, the system layer provides a timestamp application interface to the application layer, and the application layer can apply to the system layer for a timestamp cache area for storing timestamps through the timestamp application interface; the system layer sends the timestamp identifier of the allocated timestamp cache area to the application layer so that the application layer can send the timestamp identifier to the system layer when obtaining the relative timestamp, so that the system layer determines the target timestamp cache area according to the timestamp identifier, and then obtains the timestamp stored in the target timestamp cache area as the target timestamp.
[0059] In some embodiments, when a timestamp application request sent by the application layer is received through the timestamp application interface, the allocation status of each timestamp buffer area is queried.
[0060] Exemplarily, the allocation status of each timestamp buffer area is queried, and the available timestamp buffer area can be determined according to the allocation status of each timestamp buffer area. For example, a timestamp buffer area with an allocation status of unallocated is determined as an available timestamp buffer area. The available timestamp buffer area can be subsequently allocated to the application layer for use. It should be noted that a timestamp buffer area with an allocation status of allocated indicates that the timestamp identifier of the timestamp buffer area has been allocated to the application layer, and the application layer can use the corresponding timestamp buffer area according to the timestamp identifier; a timestamp buffer area with an allocation status of unallocated indicates that the timestamp identifier of the timestamp buffer area has not been allocated to the application layer.
[0061] Exemplarily, the application layer may apply for at least one timestamp buffer area through a timestamp application interface.
[0062] For example, when the application layer applies for a timestamp buffer, it can call the timestamp application interface once to obtain a timestamp identifier corresponding to the timestamp buffer. When the application layer needs to obtain a relative timestamp, it can send the timestamp identifier corresponding to the timestamp buffer to the system layer; the system layer can use the timestamp stored in the target timestamp buffer as the first timestamp, and the current timestamp corresponding to the current moment as the second timestamp, and then use the first timestamp and the second timestamp as two target timestamps.
[0063] For another example, when the application layer applies for multiple timestamp buffers, it can call the timestamp application interface multiple times to obtain timestamp identifiers corresponding to multiple timestamp buffers. When it is necessary to obtain a relative timestamp, the start timestamp identifier and the end timestamp identifier can be sent to the system layer; the system layer can determine the start timestamp buffer and the end timestamp buffer according to the start timestamp identifier and the end timestamp identifier, and then use the timestamps stored in the start timestamp buffer and the end timestamp buffer as two target timestamps.
[0064] Step S102: Determine any timestamp buffer area whose allocation status is unallocated as a timestamp buffer area to be allocated.
[0065] Exemplarily, any timestamp buffer area whose allocation status is unallocated can be determined as a timestamp buffer area to be allocated.
[0066] Step S103: Send the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface.
[0067] Exemplarily, after determining the timestamp buffer area to be allocated, the timestamp identifier corresponding to the timestamp buffer area to be allocated can be sent to the application layer through the timestamp application interface, so that the application layer can refresh the timestamp or obtain a relative timestamp according to the timestamp identifier.
[0068] Step S104: Mark the allocation status of the to-be-allocated timestamp buffer area as allocated.
[0069] Exemplarily, after the timestamp identifier is sent to the application layer, the allocation status of the timestamp buffer area to be allocated can be marked as allocated. Of course, after the timestamp buffer area to be allocated is determined, the allocation status of the timestamp buffer area to be allocated can be marked as allocated.
[0070] See also Figure 4 , Figure 4 Schematic diagram of an application timestamp buffer provided in an embodiment of the present application. Figure 4 As shown, the application layer can send a timestamp application request to the system layer through the timestamp application interface to apply for a timestamp buffer area. The system layer queries the allocation status of each timestamp buffer area according to the timestamp application request, and determines one of the timestamp buffer areas with an allocation status of unallocated as the timestamp buffer area to be allocated, for example, determining timestamp buffer area 1 as the timestamp buffer area to be allocated. Then, the system layer marks the allocation status of the timestamp buffer area to be allocated as allocated. Finally, the system layer sends the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface.
[0071] See also Figure 5 , Figure 5 It is a schematic flowchart of another sub-step of applying for a timestamp cache area provided in an embodiment of the present application, which may specifically include the following steps S105 to S108.
[0072] Step S105: When a timestamp application request sent by the application layer is received through the timestamp application interface, the allocation status of each timestamp buffer area is queried.
[0073] Step S106: Determine any timestamp buffer area whose allocation state is unallocated as a timestamp buffer area to be allocated, and store the timestamp corresponding to the current moment in the timestamp buffer area to be allocated.
[0074] Exemplarily, after the timestamp buffer area to be allocated is determined, the timestamp corresponding to the current moment may be stored in the timestamp buffer area to be allocated.
[0075] It should be noted that in an embodiment of the present application, after determining the timestamp buffer area to be allocated, the timestamp corresponding to the current moment may be stored in the timestamp buffer area to be allocated, or the timestamp corresponding to the current moment may not be stored in the timestamp buffer area to be allocated.
[0076] It is understandable that if the timestamp corresponding to the current moment is not stored in the timestamp buffer to be allocated, and the timestamp buffer to be allocated is blank, the application layer needs to refresh the timestamp buffer before obtaining the relative timestamp so that the timestamp buffer stores the timestamp. If the timestamp corresponding to the current moment is stored in the timestamp buffer to be allocated, the application layer may not refresh the timestamp buffer before obtaining the relative timestamp. Of course, the application layer may also refresh the timestamp buffer according to actual needs to update the original timestamp stored in the timestamp buffer.
[0077] Step S107: Send the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface.
[0078] Exemplarily, after determining the timestamp buffer area to be allocated, the timestamp identifier corresponding to the timestamp buffer area to be allocated can be sent to the application layer through the timestamp application interface, so that the application layer can refresh the timestamp or obtain a relative timestamp according to the timestamp identifier.
[0079] Step S108: Mark the allocation status of the to-be-allocated timestamp buffer area as allocated.
[0080] Exemplarily, after the timestamp identifier is sent to the application layer, the allocation status of the timestamp buffer area to be allocated can be marked as allocated. Of course, after the timestamp buffer area to be allocated is determined, the allocation status of the timestamp buffer area to be allocated can be marked as allocated.
[0081] When a timestamp application request is received from the application layer through the timestamp application interface, the timestamp buffer area to be allocated is determined, and the timestamp identifier corresponding to the timestamp buffer area to be allocated is sent to the application layer through the timestamp application interface, so that the application layer can refresh the timestamp or obtain a relative timestamp according to the timestamp identifier when necessary.
[0082] In some embodiments, before receiving a time difference acquisition request sent by the application layer through a time difference transmission interface, an embodiment of the present application may also include: receiving a timestamp refresh request sent by the application layer through a timestamp refresh interface, the timestamp refresh request carrying a target timestamp identifier; and recording the current timestamp in a timestamp cache area corresponding to the target timestamp identifier.
[0083] It should be noted that the system layer provides a timestamp refresh interface to the application layer, and the application layer can refresh the timestamp buffer area through the timestamp refresh interface.
[0084] It is understood that in the embodiment of the present application, refreshing refers to the operation of recording the current timestamp in the corresponding timestamp buffer area, and the current timestamp is the timestamp of the current moment. For example, when the timestamp buffer area does not store a timestamp, the current timestamp can be recorded in the timestamp buffer area through a refresh operation. For another example, when the timestamp buffer area stores a timestamp, the timestamp stored in the timestamp buffer area can be updated to the current timestamp through a refresh operation.
[0085] For example, when the application layer performs the duration judgment logic, it can record the timestamps corresponding to different moments into the corresponding timestamp cache area through a refresh operation according to actual needs.
[0086] See also Figure 6 , Figure 6 Schematic diagram of a refresh timestamp buffer provided by an embodiment of the present application. Figure 6 As shown, the application layer can send a timestamp refresh request to the system layer through the timestamp refresh interface to refresh the timestamp cache area, and the target timestamp identifier carried in the timestamp refresh request is the timestamp identifier corresponding to the timestamp cache area to be refreshed. The system layer records the current timestamp in the timestamp cache area corresponding to the timestamp identifier carried in the timestamp refresh request. For example, if the timestamp cache area corresponding to the timestamp identifier carried in the timestamp refresh request is timestamp cache area 1, the current timestamp is recorded in timestamp cache area 1.
[0087] In some embodiments, when the application layer needs to obtain the relative timestamp execution duration judgment logic between moment A and moment B, the application layer can send a first timestamp refresh request to the system layer through the timestamp refresh interface at moment A, wherein the first timestamp refresh request carries the target timestamp identifier a; the system layer can record the timestamp of moment A in the timestamp cache area corresponding to the target timestamp identifier a. Then, the application layer can send a second timestamp refresh request to the system layer through the timestamp refresh interface at moment B, wherein the second timestamp refresh request carries the target timestamp identifier b; the system layer can record the timestamp of moment B in the timestamp cache area corresponding to the target timestamp identifier b. Among them, when the target timestamp identifier a is different from the target timestamp identifier b, the timestamp cache area corresponding to the target timestamp identifier a and the timestamp cache area corresponding to the target timestamp identifier b are different timestamp cache areas.
[0088] Of course, the target timestamp identifier a and the target timestamp identifier b may also be the same identifier. For example, after the application layer requests the system layer to record the timestamp of time A, if the timestamp of time A needs to be discarded, the application layer may send a timestamp refresh request to the system layer using the same timestamp identifier as the last time, so that the system layer updates the timestamp of the last record in the timestamp cache area corresponding to the timestamp identifier.
[0089] When a timestamp refresh request carrying a target timestamp identifier is received from the application layer through the timestamp refresh interface, the current timestamp is recorded in the timestamp buffer corresponding to the target timestamp identifier, so that the timestamp required for the application layer to execute the duration judgment logic can be recorded in the timestamp buffer.
[0090] Step S20: determining two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp.
[0091] It should be noted that the time difference transmission interface provided by the system layer to the application layer can have two types of interface types, including real-time interface and non-real-time interface. Among them, the time difference transmission interface with the interface type of real-time interface is used to obtain the relative timestamp between the timestamp in the timestamp buffer corresponding to a timestamp identifier and the current timestamp corresponding to the current moment; the time difference transmission interface with the interface type of non-real-time interface is used to obtain the relative timestamp between the timestamps in the timestamp buffer corresponding to two timestamp identifiers. The time difference acquisition request received by the system layer through the time difference transmission interface with the interface type of real-time interface only carries one timestamp identifier, and the time difference acquisition request received through the time difference transmission interface with the interface type of non-real-time interface carries two timestamp identifiers. By determining two target timestamps based on the interface type of the time difference transmission interface and at least one timestamp identifier, it is possible to flexibly and accurately determine the target timestamps in different application scenarios.
[0092] In the embodiments of the present application, how to determine the target timestamp will be described in detail.
[0093] See also Figure 7 , Figure 7 It is a schematic flowchart of sub-steps for determining two target timestamps provided in an embodiment of the present application, which may specifically include the following steps S201 to S204.
[0094] Step S201: Determine, among multiple timestamp buffers, a timestamp buffer corresponding to the first timestamp identifier as a target timestamp buffer.
[0095] Exemplarily, the time difference acquisition request carries a timestamp identifier, which is the first timestamp identifier. It should be noted that when the application layer needs to use the timestamp in the timestamp cache corresponding to the first timestamp identifier, the first timestamp identifier can be added to the timestamp acquisition request when generating the time difference acquisition request.
[0096] It should be noted that, among the multiple timestamp buffer areas defined, the timestamp identifier can be the number or name of the timestamp buffer area, or the base address of the timestamp buffer area plus the cache size, etc. Therefore, the timestamp buffer area corresponding to the first timestamp identifier can be directly determined as the target timestamp buffer area based on the first timestamp identifier.
[0097] Step S202: Use the timestamp stored in the target timestamp buffer as a first timestamp.
[0098] Exemplarily, the timestamp stored in the target timestamp buffer area may be directly used as the first timestamp. For example, if the timestamp stored in the target timestamp buffer area is A1, then the first timestamp may be determined to be A1.
[0099] It should be noted that the timestamp stored in the target timestamp buffer can be the timestamp recorded in the target timestamp buffer by the system layer during the process of the application layer applying for the timestamp buffer from the system layer. The timestamp stored in the target timestamp buffer can also be the timestamp recorded in the target timestamp buffer by the system layer during the process of the application layer applying for a refresh timestamp from the system layer.
[0100] Step S203: When the interface type of the time difference transmission interface is a real-time interface, a current timestamp corresponding to the current moment is used as a second timestamp.
[0101] Exemplarily, if the current timestamp corresponding to the current moment is B1, the current timestamp B1 may be used as the second timestamp.
[0102] Step S204: Use the first timestamp and the second timestamp as the two target timestamps.
[0103] Exemplarily, the first timestamp and the second timestamp may be used as two target timestamps.
[0104] See also Figure 8 , Figure 8 It is a schematic flowchart of another sub-step of determining two target timestamps provided in an embodiment of the present application, which may specifically include the following steps S205 to S207.
[0105] Step S205: Among multiple timestamp buffer areas, determine the timestamp buffer area corresponding to the start timestamp identifier as the start timestamp buffer area.
[0106] Exemplarily, the time difference acquisition request carries two timestamp identifiers, namely a start timestamp identifier and an end timestamp identifier. Exemplarily, if the start timestamp identifier is 2, then timestamp buffer area 2 may be determined as the start timestamp buffer area.
[0107] Step S206: Among the multiple timestamp buffer areas, determine the timestamp buffer area corresponding to the end timestamp identifier as the end timestamp buffer area.
[0108] Exemplarily, if the start timestamp identifier is 4, then timestamp buffer area 4 may be determined as the end timestamp buffer area.
[0109] Step S207: When the interface type of the time difference transmission interface is a non-real-time interface, the timestamps stored in the start timestamp buffer area and the end timestamp buffer area are used as the two target timestamps.
[0110] For example, if the timestamp stored in the start timestamp buffer is A2, and the timestamp stored in the end timestamp buffer is B2, then the timestamp A2 and the timestamp B2 may be determined as the target timestamp.
[0111] Step S30: Calculate the time difference between the two target timestamps to obtain a relative timestamp.
[0112] In an embodiment of the present application, the system layer calculates the time difference based on the two target timestamps to obtain a relative timestamp. In the prior art, the two target timestamps are returned to the application layer, and the application layer calculates the time difference based on the two target timestamps to obtain a relative timestamp. Since the application layer needs to make multiple judgments and calculations when calculating the time difference, the efficiency of the application layer's execution duration judgment logic is reduced. In addition, different applications in the application layer do not use a unified method to calculate the time difference, which can easily lead to logical judgment anomalies due to timestamp overflow. The embodiment of the present application calculates the time difference based on the two target timestamps, which not only improves the efficiency of the application layer's execution duration judgment logic, but also solves the problem that the application layer directly obtains the timestamp from the system layer to calculate the time difference, which leads to logical judgment anomalies due to timestamp overflow.
[0113] Exemplarily, for target timestamps A and B, the time difference between target timestamp B and target timestamp A can be determined as a relative timestamp. Wherein, target timestamp A is the first timestamp in the above step S202, and target timestamp B is the second timestamp in the above step S203. The relative timestamp Δt can be obtained by the following formula:
[0114] Δt=B–A
[0115] It should be noted that when the timestamp does not overflow, that is, B≥A, then the relative timestamp Δt=B–A. When the timestamp overflows, that is, B<A, then the relative timestamp Δt=B–A. That is, when the timestamp overflows, the above calculation formula still applies.
[0116] It can be understood that when the timestamp overflows, Δt = overflow value –A + B + 1, where the overflow value of the timestamp is 0xFFFFFFFF when a 32-bit unsigned variable is used to store the timestamp. Since the overflow value = (~A) + A, we can get Δt = (~A) + B + 1, where (~A) represents the bitwise inversion of A. According to the principle of complement, (~A) + 1 = –A, we can get Δt = (~A) + B + 1 = B – A. Therefore, no matter what the size relationship between timestamps A and B is, that is, no matter whether the timestamp overflows, the formula Δt = B – A can be used to calculate the relative timestamp.
[0117] Based on the principle of computer complement, the time difference between the two target timestamps is calculated at the system layer and then provided to the application layer. This can avoid multiple judgments and calculations, effectively improve the calculation efficiency of the relative timestamp, and thus improve the efficiency of the application layer's execution time judgment logic.
[0118] Step S40: Return the relative timestamp to the application layer through the time difference transmission interface, so that the application layer executes a preset duration judgment logic based on the relative timestamp.
[0119] Exemplarily, after calculating the time difference based on the two target timestamps to obtain the relative timestamp, the relative timestamp can be returned to the application layer through the time difference transmission interface, so that the application layer can execute the preset duration judgment logic based on the relative timestamp. The duration judgment logic executed by the application layer is not limited here.
[0120] By returning the obtained relative timestamp to the application layer through the time difference transmission interface, the application layer can execute the preset duration judgment logic based on the relative timestamp, so that the application layer does not need to calculate the time difference based on the timestamp, and can directly use the received relative timestamp to execute the duration judgment logic, avoiding the problem of logical judgment anomalies caused by inconsistent timestamp calculation methods in the application layer when the timestamp overflows.
[0121] See also Fig. 9 , Fig. 9 FIG. 1 is a schematic diagram of obtaining a relative timestamp provided in an embodiment of the present application. Fig. 9 As shown, the application layer can send a time difference acquisition request to the system layer through the time difference transmission interface to obtain a relative timestamp. The system layer determines the target timestamp buffer area, for example, timestamp buffer area 1, according to the first timestamp identifier in the time difference acquisition request; then, the timestamp stored in the target timestamp buffer area is used as the first timestamp, and the current timestamp corresponding to the current moment is used as the second timestamp, and the time difference is calculated based on the first timestamp and the second timestamp to obtain the relative timestamp; finally, the system layer returns the relative timestamp to the application layer through the time difference transmission interface.
[0122] See also Fig.10 , Fig.10 FIG. 1 is another schematic diagram of obtaining a relative timestamp provided in an embodiment of the present application. Fig.10 As shown, the application layer can send a time difference acquisition request to the system layer through the time difference transmission interface to obtain a relative timestamp. The system layer determines the starting timestamp buffer area, for example, timestamp buffer area 2, according to the starting timestamp identifier in the time difference acquisition request; and determines the ending timestamp buffer area, for example, timestamp buffer area 4, according to the ending timestamp identifier in the time difference acquisition request. Then, the time difference is calculated based on the timestamps stored in the starting timestamp buffer area and the ending timestamp buffer area to obtain a relative timestamp; finally, the system layer returns the relative timestamp to the application layer through the time difference transmission interface.
[0123] In some embodiments, the relative timestamp generation method provided by the embodiments of the present application may also include: receiving a timestamp release request from the application layer through a timestamp release interface; marking the allocation status of the timestamp cache area corresponding to the timestamp identifier carried in the timestamp release request as unallocated.
[0124] It should be noted that in the embodiment of the present application, the system layer provides a timestamp release interface to the application layer. After the application layer applies for a timestamp buffer, it can request the system layer to release the timestamp buffer obtained through the timestamp release interface. The application layer can add the timestamp identifier corresponding to the timestamp buffer to be released to the timestamp release request.
[0125] Exemplarily, after receiving the timestamp identifier corresponding to the timestamp buffer area to be allocated returned by the system layer, the application layer may send a timestamp release request to the system layer through the timestamp release interface.
[0126] Exemplarily, after receiving the relative timestamp returned by the system layer, the application layer may send a timestamp release request to the system layer through a timestamp release interface.
[0127] Exemplarily, when the system layer receives the timestamp release request from the application layer, it can mark the allocation state of the timestamp buffer corresponding to the timestamp identifier carried in the timestamp release request as unallocated, and can also clear the timestamp in the corresponding timestamp buffer. Of course, the timestamp in the corresponding timestamp buffer may not be cleared.
[0128] See also Fig.11 , Fig.11 Schematic diagram of a release timestamp buffer provided by an embodiment of the present application. Fig.11As shown, the application layer can send a timestamp release request to the system layer through the timestamp release interface. The system layer marks the allocation status of the timestamp buffer area corresponding to the timestamp identifier carried in the timestamp release request as unallocated, for example, marking the allocation status corresponding to timestamp buffer area 1 as unallocated.
[0129] By receiving the timestamp release request of the application layer through the timestamp release interface and marking the allocation status of the timestamp buffer area corresponding to the timestamp identifier carried in the timestamp release request as unallocated, it is possible to release redundant timestamp buffer areas according to the actual needs of the application layer to avoid occupying system resources.
[0130] The relative timestamp generation method provided in the above embodiment receives a time difference acquisition request sent by the application layer through a time difference transmission interface, and can subsequently determine the target timestamp according to at least one timestamp identifier carried in the time difference acquisition request, thereby avoiding the application layer directly obtaining the timestamp from the system layer through the existing timestamp interface; when receiving a timestamp application request sent by the application layer through the timestamp application interface, determines the timestamp buffer area to be allocated, and sends the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface, so that the application layer can refresh the timestamp or obtain the relative timestamp according to the timestamp identifier when necessary; when receiving a timestamp refresh request carrying the target timestamp identifier sent by the application layer through the timestamp refresh interface, the current timestamp is recorded in the target timestamp identifier In the timestamp buffer area corresponding to the identification, the timestamp required by the application layer for the duration judgment logic can be recorded in the timestamp buffer area; based on the principle of computer complement, the system layer calculates the time difference according to the two target timestamps and then provides it to the application layer, which can avoid multiple judgments and calculations, effectively improve the calculation efficiency of the relative timestamp, and thus improve the efficiency of the application layer for the duration judgment logic; by returning the obtained relative timestamp to the application layer through the time difference transmission interface, so that the application layer executes the preset duration judgment logic based on the relative timestamp, the application layer does not need to calculate the time difference according to the timestamp, and can directly use the received relative timestamp to execute the duration judgment logic, avoiding the problem of abnormal logic judgment caused by inconsistent timestamp calculation method when the timestamp overflows.
[0131] See also Fig.12 , Fig.12 1 is a schematic diagram of an embedded system 1000 provided in an embodiment of the present application. Fig.12 As shown, the embedded system 1000 includes an application layer 1001 and a system layer 1002 , wherein the system layer 1002 provides a time difference transmission interface for the application layer 1001 .
[0132] In some embodiments, the system layer 1002 receives a time difference acquisition request sent by the application layer 1001 through a time difference transmission interface, and the time difference acquisition request carries at least one timestamp identifier; the system layer 1002 determines two target timestamps based on the type of the time difference transmission interface and at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp; the system layer 1002 calculates the time difference according to the two target timestamps to obtain a relative timestamp; the system layer 1002 returns the relative timestamp to the application layer 1001 through the time difference transmission interface; the application layer 1001 executes a preset duration judgment logic based on the relative timestamp.
[0133] See also Fig.13 , Fig.13 Schematic diagram of the interaction between the application layer and the system layer provided in an embodiment of the present application. Fig.13 As shown, the application layer sends a timestamp application request to the system layer through the timestamp application interface. The system layer queries the allocation status of each timestamp buffer area according to the timestamp application request, determines the timestamp buffer area to be allocated, and sends the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface.
[0134] In some embodiments, Fig.13 As shown, the application layer sends a timestamp refresh request to the system layer through the timestamp refresh interface. When the system layer receives the timestamp refresh request, it records the current timestamp corresponding to the current moment in the timestamp buffer corresponding to the timestamp identifier carried in the timestamp refresh request.
[0135] In some embodiments, Fig.13 As shown, the application layer sends a time difference acquisition request to the system layer through the time difference transmission interface. The system layer determines two target timestamps based on the interface type of the time difference transmission interface and at least one timestamp identifier in the time difference acquisition request, calculates the time difference based on the two target timestamps, and obtains a relative timestamp; then, the system layer returns the relative timestamp to the application layer through the time difference transmission interface.
[0136] In some embodiments, Fig.13 As shown, the application layer requests the system layer to release the timestamp buffer area through the timestamp release interface. The system layer marks the allocation state of the timestamp buffer area corresponding to the timestamp identifier carried in the timestamp release request as unallocated.
[0137] See also Fig.14 , Fig.14 It is a schematic block diagram of the structure of an electronic device provided in an embodiment of the present application.
[0138] See also Fig.14The electronic device includes a processor and a memory connected via a system bus, wherein the memory may include a storage medium and an internal memory. The storage medium may be a non-volatile storage medium or a volatile storage medium.
[0139] The processor is used to provide computing and control capabilities to support the operation of the entire electronic device.
[0140] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any relative timestamp generation method.
[0141] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0142] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0143] A time difference acquisition request sent by the application layer is received through a time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier; two target timestamps are determined based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp; a time difference is calculated according to the two target timestamps to obtain a relative timestamp; and the relative timestamp is returned to the application layer through the time difference transmission interface, so that the application layer can execute a preset duration judgment logic based on the relative timestamp.
[0144] In one embodiment, the time difference acquisition request carries a timestamp identifier, and the timestamp identifier is a first timestamp identifier; when the processor determines two target timestamps based on the type of the time difference transmission interface and the at least one timestamp identifier, it is used to implement:
[0145] Among multiple timestamp buffer areas, determine the timestamp buffer area corresponding to the first timestamp identifier as a target timestamp buffer area; and use the timestamp stored in the target timestamp buffer area as the first timestamp;
[0146] When the interface type of the time difference transmission interface is a real-time interface, the current timestamp corresponding to the current moment is used as the second timestamp; and the first timestamp and the second timestamp are used as the two target timestamps.
[0147] In one embodiment, the time difference acquisition request carries two timestamp identifiers, the two timestamp identifiers being a start timestamp identifier and an end timestamp identifier; when the processor determines two target timestamps based on the type of the time difference transmission interface and the at least one timestamp identifier, it is used to implement:
[0148] Among multiple timestamp buffer areas, the timestamp buffer area corresponding to the start timestamp identifier is determined as the start timestamp buffer area; among the multiple timestamp buffer areas, the timestamp buffer area corresponding to the end timestamp identifier is determined as the end timestamp buffer area; when the interface type of the time difference transmission interface is a non-real-time interface, the timestamps stored in the start timestamp buffer area and the end timestamp buffer area are used as the two target timestamps.
[0149] In one embodiment, before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the processor is further configured to implement:
[0150] When a timestamp application request sent by the application layer is received through the timestamp application interface, the allocation status of each timestamp buffer area is queried; any timestamp buffer area with an allocation status of unallocated is determined as a timestamp buffer area to be allocated; the timestamp identifier corresponding to the timestamp buffer area to be allocated is sent to the application layer through the timestamp application interface; the allocation status of the timestamp buffer area to be allocated is marked as allocated.
[0151] In one embodiment, before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the processor is further configured to implement:
[0152] When a timestamp application request sent by the application layer is received through the timestamp application interface, the allocation status of each timestamp buffer area is queried; any timestamp buffer area with an allocation status of unallocated is determined as a timestamp buffer area to be allocated, and the timestamp corresponding to the current moment is stored in the timestamp buffer area to be allocated; the timestamp identifier corresponding to the timestamp buffer area to be allocated is sent to the application layer through the timestamp application interface; the allocation status of the timestamp buffer area to be allocated is marked as allocated.
[0153] In one embodiment, before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the processor is further configured to implement:
[0154] A timestamp refresh request sent by the application layer is received through a timestamp refresh interface, wherein the timestamp refresh request carries a target timestamp identifier; and a current timestamp is recorded in a timestamp buffer area corresponding to the target timestamp identifier.
[0155] In one embodiment, the processor is further configured to implement:
[0156] A timestamp release request of the application layer is received through a timestamp release interface; and an allocation state of a timestamp buffer area corresponding to a timestamp identifier carried in the timestamp release request is marked as unallocated.
[0157] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any relative timestamp generation method provided in the embodiment of the present application or load an embedded system such as the above.
[0158] For example, the program is loaded by the processor and may execute the following steps:
[0159] A time difference acquisition request sent by the application layer is received through a time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier; two target timestamps are determined based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores a corresponding timestamp; a time difference is calculated according to the two target timestamps to obtain a relative timestamp; and the relative timestamp is returned to the application layer through the time difference transmission interface, so that the application layer can execute a preset duration judgment logic based on the relative timestamp.
[0160] The computer-readable storage medium may be an internal storage unit of the electronic device described in the above embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital card (Secure Digital Card, SD Card), a flash card (Flash Card), etc. equipped on the electronic device.
[0161] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0162] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0163] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A relative timestamp generation method, characterized in that: The method is applied to an electronic device, wherein the electronic device is equipped with an embedded system, wherein the embedded system includes a system layer and an application layer, and the method includes: Receiving a time difference acquisition request sent by the application layer through a time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier; Determine two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, the timestamp buffer area stores a corresponding timestamp, when the interface type is a real-time interface, the time difference acquisition request carries a timestamp identifier, and when the interface type is a non-real-time interface, the time difference acquisition request carries two timestamp identifiers; Calculate the time difference between the two target timestamps to obtain a relative timestamp; The relative timestamp is returned to the application layer through the time difference transmission interface, so that the application layer executes a preset duration judgment logic based on the relative timestamp.
2. The relative timestamp generation method according to claim 1, characterized in that: The time difference acquisition request carries a timestamp identifier, the timestamp identifier is a first timestamp identifier, and the determining of two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier includes: Among multiple timestamp buffer areas, determining the timestamp buffer area corresponding to the first timestamp identifier as the target timestamp buffer area; Using the timestamp stored in the target timestamp buffer as a first timestamp; When the interface type of the time difference transmission interface is a real-time interface, using a current timestamp corresponding to the current moment as a second timestamp; The first timestamp and the second timestamp are used as the two target timestamps.
3. The relative timestamp generation method according to claim 1, characterized in that: The time difference acquisition request carries two timestamp identifiers, where the two timestamp identifiers are a start timestamp identifier and an end timestamp identifier; and the determining of two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier includes: Among the multiple timestamp buffer areas, determining the timestamp buffer area corresponding to the starting timestamp identifier as the starting timestamp buffer area; Among the multiple timestamp buffer areas, determine the timestamp buffer area corresponding to the end timestamp identifier as the end timestamp buffer area; When the interface type of the time difference transmission interface is a non-real-time interface, the timestamps stored in the start timestamp buffer area and the end timestamp buffer area are used as the two target timestamps.
4. The relative timestamp generation method according to claim 1, characterized in that: Before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the method further includes: When a timestamp application request sent by the application layer is received through the timestamp application interface, querying the allocation status of each timestamp buffer area; Determine any timestamp buffer area whose allocation state is unallocated as a timestamp buffer area to be allocated; Sending the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface; The allocation state of the timestamp buffer area to be allocated is marked as allocated.
5. The relative timestamp generation method according to claim 1, characterized in that: Before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the method further includes: When a timestamp application request sent by the application layer is received through the timestamp application interface, querying the allocation status of each timestamp buffer area; Determine any timestamp buffer area whose allocation state is unallocated as a timestamp buffer area to be allocated, and store the timestamp corresponding to the current moment in the timestamp buffer area to be allocated; Sending the timestamp identifier corresponding to the timestamp buffer area to be allocated to the application layer through the timestamp application interface; The allocation state of the timestamp buffer area to be allocated is marked as allocated.
6. The relative timestamp generation method according to claim 1, characterized in that: Before receiving the time difference acquisition request sent by the application layer through the time difference transmission interface, the method further includes: Receiving a timestamp refresh request sent by the application layer through a timestamp refresh interface, wherein the timestamp refresh request carries a target timestamp identifier; The current timestamp is recorded in the timestamp buffer area corresponding to the target timestamp identifier.
7. The relative timestamp generation method according to any one of claims 1 to 6, characterized in that: The method further comprises: Receiving a timestamp release request from the application layer through a timestamp release interface; The allocation state of the timestamp buffer area corresponding to the timestamp identifier carried in the timestamp release request is marked as unallocated.
8. An embedded system, comprising a system layer and an application layer, characterized in that: The system layer provides a time difference transmission interface to the application layer; The system layer receives the time difference acquisition request sent by the application layer through the time difference transmission interface, wherein the time difference acquisition request carries at least one timestamp identifier; The system layer determines two target timestamps based on the interface type of the time difference transmission interface and the at least one timestamp identifier; wherein each timestamp identifier corresponds to a timestamp buffer area, and the timestamp buffer area stores the corresponding timestamp, and when the interface type is a real-time interface, the time difference acquisition request carries a timestamp identifier, and when the interface type is a non-real-time interface, the time difference acquisition request carries two timestamp identifiers; The system layer calculates the time difference according to the two target timestamps to obtain a relative timestamp; The system layer returns the relative timestamp to the application layer through the time difference transmission interface; The application layer executes a preset duration determination logic based on the relative timestamp.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the relative timestamp generation method as described in any one of claims 1 to 7 when executing the computer program, or load the embedded system as described in claim 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the relative timestamp generation method according to any one of claims 1 to 7, or loads the embedded system according to claim 8.
Citation Information
Patent Citations
Time-out judging method and system between heterogeneous systems
CN103414545A
Target test method and device, equipment and storage medium
CN112905449A