A processor utilization statistics method, system, device, and medium
Patent Information
- Application Number
- CN202211179247.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2042-09-27
AI Technical Summary
而现有的处理器利用率统计技术往往依赖操作系统,依赖独立硬件来处理,现有技术中没有如何统计固态硬盘裸机的处理器利用率的技术方案
[0040]本发明至少具有以下有益技术效果:通过本发明的方案,能够在固态硬盘产品裸机开发过程中,高效、准确地统计处理器利用率,对固态硬盘产品的性能分析提供精准的统计数据,使开发人员能够根据利用率数据来判断处理器的最大业务处理能力,优化处理器使用率,排查并控制占用处理器利用率过高的业务。
Smart Images

Figure CN115525426B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of storage technology, and in particular to a method, system, device and medium for calculating processor utilization. Background Technology
[0002] Firmware development for solid-state drives (SSDs) typically falls into two categories: bare-metal and RTOS (Real-Time Operating System). In bare-metal development, obtaining accurate CPU (Central Processing Unit) utilization is crucial for assessing CPU computing power, optimizing business performance, and troubleshooting. However, existing processor utilization statistics often rely on the operating system and dedicated hardware; there is currently no technical solution for accurately calculating processor utilization for bare-metal SSDs. Summary of the Invention
[0003] In view of this, the present invention proposes a processor utilization statistics method, system, device and medium, which can efficiently and accurately count processor utilization during the bare-metal development process of solid-state drive products, and provide accurate statistical data for the performance analysis of solid-state drive products.
[0004] To achieve the above objectives, one aspect of the present invention provides a processor utilization statistics method, specifically including the following steps:
[0005] In response to receiving a statistics processor utilization command, the global statistics variables are cleared and the statistics function module is started, wherein the global statistics variables include idle global statistics variables and busy global statistics variables;
[0006] The statistical function module is configured to perform the following steps:
[0007] Set the initial clock tick count and poll the message queue of the corresponding processor;
[0008] In response to the polling finding that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated, and the difference in clock ticks is accumulated into the idle global statistics variable, and the initial clock tick count is updated;
[0009] In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially;
[0010] After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed in processing the service to the corresponding busy global statistics variable, and update the updated initial clock tick count.
[0011] In response to receiving a command to obtain processor utilization, the processor utilization is calculated based on the accumulated idle global statistics and the busy global statistics corresponding to each service.
[0012] In some implementations, setting an initial clock tick count and polling the message queue of the corresponding processor includes:
[0013] Obtain the clock tick count and set the initial clock tick count based on the clock tick count;
[0014] In response to the completion of the initial clock tick count setting, the message queue of the corresponding processor is polled.
[0015] In some implementations, calculating the difference in clock ticks consumed when the processor is idle includes:
[0016] Obtain the latest clock tick count, and calculate the difference in clock tick count consumed by the processor during idle time based on the latest clock tick count and the initial clock tick count;
[0017] Updating the initial clock tick count includes:
[0018] The initial clock tick count is updated based on the latest clock tick count.
[0019] In some implementations, calculating the difference in clock ticks consumed by processing the service includes:
[0020] Obtain the clock tick count when the service processing is completed, and calculate the difference in clock tick count consumed in processing the service based on the clock tick count when the service processing is completed and the updated initial clock tick count;
[0021] Updating the initial clock tick count includes:
[0022] The updated initial clock tick count is updated based on the clock tick count when the business process is completed.
[0023] In some implementations, after updating the initial clock tick count, the method further includes:
[0024] Determine whether the message queue is empty;
[0025] In response to the message queue not being empty, the steps of processing the services in the message queue sequentially are returned in response to the completion of the initial clock tick count update.
[0026] In response to the message queue being empty, return to the step of polling the message queue of the corresponding processor in response to the completion of the initial clock tick count setting.
[0027] In some implementations, the method further includes:
[0028] In response to receiving a command to stop the utilization of the statistics processor, the statistics function module is shut down.
[0029] In some implementations, the method is applied to single-core solid-state drives or multi-core solid-state drives.
[0030] Another aspect of this invention provides a processor utilization statistics system, comprising:
[0031] A receiving and cleaning module is configured to clean up global statistical variables and start a statistical function module in response to receiving a statistical processor utilization command, wherein the global statistical variables include idle global statistical variables and busy global statistical variables.
[0032] The statistical function module is configured as follows:
[0033] Set the initial clock tick count and poll the message queue of the corresponding processor;
[0034] In response to the polling finding that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated, and the difference in clock ticks is accumulated into the idle global statistics variable, and the initial clock tick count is updated;
[0035] In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially;
[0036] After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed in processing the service to the corresponding busy global statistics variable, and update the updated initial clock tick count.
[0037] The receiving and calculation module is configured to calculate the processor utilization based on the accumulated idle global statistics variable and the busy global statistics variable corresponding to each service in response to receiving a command to obtain processor utilization.
[0038] In another aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory storing a computer program executable on the processor, the computer program performing the steps of the method described above when executed by the processor.
[0039] In another aspect, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method steps.
[0040] The present invention has at least the following beneficial technical effects: Through the solution of the present invention, the processor utilization rate can be efficiently and accurately counted during the bare-metal development process of solid-state drive products, providing accurate statistical data for the performance analysis of solid-state drive products, enabling developers to judge the maximum business processing capacity of the processor based on the utilization rate data, optimize the processor utilization rate, and identify and control the business that occupies too much processor utilization. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0042] Figure 1 A block diagram of an embodiment of the processor utilization statistics method provided by the present invention;
[0043] Figure 2 A block diagram of an embodiment of the method for calculating processor utilization using a statistical function module provided by the present invention;
[0044] Figure 3 A schematic diagram of an embodiment of the processor utilization statistics system provided by the present invention;
[0045] Figure 4 A schematic diagram of the structure of an embodiment of the electronic device provided by the present invention;
[0046] Figure 5 A schematic diagram of an embodiment of the computer-readable storage medium provided by the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.
[0048] It should be noted that all uses of "first" and "second" in the embodiments of the present invention are for the purpose of distinguishing two entities or parameters with the same name but different names. It is clear that "first" and "second" are only for the convenience of expression and should not be construed as limiting the embodiments of the present invention. Subsequent embodiments will not explain this in detail.
[0049] Based on the above objectives, a first aspect of the present invention provides an embodiment of a processor utilization statistics method. For example... Figure 1 As shown, it includes the following steps:
[0050] S10. In response to receiving the statistics processor utilization command, clear the global statistics variables and start the statistics function module, wherein the global statistics variables include idle global statistics variables and busy global statistics variables.
[0051] S20. In response to receiving the command to obtain processor utilization, calculate the processor utilization based on the accumulated idle global statistics variable and the busy global statistics variable corresponding to each service.
[0052] Among them, such as Figure 2 As shown, the statistical function module is configured to perform the following steps:
[0053] S21. Set the initial clock tick count and poll the message queue of the corresponding processor;
[0054] S22. In response to the polling finding that the message queue is not empty, calculate the difference in clock ticks consumed when the processor is idle, add the difference in clock ticks to the idle global statistics variable, and update the initial clock tick count.
[0055] S23. In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially;
[0056] S24. After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed by the service to the corresponding busy global statistics variable, and update the updated initial clock tick count.
[0057] Specifically, the technical solution of this invention can be applied to solid-state drives.
[0058] The solid-state drive (SSD) receives serial port commands from the user, including commands to calculate processor utilization, retrieve processor utilization, and stop calculating processor utilization. If a command to calculate processor utilization is received, the previously recorded global statistics variables are cleared, and the statistics module is started. Based on this, the statistics module calculates the proportion of time the SSD spends processing tasks within the total processing time over a given period, representing the processor utilization during that time. Statistical data can be recorded using global variables. Specifically, an idle global statistics variable and a busy global variables corresponding to each processed task are defined. During the statistical period, the time the SSD's processor is idle (i.e., the number of ticks consumed during idle time) is added to the idle global statistics variable, and the number of clock ticks consumed for each processed task is added to the corresponding busy global statistics variable. If a command to obtain processor utilization is received, the system retrieves the values of all busy and idle global statistics variables for that period. Based on the sum of all busy global statistics variables (ratio of all busy global statistics variables to the sum of all idle global statistics variables), the system calculates the total processing time for all services, i.e., the total processor utilization. Then, based on the sum of all busy global statistics variables (ratio of all busy global statistics variables to the sum of all idle global statistics variables), the system calculates the processor utilization for each service. The SSD can output the calculation results to the host via a serial port, allowing the host to display the results through its serial port. If a command to stop processor utilization is received, the system disables the statistics module, ceasing the acquisition or calculation of clock ticks to avoid interfering with SSD performance.
[0059] The statistics module calculates processor utilization by counting the number of clock ticks consumed during peak and off-peak hours. The specific process is as follows:
[0060] An initial clock tick count is set, and the message queue of the corresponding processor is polled. The processor enters a busy state only when the message queue is not empty; otherwise, it is idle. Therefore, the processor's busy state is determined by polling its message queue. Solid-state drives (SSDs) include single-core and multi-core SSDs. The processor utilization statistics command includes the utilization of the processor being measured. In response to the polling result that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated based on the current clock tick count and the initial clock tick count. This difference is then accumulated into the idle global statistics variable, and the initial clock tick count is updated based on the current clock tick count. Once the initial clock tick count is updated, the services in the message queue should be processed sequentially. After processing each service in the message queue, the difference in clock ticks consumed in processing that service should be calculated based on the clock tick count when the service was completed and the updated initial clock tick count. This difference should be accumulated into the busy global statistics variable corresponding to that service. The updated initial clock tick count should then be updated based on the clock tick count when the service was completed. This process records the clock tick count consumed when the processor is idle and the clock tick count consumed when processing each service, so that processor utilization can be calculated after receiving a command to obtain processor utilization.
[0061] The above solution enables efficient and accurate statistics on processor utilization during the bare-metal development of solid-state drive (SSD) products. It provides precise statistical data for the performance analysis of SSD products, allowing developers to determine the processor's maximum processing capacity based on utilization data, optimize processor utilization, and identify and control services that consume excessive processor utilization.
[0062] In some implementations, setting an initial clock tick count and polling the message queue of the corresponding processor includes:
[0063] Obtain the clock tick count and set the initial clock tick count based on the clock tick count;
[0064] In response to the completion of the initial clock tick count setting, the message queue of the corresponding processor is polled.
[0065] In some implementations, calculating the difference in clock ticks consumed when the processor is idle includes:
[0066] Obtain the latest clock tick count, and calculate the difference in clock tick count consumed by the processor during idle time based on the latest clock tick count and the initial clock tick count;
[0067] Updating the initial clock tick count includes:
[0068] The initial clock tick count is updated based on the latest clock tick count.
[0069] In some implementations, calculating the difference in clock ticks consumed by processing the service includes:
[0070] Obtain the clock tick count when the service processing is completed, and calculate the difference in clock tick count consumed in processing the service based on the clock tick count when the service processing is completed and the updated initial clock tick count;
[0071] Updating the initial clock tick count includes:
[0072] The updated initial clock tick count is updated based on the clock tick count when the business process is completed.
[0073] In some implementations, after updating the initial clock tick count, the method further includes:
[0074] Determine whether the message queue is empty;
[0075] In response to the message queue not being empty, the steps of processing the services in the message queue sequentially are returned in response to the completion of the initial clock tick count update.
[0076] In response to the message queue being empty, return to the step of polling the message queue of the corresponding processor in response to the completion of the initial clock tick count setting.
[0077] In some implementations, the method further includes:
[0078] In response to receiving a command to stop the utilization of the statistics processor, the statistics function module is shut down.
[0079] In one specific embodiment, the solid-state drive (SSD) receives serial port commands from the user, including commands such as commands to calculate processor utilization, commands to obtain processor utilization, and commands to stop calculating processor utilization. If a command to calculate processor utilization is received, the previously recorded global statistical variables are cleared, and the statistical function module is started. The utilization of the processor during that period is calculated based on the clock tick count obtained or calculated by the statistical function module. Specifically, statistical data can be recorded through global variables. More specifically, an idle global statistical variable and a busy global variable corresponding to each processed service are defined. During the statistical period, the time the SSD's processor is idle (i.e., the number of ticks consumed during processor idle time) is accumulated to the idle global statistical variable, and the number of clock ticks consumed by each processed service is accumulated to the corresponding busy global statistical variable. If a command to obtain processor utilization is received, the system retrieves the values of all busy and idle global statistics variables for that period. Based on the sum of all busy global statistics variables (ratio of all busy global statistics variables to the sum of all idle global statistics variables), the system calculates the total processing time for all services, i.e., the total processor utilization. Then, based on the sum of all busy global statistics variables (ratio of all busy global statistics variables to the sum of all idle global statistics variables), the system calculates the processor utilization for each service. The SSD can output the calculation results to the host via a serial port, allowing the host to display the results through its serial port. If a command to stop processor utilization is received, the system disables the statistics module, ceasing the acquisition or calculation of clock ticks to avoid interfering with SSD performance.
[0080] The above solution enables efficient and accurate statistics on processor utilization during the bare-metal development of solid-state drive (SSD) products. It provides precise statistical data for the performance analysis of SSD products, allowing developers to determine the maximum processing capacity of the processor based on the utilization data, optimize processor utilization, and identify and control services that consume excessive processor utilization.
[0081] In some implementations, the method is applied to single-core solid-state drives or multi-core solid-state drives.
[0082] The specific implementation of the present invention will be described below through a specific embodiment, which includes the following steps:
[0083] S1. Receive the command from the user to calculate the specified CPU utilization, clear the previous statistical data in the background, start the statistics function, and set the initial clock tick count (start tick).
[0084] S2. Before the CPU enters the logic of processing business functions, it is generally treated as if the business has data that needs to be processed. Therefore, the message queue of the CPU specified in the polling command is used to determine whether the CPU has entered the business function. If the message queue is not empty, the business function is entered; otherwise, it is treated as idle. The difference in ticks consumed is calculated and added to the global idle statistics variable. A new start tick value is set. Assume that there are n business functions in the current message queue.
[0085] S3. When business 1 is completed, calculate the difference in ticks consumed, add it to the global busy_1 statistical variable, and set a new start tick value.
[0086] S4. When business 2 is completed, calculate the difference in ticks consumed, add it to the global busy_2 statistical variable, and set a new start tick value. Since the statistical process of business 3 to business n-1 is the same as that of business 1 or business 2, the statistical process of business 3 to business n-1 is omitted.
[0087] S5. When business n is completed, calculate the difference in ticks consumed, add it to the global busy_n statistical variable, and set a new start tick value.
[0088] S6. When a user's command to obtain CPU utilization data is received, calculate the proportion of the time consumed by the busy variable statistics in the total time consumed by the busy and idle variables, and display the specific calculation results to the serial port. The display results are divided into the total utilization rate and the utilization rate of each service.
[0089] S7. When the user sends another command to start CPU utilization statistics, the previous statistics are cleared and the busy / idle statistics for the next cycle are started.
[0090] S8. When a user sends a command to stop CPU utilization statistics, the statistics function is turned off, and tick values are no longer acquired or calculated, so as to achieve zero interference with product performance.
[0091] The above solution enables efficient and accurate statistics on processor utilization during the bare-metal development of solid-state drive (SSD) products. It provides precise statistical data for the performance analysis of SSD products, allowing developers to determine the maximum processing capacity of the processor based on the utilization data, optimize processor utilization, and identify and control services that consume excessive processor utilization.
[0092] Based on the same inventive concept, according to another aspect of the present invention, such as Figure 3As shown, embodiments of the present invention also provide a processor utilization statistics system, including:
[0093] A receiving and cleaning module 110 is configured to clean up global statistical variables and start the statistical function module 120 in response to receiving a statistical processor utilization command. The global statistical variables include idle global statistical variables and busy global statistical variables.
[0094] The statistical function module 120 is configured as follows:
[0095] Set the initial clock tick count and poll the message queue of the corresponding processor;
[0096] In response to the polling finding that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated, and the difference in clock ticks is accumulated into the idle global statistics variable, and the initial clock tick count is updated;
[0097] In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially;
[0098] After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed in processing the service to the corresponding busy global statistics variable, and update the updated initial clock tick count.
[0099] The receiving and calculation module 130 is configured to calculate the processor utilization based on the accumulated idle global statistical variable and the busy global statistical variable corresponding to each service in response to receiving a command to obtain processor utilization.
[0100] Based on the same inventive concept, according to another aspect of the present invention, such as Figure 4 As shown, an embodiment of the present invention also provides an electronic device 30, which includes a processor 310 and a memory 320. The memory 320 stores a computer program 321 that can run on the processor. When the processor 310 executes the program, it performs the steps of the method described above.
[0101] Memory, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the processor utilization statistics method described in this application embodiment. The processor executes various system functions and data processing by running the non-volatile software programs, instructions, and modules stored in the memory, thus implementing the processor utilization statistics method described in the above embodiment.
[0102] The memory may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on system usage. Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected to the local module via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0103] Based on the same inventive concept, according to another aspect of the present invention, such as Figure 5 As shown, embodiments of the present invention also provide a computer-readable storage medium 40, which stores a computer program 410 that, when executed by a processor, performs the methods described above.
[0104] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The storage medium for the program can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. The above computer program embodiments can achieve the same or similar effects as any of the corresponding foregoing method embodiments.
[0105] Those skilled in the art will also understand that the various exemplary logic blocks, modules, circuits, and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the functionality of various illustrative components, blocks, modules, circuits, and steps has been generally described. Whether this functionality is implemented as software or as hardware depends on the specific application and the design constraints imposed on the system as a whole. Those skilled in the art can implement the functionality in various ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the embodiments disclosed herein.
[0106] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. The sequence numbers of the disclosed embodiments of this invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.
[0107] It should be understood that, as used herein, the singular form “a” is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, “and / or” refers to any and all possible combinations of one or more of the associated listed items.
[0108] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of different aspects of the invention exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.
Claims
1. A method for statistical analysis of processor utilization, characterized in that, Applied to solid-state drives, the methods include: In response to receiving a statistics processor utilization command, the global statistics variables are cleared and the statistics function module is started, wherein the global statistics variables include idle global statistics variables and busy global statistics variables; The statistical function module is configured to perform the following steps: Set the initial clock tick count and poll the message queue of the corresponding processor; In response to the polling finding that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated, and the difference in clock ticks is accumulated into the idle global statistics variable, and the initial clock tick count is updated; In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially; After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed in processing the service to the corresponding busy global statistics variable, and update the updated initial clock tick count. In response to receiving a command to obtain processor utilization, the processor utilization is calculated based on the accumulated idle global statistics and the busy global statistics corresponding to each service.
2. The method according to claim 1, characterized in that, Setting the initial clock tick count and polling the message queue of the corresponding processor includes: Obtain the clock tick count and set the initial clock tick count based on the clock tick count; In response to the completion of the initial clock tick count setting, the message queue of the corresponding processor is polled.
3. The method according to claim 1, characterized in that, Calculating the difference in clock ticks consumed when the processor is idle includes: Obtain the latest clock tick count, and calculate the difference in clock tick count consumed by the processor during idle time based on the latest clock tick count and the initial clock tick count; Updating the initial clock tick count includes: The initial clock tick count is updated based on the latest clock tick count.
4. The method according to claim 1, characterized in that, Calculating the difference in clock ticks consumed in processing the aforementioned service includes: Obtain the clock tick count when the service processing is completed, and calculate the difference in clock tick count consumed in processing the service based on the clock tick count when the service processing is completed and the updated initial clock tick count; Updating the initial clock tick count includes: The updated initial clock tick count is updated based on the clock tick count when the business process is completed.
5. The method according to claim 2, characterized in that, After updating the initial clock tick count, the process also includes: Determine whether the message queue is empty; In response to the message queue not being empty, the steps of processing the services in the message queue sequentially are returned in response to the completion of the initial clock tick count update. In response to the message queue being empty, return to the step of polling the message queue of the corresponding processor in response to the completion of the initial clock tick count setting.
6. The method according to claim 1, characterized in that, Also includes: In response to receiving a command to stop the utilization of the statistics processor, the statistics function module is shut down.
7. The method according to claim 1, characterized in that, It is applicable to single-core or multi-core solid-state drives.
8. A processor utilization statistics system, characterized in that, Applied to solid-state drives, the system includes: A receiving and cleaning module is configured to clean up global statistical variables and start a statistical function module in response to receiving a statistical processor utilization command, wherein the global statistical variables include idle global statistical variables and busy global statistical variables. The statistical function module is configured as follows: Set the initial clock tick count and poll the message queue of the corresponding processor; In response to the polling finding that the message queue is not empty, the difference in clock ticks consumed when the processor is idle is calculated, and the difference in clock ticks is accumulated into the idle global statistics variable, and the initial clock tick count is updated; In response to the completion of the initial clock tick update, the services in the message queue are processed sequentially; After processing each service in the message queue, calculate the difference in clock ticks consumed in processing the service, add the difference in clock ticks consumed in processing the service to the corresponding busy global statistics variable, and update the updated initial clock tick count. The receiving and calculation module is configured to calculate the processor utilization based on the accumulated idle global statistics variable and the busy global statistics variable corresponding to each service in response to receiving a command to obtain processor utilization.
9. An electronic device, comprising: At least one processor; as well as A memory storing a computer program executable on the processor, characterized in that the processor executes the program by performing the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it performs the steps of the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Processor availability measuring device and method
CN101067797A
Method for calculating CPU utilization rate
CN107368402A