Starting time consumption recording method and device

By using hardware counters and shared memory in embedded systems to record subsystem startup time, the problem of inaccurate startup time calculation in the prior art is solved, and more accurate startup process time consumption analysis is achieved.

CN120653315APending Publication Date: 2025-09-16JINGWEI HIRAIN (TIANJIN) RES&DEV CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510727430.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-16

Smart Images

  • Figure CN120653315A_ABST
    Figure CN120653315A_ABST
Patent Text Reader

Abstract

The invention provides a starting time consumption recording method and device. The method comprises the following steps: when any subsystem receives a starting signal, reading a current count in the hardware counter; determining the start completion time corresponding to the subsystem according to the current count; storing the starting completion time corresponding to each subsystem to a preset shared memory area; reading data in the preset shared memory area under the condition that the operation system is started; on the basis of the data in the preset shared memory area, according to the starting sequence of all the subsystems, the difference value between the starting completion time corresponding to each subsystem and the starting completion time corresponding to the previous subsystem is calculated, and the starting process consumed time of all the subsystems is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method and device for recording startup time consumption. Background Art

[0002] In embedded systems, fast boot times are often required. To record boot time, serial port logging tools are often used to include personal computer (PC) timestamps. The boot time is estimated by calculating the difference between the PC timestamp of the boot completion log and the PC timestamp of the first boot log.

[0003] In the prior art, the calculation of time relies entirely on the serial port, that is, the system log needs to be output through the serial port, and a serial port log tool is required to receive and display these logs. However, in order to save startup time, fast startup requirements usually turn off the serial port output of the system log. In addition, for system security reasons, some chip designs may no longer retain the serial port interface, which makes the method of relying on the serial port impossible to implement. Moreover, the system log cannot record the time consumed by processes such as power-on, early boot loader execution, and serial port initialization. The system log also does not record in detail the time consumed by each subsystem during the startup process. Therefore, using the system log will lead to inaccurate calculated startup time. Summary of the Invention

[0004] The embodiments of the present application provide a method and device for recording startup time consumption, which can calculate a more accurate startup time.

[0005] In a first aspect, the present application provides a method for recording startup time of an operating system, wherein the operating system includes multiple subsystems, the operating system includes a hardware counter and a preset shared memory area, the hardware counter is used to start timing after the hardware device is powered on, and the method includes:

[0006] When any subsystem receives a start signal, read the current count in the hardware counter;

[0007] Determining a startup completion time corresponding to the subsystem according to the current count;

[0008] Store the startup completion time corresponding to each subsystem in the preset shared memory area;

[0009] When the operating system is started, the data in the preset shared memory area is read;

[0010] Based on the data in the preset shared memory area, according to the startup sequence of each subsystem, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated to obtain the startup process time of each subsystem.

[0011] In some possible implementations, calculating, based on the data in the preset shared memory area and in accordance with the startup order of each subsystem, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem to obtain the startup process time of each subsystem includes:

[0012] Extracting a startup string in the preset shared memory area based on the data in the preset shared memory area, wherein the startup string includes startup completion time corresponding to each subsystem arranged in a startup sequence;

[0013] Separating the startup string into a plurality of substrings according to the subsystem according to a preset separator in the startup string, wherein the substrings include subsystem identifiers, and the subsystem identifiers correspond to the respective subsystems;

[0014] Based on each substring in the separated startup string, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated to obtain the startup process time of each subsystem.

[0015] In some possible implementations, calculating the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on each substring in the separated startup string to obtain the startup process time of each subsystem includes:

[0016] For each substring in the separated startup string, perform the following steps:

[0017] extracting a subsystem identifier from the substring;

[0018] Determining, according to the subsystem identifier, the subsystem corresponding to the substring and the first startup completion time corresponding to the substring;

[0019] Determining a second startup completion time corresponding to a previous substring of the substring according to a startup sequence of each subsystem;

[0020] The difference between the first startup completion time and the second startup completion time is calculated to obtain the startup process time consumption of the subsystem corresponding to the substring.

[0021] In some possible implementations, storing the startup completion time corresponding to each subsystem in a preset shared memory area includes:

[0022] Map the physical address of the preset shared memory area to a virtual address;

[0023] In the case where the subsystem is a hardware subsystem, storing the startup completion time corresponding to the subsystem in a preset shared memory area;

[0024] In the case where the subsystem is a software subsystem, the startup completion time corresponding to the subsystem is stored in a preset shared memory area according to the virtual address.

[0025] In some possible implementations, mapping the physical address of the preset shared memory area to a virtual address includes:

[0026] Determine a physical page corresponding to the preset shared memory area and a physical address corresponding to the physical page;

[0027] A preset mapping function is called to map the physical address to the virtual address space of the system to obtain a corresponding virtual address.

[0028] In some possible implementations, when the subsystem is a software subsystem, storing the startup completion time corresponding to the subsystem in a preset shared memory area according to the virtual address includes:

[0029] In the case where the subsystem is a software subsystem, constructing a corresponding write interface according to the virtual address;

[0030] The startup completion time corresponding to the subsystem is stored in a preset shared memory area according to the virtual address through the write interface.

[0031] In some possible implementations, when any subsystem receives a start signal, reading the current count in the hardware counter includes:

[0032] When any sub-software system receives a start signal, it reads the current count in the hardware counter through a write interface.

[0033] In some possible implementations, when the operating system is started, reading the data in the preset shared memory area includes:

[0034] When the login service of the operating system is started, determining that the startup of the operating system is complete;

[0035] The write interface is called to read the data in the preset shared memory area.

[0036] In some possible implementations, determining the startup completion time corresponding to the subsystem according to the current count includes:

[0037] Obtaining the operating frequency of the hardware counter;

[0038] The ratio of the current count to the operating frequency is calculated to obtain the startup completion time corresponding to the subsystem.

[0039] In a second aspect, the present application provides a device for recording startup time consumption, the device comprising:

[0040] A reading module, configured to read the current count in the hardware counter when any subsystem receives a start signal;

[0041] A determination module, configured to determine a startup completion time corresponding to the subsystem according to the current count;

[0042] The storage module is used to store the startup completion time corresponding to each subsystem in a preset shared memory area;

[0043] The reading module is further configured to read the data in the preset shared memory area when the operating system is started;

[0044] The calculation module is used to calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on the data in the preset shared memory area and according to the startup order of each subsystem, so as to obtain the startup process time of each subsystem.

[0045] The startup time recording method and device provided in the embodiment of the present application read the current count in the hardware counter when any subsystem receives a startup signal, and then determines the startup completion time corresponding to the subsystem based on the current count, and then stores the startup completion time corresponding to each subsystem in a preset shared memory area. Once the operating system startup is completed, the data in the shared memory is read, and the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated according to the startup order of each subsystem to obtain the startup process time of each subsystem. The allocated shared memory is used to write the corresponding startup process time into this memory during the startup process, thereby avoiding the use of the serial port to calculate the startup time. A distinction is made between each subsystem during recording and calculation, which can make the calculated startup time more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The present application can be better understood from the following description of specific embodiments of the present application in conjunction with the accompanying drawings, in which:

[0047] Other features, objects and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings, in which the same or similar reference numerals represent the same or similar features.

[0048] Figure 1This is a flowchart of a method for starting time-consuming recording provided by an embodiment of the present application;

[0049] Figure 2 This is a flowchart of a method for starting time-consuming recording provided by another embodiment of the present application;

[0050] Figure 3 This is a flowchart of a method for starting time-consuming recording provided by another embodiment of the present application;

[0051] Figure 4 This is a structural diagram of a startup time-consuming recording device provided by an embodiment of the present application;

[0052] Figure 5 This is a schematic diagram of the hardware structure of the startup time-consuming recording device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating the examples of the present application.

[0054] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, the elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article, or device comprising the elements.

[0055] In order to solve the problems in the prior art, the embodiments of the present application provide a method and device for recording the startup time consumption.

[0056] Figure 1The flowchart of the startup time recording method provided by one embodiment of the present application is shown. Applied to an operating system, the operating system includes multiple subsystems, the operating system includes a hardware counter and a preset shared memory area, the hardware counter is used to start timing after the hardware device is powered on, such as Figure 1 As shown, the method includes the following steps: S101 to S106.

[0057] S101: When any subsystem receives a start signal, the current count in the hardware counter is read.

[0058] In practice, a hardware counter is a device capable of precise timing. It typically begins counting when the hardware is powered on, recording the system's boot time. Each subsystem receives a boot signal upon startup, which may be issued by the operating system or triggered externally. This signal indicates that the subsystem should begin booting. Upon receiving the boot signal, the subsystem first reads the current value of the hardware counter. This value represents the time since the system was powered on. It is then converted to milliseconds or microseconds to mark the start of the boot process. The driver or hardware interface within the system provides an application program interface or direct hardware access to read the counter value.

[0059] S102: Determine the startup completion time corresponding to the above subsystem according to the above current count.

[0060] In specific implementations, the startup completion time refers to the time from when the subsystem receives the startup signal to when the startup process is completely completed. Typically, this time point is set to a key marker in the startup process, such as when all system modules have been loaded and hardware initialization is complete. After reading the hardware counter, the system needs to compare the current count with a preset standard. This standard can be the subsystem's internal clock or a flag in the system that indicates whether the startup process has been completed. Each subsystem may have an internal mechanism to calculate whether the startup process has ended. Generally speaking, the system may set an event listener or timer to capture the moment the startup process ends, and then update the startup completion time based on this event.

[0061] S103: Storing the startup completion time corresponding to each subsystem in a preset shared memory area.

[0062] In practice, a shared memory zone is a memory area accessible to multiple subsystems. It is typically used to store data that needs to be shared across multiple subsystems or processes, reducing data transmission overhead. After each subsystem determines its own startup completion time, it stores this time information in a pre-defined shared memory zone. This shared memory zone may be pre-allocated by the operating system or dynamically allocated. Shared memory is typically implemented through the operating system's memory management mechanism. Subsystems access shared memory using specific memory addresses or identifiers and write their own startup completion time to the shared memory zone.

[0063] S104: When the operating system is started, data in the preset shared memory area is read.

[0064] In the specific implementation, when the operating system boots up, a global flag is triggered, indicating that all subsystems have been booted and initialized. At this point, the operating system can begin collecting boot data for all subsystems. The operating system reads the boot completion time data for all subsystems from shared memory, either through memory mapping or pointer reference.

[0065] S105: Based on the data in the preset shared memory area, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated according to the startup sequence of each subsystem to obtain the startup process time of each subsystem.

[0066] In practice, each subsystem might start up in a specific order. By reading the shared memory data, the operating system can calculate the startup time of each subsystem based on the difference between the startup completion time of each subsystem and the previous subsystem's startup completion time. Once the startup completion times of all subsystems are stored and read, the operating system can traverse the shared memory area and calculate the difference one by one. These calculation results can be recorded in the form of logs or passed to performance monitoring tools for analysis.

[0067] As another example, the specific calculation process can be, for example, the startup completion time of the first subsystem is T1, and the second subsystem is T2, then the startup time of the second subsystem is T2-T1, and so on, calculating the startup time difference between all subsystems in sequence.

[0068] The startup time recording method provided in the embodiment of the present application is to read the current count in the hardware counter when any subsystem receives a startup signal, and then determine the startup completion time corresponding to the subsystem based on the current count, and then store the startup completion time corresponding to each subsystem in a preset shared memory area. Once the operating system startup is completed, read the data in the shared memory, and calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem according to the startup order of each subsystem to obtain the startup process time of each subsystem. Utilize the allocated shared memory to write the corresponding startup process time into this memory during the startup process, thereby avoiding the use of the serial port to calculate the startup time. Distinguish between each subsystem during recording and calculation, so that the calculated startup time can be more accurate.

[0069] In order to calculate the startup time of each subsystem, in some embodiments, the above S105 may include the following steps: S1051 to S1053.

[0070] S1051: extracting a startup string in the preset shared memory area based on the data in the shared memory, where the startup string includes startup completion time corresponding to each subsystem arranged in startup order.

[0071] In a specific implementation, in step S104, the operating system has already stored the startup completion time of each subsystem in shared memory. These startup times may be stored in the form of strings and arranged in the order in which the subsystems are started. The startup string contains multiple substrings, each representing a subsystem and its corresponding startup completion time. The subsystem identifier and the corresponding startup completion time are separated by a preset delimiter. Through appropriate memory mapping and address pointers, the startup string in shared memory can be retrieved.

[0072] S1052: Separate the startup string into multiple substrings according to the subsystems according to the preset separator in the startup string, wherein the substrings include subsystem identifiers, and the subsystem identifiers correspond to the respective subsystems.

[0073] In a specific implementation, after obtaining the startup string, it is split according to a preset delimiter, where each substring contains an identifier of a subsystem and the startup completion time. The substrings obtained after the splitting are stored in an array or a list.

[0074] As another example, the split substrings can be organized into a key-value pair structure.

[0075] S1053: Based on each substring in the separated startup string, calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem to obtain the startup process time of each subsystem.

[0076] In the implementation, the startup time of each subsystem is calculated one by one. Specifically, the time difference between each subsystem and the previous subsystem can be calculated by traversing this data. For each subsystem, its startup time is obtained and compared with the startup time of the previous subsystem to calculate the difference between them. A loop can be used to traverse all subsystems and calculate the time difference between each subsystem and the previous subsystem.

[0077] The above implementation method of the embodiment of the present application extracts the startup string in the above shared memory through the data in the above shared memory, and according to the preset delimiter in the above startup string, separates the above startup string into multiple substrings according to the subsystem. Based on each substring in the above startup string after separation, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated to obtain the startup process time of each subsystem. By extracting the startup string from the shared memory, splitting the string by the delimiter, and converting the split data into a structured form, the startup time difference of each subsystem is calculated. Finally, by traversing and calculating the startup process time of each subsystem, data support is provided for system optimization and performance monitoring.

[0078] In order to accurately obtain the startup time of each subsystem, in some embodiments, the above S1053 includes:

[0079] For each substring in the separated startup string, the following steps are performed: which may include the following steps: S10531 to S10534.

[0080] S10531: Extract the subsystem identifier from the above substring.

[0081] In a specific implementation, the separated startup strings appear in pairs according to the subsystem identifier and the startup time. The subsystem identifier is extracted from each substring by traversing the separated string array or list.

[0082] S10532: Determine the subsystem corresponding to the substring and the first startup completion time corresponding to the substring according to the subsystem identifier.

[0083] In the specific implementation, the subsystem identifier is extracted, and the startup completion time corresponding to the subsystem is obtained. According to each subsystem identifier, the startup completion time of the subsystem is searched, and the extracted subsystem identifiers are traversed. For each identifier, the corresponding time in the startup time array is searched by index to obtain the first startup completion time.

[0084] S10533: Determine the second startup completion time corresponding to the previous substring of the above substring according to the startup sequence of each subsystem.

[0085] In a specific implementation, for each subsystem, the startup time of its previous subsystem is obtained, the startup time of each subsystem relative to the previous subsystem is calculated, and the second startup completion time corresponding to the previous substring is obtained.

[0086] S10534: Calculate the difference between the first startup completion time and the second startup completion time to obtain the startup process time of the subsystem corresponding to the substring.

[0087] In a specific implementation, for each subsystem, the difference between its startup completion time and the startup completion time of the previous subsystem is calculated, and this difference is used as the startup process time consumption of the current subsystem.

[0088] The above-mentioned implementation method of the embodiment of the present application extracts the subsystem identifier from the above-mentioned substring, determines the subsystem corresponding to the above-mentioned substring and the first startup completion time corresponding to the above-mentioned substring according to the above-mentioned subsystem identifier, determines the second startup completion time corresponding to the previous substring of the above-mentioned substring according to the startup order of each subsystem, and then calculates the difference between the above-mentioned first startup completion time and the above-mentioned second startup completion time to obtain the startup process time of the subsystem corresponding to the above-mentioned substring, thereby accurately obtaining the startup process time of each subsystem.

[0089] In order to perform efficient data exchange through shared memory, in some implementations, reference may be made to Figure 2 The above S103 may include the following steps: S1031 to S1033.

[0090] S1031: Map the physical address of the preset shared memory area to a virtual address.

[0091] In the implementation, the physical address of the preset shared memory area is obtained. For example, the operating system or hardware provides the starting physical address of the shared memory. This address may be initialized by the operating system or hardware and assigned to different subsystems for data sharing. The operating system's virtual memory management system then maps the physical address to the process's virtual address space. This mapping process requires the operating system to provide relevant permissions and mapping mechanisms to ensure that the virtual address can correctly access the data at the physical address.

[0092] S1032: When the subsystem is a hardware subsystem, the startup completion time corresponding to the subsystem is stored in a preset shared memory area.

[0093] In a specific implementation, when the subsystem is a hardware subsystem, since the hardware subsystem usually has an independent startup process, the startup completion time of the hardware subsystem is usually recorded by the hardware module or the operating system, and the startup completion time of the hardware subsystem is stored in a preset shared memory area.

[0094] S1033: In the case where the subsystem is a software subsystem, the startup completion time corresponding to the subsystem is stored in a preset shared memory area according to the virtual address.

[0095] In a specific implementation, it is determined whether the current subsystem is a software subsystem. If it is a software subsystem, the software subsystem processing flow is entered to obtain the startup completion time of the software subsystem. The startup completion time of the software subsystem is stored in the shared memory area using the virtual address obtained in step S1031.

[0096] The above-mentioned implementation of the embodiment of the present application maps the physical address of the preset shared memory area to a virtual address. When the subsystem is a hardware subsystem, the startup completion time corresponding to the above-mentioned subsystem is stored in the preset shared memory area. When the subsystem is a software subsystem, the startup completion time corresponding to the above-mentioned subsystem is stored in the preset shared memory area according to the above-mentioned virtual address, so that efficient data exchange can be carried out through shared memory.

[0097] In order to accurately map the virtual address, in some implementations, the above S1031 may include the following steps S10311 to S10312.

[0098] S10311: Determine the physical page corresponding to the preset shared memory area and the physical address corresponding to the physical page.

[0099] In computer memory management, physical pages are fixed-size pages into which memory is divided. The operating system maintains the mapping between virtual addresses and physical addresses through page tables.

[0100] The preset shared memory area is a shared memory area that has been allocated by the operating system. It has a clear physical address. The operating system or hardware provides shared memory for multiple processes or subsystems in advance.

[0101] In a specific implementation, the physical address of the shared memory area is determined. This physical address indicates the actual memory location where the shared memory is located. Once the physical address of the shared memory is obtained, the physical page where the address is located needs to be determined.

[0102] S10312: Call a preset mapping function to map the above physical address to the virtual address space of the system to obtain the corresponding virtual address.

[0103] In its implementation, the mapping function is called to create a region in the virtual address space and map it to the corresponding portion of physical memory. Based on the physical address and mapping parameters, an appropriate virtual address is assigned to the shared memory in the virtual address space. Upon successful execution, the mapping function returns a virtual address that serves as the entry point for the program to access the shared memory. This virtual address points to the shared memory region, and the program can read or write data from this address.

[0104] The above implementation method of the embodiment of the present application determines the physical page corresponding to the above-mentioned preset shared memory area and the physical address corresponding to the above-mentioned physical page, and then calls the preset mapping function to map the above-mentioned physical address to the virtual address space of the system to obtain the corresponding virtual address, thereby accurately mapping the virtual address.

[0105] In order to accurately write into the preset shared memory area, in some implementations, the above S1033 may include the following steps S10331 to S10332.

[0106] S10331: When the subsystem is a software subsystem, a corresponding write interface is constructed according to the virtual address.

[0107] In practice, to write data to shared memory using a virtual address, an interface is first required. This is typically a function or object that can access a specific memory location. For this virtual address, a corresponding write interface is constructed.

[0108] S10332: Through the write interface, according to the virtual address, store the startup completion time corresponding to the subsystem into the preset shared memory area.

[0109] In the specific implementation, the startup completion time is obtained. Once the startup completion time is obtained, this time value is written to the shared memory through the established write interface. The virtual address can be directly located at the corresponding location in the shared memory area. Then, the subsystem successfully writes the startup completion time to the shared memory area.

[0110] The above-mentioned implementation method of the embodiment of the present application constructs a corresponding write interface according to the above-mentioned virtual address when the subsystem is a software subsystem, and then stores the startup completion time corresponding to the above-mentioned subsystem to the preset shared memory area through the above-mentioned write interface according to the above-mentioned virtual address, so that the preset shared memory area can be accurately written.

[0111] In order to reliably obtain and store the value of the hardware counter, in some implementations, the above S101 may include:

[0112] When any sub-software system receives a start signal, it reads the current count in the hardware counter through a write interface.

[0113] In a specific implementation, after receiving the start signal, the sub-software system interacts with the hardware counter through the write interface, reads the current value of the counter, and then writes the count value to a preset location.

[0114] The above implementation of the embodiment of the present application can reliably obtain and store the value of the hardware counter by reading the current count in the above hardware counter through the write interface when any sub-software system receives a start signal.

[0115] In order to accurately read the data in the shared memory, in some implementations, the above S104 may include the following steps S1041 to S1042.

[0116] S1041: When the login service of the operating system is started, it is determined that the startup of the operating system is completed.

[0117] In a specific implementation, the state of the key process is checked to determine the startup status of the operating system. When the login service of the operating system is started, it is determined that the startup of the operating system is completed.

[0118] S1042: Call the above-mentioned write interface to read the data in the above-mentioned preset shared memory area.

[0119] In the specific implementation, the above-mentioned write interface is called to read the data in the shared memory and process the read data.

[0120] The above implementation of the embodiment of the present application determines that the operating system startup is complete when the login service of the above operating system is started, and then calls the above write interface to read the data in the above shared memory, thereby accurately reading the data in the above shared memory.

[0121] For the startup completion time of the subsystem, in some embodiments, reference can be made to Figure 3 , the above S102 may include the following steps S1021 to S1042.

[0122] S1021: Obtain the operating frequency of the hardware counter.

[0123] In a specific implementation, the operating frequency of the hardware counter can be obtained through an interface provided by the operating system or by directly querying the hardware register.

[0124] S1022: Calculate the ratio of the current count to the operating frequency to obtain the startup completion time corresponding to the subsystem.

[0125] In a specific implementation, the count value of the hardware counter increases continuously with the passage of time, and its increment rate is known. The ratio of the current count to the operating frequency is calculated to obtain the startup completion time corresponding to the subsystem.

[0126] The above implementation of the embodiment of the present application obtains the operating frequency of the above hardware counter, and then calculates the ratio of the above current count to the above operating frequency to obtain the startup completion time corresponding to the above subsystem, thereby accurately obtaining the startup completion time corresponding to the subsystem.

[0127] As another implementation method of the present application, first, a memory area of ​​a physical page is reserved for use as shared memory. This memory area is marked as a reserved area in each subsystem, that is, all subsystems will not change this shared memory during operation. When the double data rate synchronous dynamic random access memory (DDR) is initialized, the early stage of the startup process (early boot) is directly written into the shared memory. When arriving at the ATF subsystem entrance, assuming that the counter value reaches 2000, according to milliseconds = counter * 1000 / frequency, the counter value is converted into milliseconds of 2, and then "2, atf," is appended to the shared memory. When arriving at the Optee subsystem entrance, assuming that the counter value reaches 3000, according to milliseconds = counter * 1000 / frequency, the counter value is converted into milliseconds of 3, and then "3, optee," is appended to the shared memory. Upon reaching the Uboot subsystem entry, assuming the counter reaches 4000, the counter value is converted to 4 milliseconds using the formula milliseconds = counter * 1000 / frequency. Then, "4, uboot" is written to shared memory. The software subsystem maps the physical address of shared memory to a readable and writable virtual address. It then creates a virtual device file node and implements its write interface. This interface reads the hardware counter, converts it to milliseconds, and then writes the milliseconds and the corresponding process to the virtual address.

[0128] When the kernel subsystem is reached, the write interface is called to append "5, kernel," to the shared memory. When the system daemon (Systemd) subsystem is reached, a system call is made to fall into the kernel write interface, and "6, systemd," is appended to the shared memory. When the login service is reached, indicating that the system has been booted, a system call is made to fall into the kernel write interface, and the corresponding flag is passed. This will append only "7" to the shared memory, and the shared memory will now read "early boot, 2, atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7."

[0129] After receiving the corresponding flag, the write interface separates and subtracts the strings in shared memory to obtain the boot process and overall time. This separation and subtraction process is based on the separation of specific characters in the string. Here, commas (,") are used as delimiters to separate the strings layer by layer. For example, "early boot, 2, atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7" is:

[0130] First find the first comma "," in the string, and use the comma as a delimiter to separate the string into "earlyboot" and "2, atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7".

[0131] Then separate "2, atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7" with commas to get "2" and "atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7".

[0132] This separates "early boot" and "2" as the first boot process and time consumption.

[0133] Using the same method, we can separate "atf" and "3" from "atf, 3, optee, 4, uboot, 5, kernel, 6, systemd, 7", and then subtract the time taken by "early boot" "2" from "3" to get the second boot process "atf" and the time taken by "1".

[0134] Similarly, separate "optee" and "4" from "optee, 4, uboot, 5, kernel, 6, systemd, 7", subtract "early boot" time "2" from "4", and then subtract "atf" time "1" from "4" to get the third boot process "optee" and time "1".

[0135] Until the end of the string, there is "systemd, 7" left. Separate "sysemd" and "7" to get the total time. Then subtract the time of the previous startup process from "7" to get the final startup process "systemd" and time.

[0136] The above is achieved through a two-layer loop algorithm. The first layer separates all the boot processes. The second layer separates and calculates the time taken for all the boot processes by difference. At the same time, it is saved in the local structure array driven by boottime, which is convenient for direct reading when referenced again without re-parsing the string.

[0137] Based on the startup time recording method provided in the above embodiment, the present application also provides a specific implementation of the startup time recording device. Please refer to the following embodiment.

[0138] See first Figure 4 The startup time recording device 400 provided in the embodiment of the present application includes the following modules:

[0139] The reading module 401 is configured to read the current count in the hardware counter when any subsystem receives a start signal.

[0140] The determination module 402 is configured to determine the startup completion time corresponding to the above subsystem according to the above current count.

[0141] The storage module 403 is configured to store the startup completion time corresponding to each subsystem in a preset shared memory area.

[0142] The reading module 401 is further configured to read the data in the preset shared memory area when the operating system is started.

[0143] The calculation module 404 is used to calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on the data in the above-mentioned preset shared memory area and according to the startup order of each subsystem, so as to obtain the startup process time of each subsystem.

[0144] As an implementation of the present application, the calculation module 404 includes:

[0145] The extraction unit is configured to extract a startup string in the preset shared memory area based on the data in the preset shared memory area, wherein the startup string includes startup completion time corresponding to each subsystem arranged in a startup sequence.

[0146] The separation unit is used to separate the startup string into multiple substrings according to the subsystem according to the preset separator in the startup string, wherein the substrings include subsystem identifiers, and the subsystem identifiers correspond to the respective subsystems.

[0147] The calculation unit is used to calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on each substring in the separated startup string, so as to obtain the startup process time of each subsystem.

[0148] As an implementation of the present application, a computing unit includes:

[0149] The extraction subunit is used to extract the subsystem identifier from the above substring.

[0150] The determining subunit is configured to determine the subsystem corresponding to the substring and the first startup completion time corresponding to the substring according to the subsystem identifier.

[0151] The determining subunit is further configured to determine a second startup completion time corresponding to a previous substring of the substring according to a startup sequence of each subsystem.

[0152] The calculation subunit is configured to calculate the difference between the first startup completion time and the second startup completion time to obtain the startup process time consumption of the subsystem corresponding to the substring.

[0153] As an implementation of the present application, the storage module 403 includes:

[0154] The mapping unit is used to map the physical address of the preset shared memory area into a virtual address.

[0155] The storage unit is used to store the startup completion time corresponding to the above subsystem in a preset shared memory area when the subsystem is a hardware subsystem.

[0156] The storage unit is further configured to store the startup completion time corresponding to the subsystem into a preset shared memory area according to the virtual address when the subsystem is a software subsystem.

[0157] As an implementation of the present application, the mapping unit includes:

[0158] The determination subunit is used to determine the physical page corresponding to the preset shared memory area and the physical address corresponding to the physical page.

[0159] The calling subunit is used to call a preset mapping function to map the above physical address to the virtual address space of the system to obtain the corresponding virtual address.

[0160] As an implementation of the present application, a storage unit includes:

[0161] The construction subunit is used to construct a corresponding write interface according to the virtual address when the subsystem is a software subsystem.

[0162] The storage subunit is used to store the startup completion time corresponding to the above subsystem into a preset shared memory area according to the above virtual address through the above write interface.

[0163] As an implementation of the present application, the reading module 401 includes:

[0164] The reading unit is used to read the current count in the hardware counter through the write interface when any sub-software system receives the start signal.

[0165] As an implementation of the present application, the reading module 401 includes:

[0166] The determination unit is used to determine whether the operating system startup is completed when the login service of the operating system is started.

[0167] The calling unit is used to call the above-mentioned write interface to read the data in the above-mentioned preset shared memory area.

[0168] As an implementation of the present application, the determination module 402 includes:

[0169] The acquisition unit is used to obtain the operating frequency of the hardware counter.

[0170] The calculation unit is used to calculate the ratio of the current count to the operating frequency to obtain the startup completion time corresponding to the subsystem.

[0171] Each module in the startup time-consuming recording device provided in the embodiment of the present application can implement each step in the above-mentioned startup time-consuming recording method and achieve corresponding effects. For the sake of concise description, they will not be repeated here.

[0172] Figure 5 A schematic diagram of the structure of the startup time-consuming recording hardware provided in an embodiment of the present application is shown.

[0173] The startup time recording device may include a processor 501 and a memory 502 storing computer program instructions.

[0174] Specifically, the processor 501 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0175] The memory 502 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 502 may include removable or non-removable (or fixed) media. Where appropriate, the memory 502 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 502 is a non-volatile solid-state memory.

[0176] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the startup time consumption recording method according to any one embodiment of the present disclosure.

[0177] The processor 501 reads and executes computer program instructions stored in the memory 502 to implement any one of the startup time consumption recording methods in the above embodiments.

[0178] In one example, the startup time recording device may further include a communication interface 503 and a bus 510. Figure 5 As shown, the processor 501, the memory 502, and the communication interface 503 are connected via a bus 510 and communicate with each other.

[0179] The communication interface 503 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0180] Bus 510 includes hardware, software or both, and the components of online data flow metering equipment are coupled to each other. For example, but not limitation, bus can include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 510 can include one or more buses. Although the present application embodiment describes and shows specific bus, the application considers any suitable bus or interconnection.

[0181] In addition, in conjunction with the method for starting time recording in the above embodiments, embodiments of the present application may provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any of the methods for starting time recording in the above embodiments is implemented.

[0182] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed, implements any one of the methods for starting time-consuming recording in the above embodiments.

[0183] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.

[0184] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0185] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0186] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or flowchart and the combination of the boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0187] The above description is only a specific embodiment of the present application. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited thereto. Any person skilled in the art 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 scope of protection of the present application.

Claims

1. A method for recording startup time consumption, characterized in that: The method is applied to an operating system including multiple subsystems, wherein the operating system corresponds to a hardware counter and a preset shared memory area, wherein the hardware counter is used to start timing after the hardware device is powered on. The method includes: When any subsystem receives a start signal, read the current count in the hardware counter; Determining a startup completion time corresponding to the subsystem according to the current count; Store the startup completion time corresponding to each subsystem in the preset shared memory area; When the operating system is started, the data in the preset shared memory area is read; Based on the data in the preset shared memory area, according to the startup sequence of each subsystem, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated to obtain the startup process time of each subsystem.

2. The startup time recording method according to claim 1, characterized in that: The method of calculating the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on the data in the preset shared memory area and according to the startup order of each subsystem to obtain the startup process time of each subsystem includes: Extracting a startup string in the preset shared memory area based on the data in the preset shared memory area, wherein the startup string includes startup completion time corresponding to each subsystem arranged in a startup sequence; Separating the startup string into a plurality of substrings according to the subsystem according to a preset separator in the startup string, wherein the substrings include subsystem identifiers, and the subsystem identifiers correspond to the respective subsystems; Based on each substring in the separated startup string, the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem is calculated to obtain the startup process time of each subsystem.

3. The startup time-consuming recording method according to claim 2, characterized in that: The step of calculating the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on each substring in the separated startup string to obtain the startup process time of each subsystem includes: For each substring in the separated startup string, perform the following steps: extracting a subsystem identifier from the substring; Determining, according to the subsystem identifier, the subsystem corresponding to the substring and the first startup completion time corresponding to the substring; Determining a second startup completion time corresponding to a previous substring of the substring according to a startup sequence of each subsystem; The difference between the first startup completion time and the second startup completion time is calculated to obtain the startup process time consumption of the subsystem corresponding to the substring.

4. The startup time recording method according to claim 1, characterized in that: The step of storing the startup completion time corresponding to each subsystem in a preset shared memory area includes: Map the physical address of the preset shared memory area to a virtual address; In the case where the subsystem is a hardware subsystem, storing the startup completion time corresponding to the subsystem in a preset shared memory area; In the case where the subsystem is a software subsystem, the startup completion time corresponding to the subsystem is stored in a preset shared memory area according to the virtual address.

5. The startup time-consuming recording method according to claim 4, characterized in that: Mapping the physical address of the preset shared memory area to the virtual address includes: Determine a physical page corresponding to the preset shared memory area and a physical address corresponding to the physical page; A preset mapping function is called to map the physical address to the virtual address space of the system to obtain a corresponding virtual address.

6. The startup time-consuming recording method according to claim 4, characterized in that: In the case where the subsystem is a software subsystem, storing the startup completion time corresponding to the subsystem in a preset shared memory area according to the virtual address includes: In the case where the subsystem is a software subsystem, constructing a corresponding write interface according to the virtual address; The startup completion time corresponding to the subsystem is stored in a preset shared memory area according to the virtual address through the write interface.

7. The startup time recording method according to claim 6, characterized in that: When any subsystem receives a start signal, reading the current count in the hardware counter includes: When any sub-software system receives a start signal, it reads the current count in the hardware counter through a write interface.

8. The startup time-consuming recording method according to claim 7, characterized in that: When the operating system is started, reading the data in the preset shared memory area includes: When the login service of the operating system is started, determining that the startup of the operating system is complete; The write interface is called to read the data in the preset shared memory area.

9. The method for recording startup time consumption according to any one of claims 1 to 8, characterized in that: Determining the startup completion time corresponding to the subsystem according to the current count includes: Obtaining the operating frequency of the hardware counter; The ratio of the current count to the operating frequency is calculated to obtain the startup completion time corresponding to the subsystem.

10. A startup time recording device, characterized in that: The device comprises: A reading module is used to read the current count in the hardware counter when any subsystem receives a start signal; A determination module, configured to determine a startup completion time corresponding to the subsystem according to the current count; The storage module is used to store the startup completion time corresponding to each subsystem in a preset shared memory area; The reading module is further used to read the data in the preset shared memory area when the operating system is started; The calculation module is used to calculate the difference between the startup completion time corresponding to each subsystem and the startup completion time corresponding to the previous subsystem based on the data in the preset shared memory area and according to the startup order of each subsystem, so as to obtain the startup process time of each subsystem.

Citation Information

Patent Citations

  • Multi-system starting method based on timer as well as intelligent terminal

    CN105511879A

  • Abnormality handling method and device for multi-core system

    CN112631872A

  • Real-time database fault recovery method and system, storage medium and server

    CN113986594A

  • Statistical method and statistical device for starting time in multi-domain system environment and medium

    CN119003305A