A method for adjusting CPU frequency and terminal device

By dynamically adjusting the CPU frequency increase duration in the terminal device based on the first frame loading time of the application, the problem that the CPU frequency increase duration setting is difficult to meet the fast start-up of the application and avoid waste of power consumption is solved, achieving efficient utilization of CPU capabilities and user experience. improvement.

CN117149409BActive Publication Date: 2024-09-27HONOR DEVICE CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202310990106.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-16
Publication Date
2024-09-27
Estimated Expiration
2043-05-16

AI Technical Summary

Technical Problem

In terminal equipment, the setting of the CPU frequency increase time period is difficult to meet the needs of quick startup of applications while avoiding the problem of wasted power consumption.

Method used

By adjusting the CPU frequency increase time in real time and dynamically calculating the frequency increase time based on the first frame loading time of each application, ensuring that the CPU frequency increase time matches the cold start speed of the application, it can both speed up application startup and avoid wasting CPU resources.

Benefits of technology

It realizes full utilization of CPU capabilities, accelerates the application cold start process, avoids waste of CPU power consumption, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117149409B
    Figure CN117149409B
Patent Text Reader

Abstract

The present application provides a method and terminal device for adjusting CPU frequency, and relates to the field of terminal technology. First, cold start the first application, and increase the CPU frequency when the first application starts; after the first frequency increase duration after the first frame of the first application is loaded, the CPU frequency is reduced. After the first application is started, cold start the second application, and increase the CPU frequency when starting the second application; after the second frequency increase duration after the first frame of the second application is loaded, the CPU frequency is reduced. Since the first frequency increase duration is calculated based on the duration used to load the first frame of the first application, and the second frequency increase duration is calculated based on the duration used to load the first frame of the second application; the longer the duration used to load the first frame of the application, the longer the calculated frequency increase duration; the CPU frequency increase duration matches the estimated cold start speed of the application. It can ensure that the CPU capacity is fully utilized, accelerate the complete process of cold starting the application, and avoid CPU power consumption waste.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This case is a divisional application. The application number of the original application is 202310553047.X, and the application date of the original application is May 16, 2023. The entire contents of the original application are incorporated into this application by reference. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to a method for adjusting CPU frequency and a terminal device. Background Art

[0003] With the popularity of smart terminals, more and more applications are installed on the terminals, and users often open multiple applications. Application startup is the process from the creation process of an application to its complete display in front of the user. For users, the faster the better. Application startup consumes various resources on the terminal device, such as the central processing unit (CPU), graphics processing unit (GPU), memory, I / O (input / output) resources, etc.

[0004] Generally speaking, the terminal device will provide the maximum capacity of various resources to meet the application startup requirements. For example, when the application is started, the terminal device will increase the CPU frequency (that is, increase the CPU frequency). After the CPU frequency is increased, the CPU processing performance is improved, which can speed up the application startup speed and shorten the application startup time; after the application is started, the terminal device will no longer increase the CPU frequency and reduce the CPU frequency.

[0005] Terminal devices can set the duration of CPU frequency increase. On the one hand, if the CPU frequency increase duration is set too long, it will cause power consumption waste; on the other hand, if the CPU frequency increase duration is set too short, the maximum capacity of the CPU cannot be brought into play, and the application startup cannot be accelerated well. The application startup is slow, affecting the user experience. How to better set the CPU frequency increase duration is a problem that needs to be solved. Summary of the invention

[0006] The embodiments of the present application provide a method and terminal device for adjusting CPU frequency, which adjusts the corresponding CPU frequency increase duration in real time for each application, thereby meeting the demand for fast application startup and avoiding waste of power consumption.

[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0008] In a first aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, the terminal device includes a central processing unit (CPU), and the terminal device is installed with a first application and a second application, the method comprising: cold starting the first application (that is, before the first application is started, there is no process of the first application in the background of the terminal device system); in response to starting the first application, increasing the frequency of the CPU; after a first frequency increase duration after the first frame of the first application is loaded, reducing the frequency of the CPU. After the first application is started, cold starting the second application, that is, before the second application is started, there is no process of the second application in the background of the terminal device system; in response to starting the second application, increasing the frequency of the CPU; after a second frequency increase duration after the first frame of the second application is loaded, reducing the frequency of the CPU.

[0009] Since the first frequency boost duration is calculated based on the duration used to load the first frame of the first application, and the second frequency boost duration is calculated based on the duration used to load the first frame of the second application; the longer the duration used to load the first frame of the application, the longer the calculated frequency boost duration; the duration used to load the first frame of the first application is shorter than the duration used to load the first frame of the second application, therefore, the calculated first frequency boost duration is shorter than the second frequency boost duration.

[0010] In this method, when the first application is cold started, the CPU frequency boost duration is the sum of the duration used to load the first frame of the first application and the calculated duration used to load the remaining frames of the first application (frames between the end of loading the first frame and the completion of starting the first application), and the CPU frequency boost duration matches the estimated cold start speed of the first application. When the second application is cold started, the CPU frequency boost duration is the sum of the duration used to load the first frame of the second application and the calculated duration used to load the remaining frames of the second application (frames between the end of loading the first frame and the completion of starting the second application), and the CPU frequency boost duration matches the estimated cold start speed of the second application. The CPU frequency boost duration is matched with the cold start speed of each application respectively, which can ensure that the CPU capacity is fully utilized, accelerate the complete process of cold starting the application, and avoid waste of CPU power consumption.

[0011] The terminal device stores a preset corresponding relationship. The first frequency increase duration is obtained according to the duration used for loading the first frame of the first application and the preset corresponding relationship; the second frequency increase duration is obtained according to the duration used for loading the first frame of the second application and the corresponding relationship.

[0012] In other words, the CPU frequency boost duration is related to the time taken to load the first frame of the application. The longer the time taken to load the first frame of the application, the longer the estimated application loading time, and accordingly, the longer the CPU frequency boost duration; the CPU frequency boost duration matches the startup speed of the application.

[0013] In combination with the first aspect, in a possible implementation, the first frame of the first application is loaded, including: the main interface Activity of the first application is started; the first frame of the second application is loaded, including: the main interface Activity of the second application is started.

[0014] In combination with the first aspect, in a possible implementation manner, increasing the frequency of the CPU is to increase the frequency of the CPU from a first value to a second value; and reducing the frequency of the CPU is to reduce the frequency of the CPU from the second value to the first value.

[0015] In a second aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, wherein the terminal device includes a central processing unit (CPU), and the terminal device is installed with a first application and a second application, and the method includes:

[0016] Starting a first application, wherein before the first application is started, there is no process of the first application in the background of the terminal device system;

[0017] In response to starting the first application, increasing the frequency of the CPU;

[0018] Starting a second application; wherein, before the second application is started, there is no process of the second application in the background of the terminal device system; the second application is started after the first application is started, and when the second application is started, the first application has not been started completely;

[0019] After the second frequency increase time period after the first frame of the second application is loaded, the frequency of the CPU is reduced.

[0020] In combination with the second aspect, in a possible implementation, the method also includes: obtaining a first frequency boost duration based on a duration used for loading a first frame of the first application and a preset corresponding relationship; obtaining a second frequency boost duration based on a duration used for loading a first frame of the second application and a preset corresponding relationship; wherein, the duration used for loading the first frame of the first application is less than the duration used for loading the first frame of the second application, and the first frequency boost duration is less than the second frequency boost duration.

[0021] In this method, if the startup processes of multiple applications overlap on the timeline, the CPU frequency is increased when the application with the earliest startup time is started. When the calculated time when the latest startup completion time of multiple applications arrives, the CPU frequency is reduced. In this way, the CPU frequency increase duration matches the cold start speed of the application, which can ensure that the CPU capacity is fully utilized, accelerate the complete process of application cold start, and avoid CPU power consumption waste.

[0022] In a third aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, wherein the terminal device includes a central processing unit (CPU), and the terminal device is installed with a first application, and the method includes:

[0023] The first application is started at a first moment, and in response to starting the first application, the CPU frequency is increased; wherein the startup process of the first application includes a first stage and a second stage, the second stage is a stage other than the first stage in the startup process of the first application, and the second stage is after the first stage. The duration of the first stage is obtained according to the first moment and the second moment (the moment when the first stage startup of the first application is completed); the duration of the second stage is determined according to the duration of the first stage and a preset corresponding relationship; the third moment (the end moment of the second stage) is determined according to the duration of the second stage; at the third moment, the CPU frequency is reduced.

[0024] In this method, the first application is started, and the CPU frequency is increased (the CPU frequency is increased). When the first stage of the first application startup is completed (for example, the main interface Activity of the first application is loaded), the duration of the second stage startup of the first application is estimated based on the duration used in the first stage, and the estimated duration required for the second stage startup is used as the remaining duration of the CPU frequency increase, that is, the CPU frequency increase duration is dynamically adjusted according to the duration used in the first stage (for example, the duration of the first frame startup), so that the CPU frequency increase duration is equal to the estimated duration of the first application startup completion; that is, the CPU frequency increase duration matches the startup speed of the first application. It can not only ensure that the CPU capacity is fully utilized, accelerate the complete process of the cold start of the first application, but also avoid CPU power consumption waste. Since the CPU frequency increase duration of the first application is dynamically obtained based on the actual situation of the first application startup this time, the determined CPU frequency increase duration is more accurate and the utilization of CPU capacity is more efficient.

[0025] In combination with the third aspect, in a possible implementation, the first stage is a stage in which the first frame of the first application is loaded.

[0026] In combination with the third aspect, in a possible implementation manner, the first frame of the first application is loaded completely, including: the main interface Activity of the first application is started completely.

[0027] In combination with the third aspect, in a possible implementation, increasing the frequency of the CPU includes: increasing the frequency of the CPU from a first value to a second value; and reducing the frequency of the CPU includes: reducing the frequency of the CPU from the second value to the first value.

[0028] In conjunction with the third aspect, in a possible implementation, the corresponding relationship is obtained by performing linear regression on startup data of N applications (for example, N applications with the highest user frequency according to statistics); wherein the startup data of the i-th application among the N applications includes: the duration X used in the first stage of the startup process of the i-th application; i , and the duration Y of the second phase of the i-th application startup process i; where N>0.

[0029] That is, according to the actual situation of the startup process of the N applications counted, the corresponding relationship between the first stage and the second stage of the application startup is obtained. In this way, the duration of the second stage estimated according to the duration of the first stage is more accurate.

[0030] In conjunction with the third aspect, in a possible implementation, before the first application is started, there is no process of the first application in the background of the terminal device system. In other words, the startup process is a cold start.

[0031] In combination with the third aspect, in a possible implementation, the terminal device receives a start-up operation of a first application from a user; and starts the first application in response to the start-up operation.

[0032] In combination with the third aspect, in a possible implementation, in response to a call from the second application, the first application is started.

[0033] In combination with the third aspect, in a possible implementation, if it is determined that the sum of the duration used in the first stage and the duration used in the second stage is less than or equal to the preset maximum frequency increase duration threshold, a third moment is obtained based on the duration used in the second stage, and the CPU frequency is reduced at the third moment. If it is determined that the sum of the duration used in the first stage and the duration used in the second stage is greater than the preset maximum frequency increase duration threshold, a fourth moment is obtained based on the maximum frequency increase duration threshold, and the fourth moment is a moment later than the first moment by the maximum frequency increase duration threshold; at the fourth moment, the CPU frequency is reduced.

[0034] In this method, a maximum frequency boost duration threshold of the CPU frequency boost is pre-set, which indicates the maximum value of the CPU frequency boost duration of the terminal device. In other words, the CPU frequency boost duration should be less than or equal to the maximum frequency boost duration threshold. In this way, it can be avoided that the cold start of the first application occupies too much CPU resources, resulting in other processes not being able to allocate CPU resources, causing system freezes.

[0035] In a fourth aspect, a terminal device is provided, which has the function of implementing the method described in the first aspect, the second aspect or the third aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.

[0036] In a fifth aspect, a terminal device is provided, comprising: a processor and a memory; the memory is used to store computer execution instructions, and when the terminal device is running, the processor executes the computer execution instructions stored in the memory to enable the terminal device to perform a method as described in any one of the first aspect, the second aspect or the third aspect above.

[0037] In a sixth aspect, a terminal device is provided, comprising: a processor; the processor is used to couple with a memory, and after reading instructions in the memory, execute a method as described in any one of the first aspect, the second aspect or the third aspect according to the instructions.

[0038] In a seventh aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer can execute any of the methods in the first aspect, the second aspect or the third aspect.

[0039] In an eighth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the methods in the first, second or third aspects above.

[0040] In a ninth aspect, a device (for example, the device may be a chip system) is provided, the device including a processor for supporting a terminal device to implement the functions involved in the first aspect, the second aspect, or the third aspect. In one possible design, the device also includes a memory for storing program instructions and data necessary for the terminal device. When the device is a chip system, it may be composed of a chip, or may include a chip and other discrete devices.

[0041] Among them, the technical effects brought about by any design method in the fourth to ninth aspects can refer to the technical effects brought about by different design methods in the first, second or third aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1A A schematic diagram showing that the CPU frequency boosting time is longer than the application cold start time;

[0043] Figure 1B A schematic diagram showing that the CPU frequency boosting duration is shorter than the application cold start duration;

[0044] Figure 2 A schematic diagram of the principle of the method for adjusting CPU frequency provided in an embodiment of the present application;

[0045] Figure 3 A flowchart of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0046] Figure 4 A schematic diagram of the hardware structure of a terminal device applicable to the method for adjusting CPU frequency provided in an embodiment of the present application;

[0047] Figure 5A A schematic diagram of the software architecture of a terminal device applicable to the method for adjusting CPU frequency provided in an embodiment of the present application;

[0048] Figure 5B A schematic diagram of module interaction of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of a CPU frequency increase processing method when two applications with different cold start speeds are started on a terminal device provided in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of a scenario example of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0051] Figure 8 A schematic diagram of another scenario example of the method for adjusting CPU frequency provided in an embodiment of the present application;

[0052] Fig. 9 A schematic diagram of another scenario example of the method for adjusting CPU frequency provided in an embodiment of the present application;

[0053] Fig.10 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0054] Fig.11 A schematic diagram of the chip system structure provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] In the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include such expressions as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are a kind of "or" relationship.

[0056] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

[0057] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0058] There are many ways to start an application, such as cold start and hot start; among them, the cold start of an application is a relatively time-consuming method. Before application A is started, if there is no process of application A in the background of the terminal device system, the system needs to create a new process for application A, and this startup process is recorded as a cold start. Before application A is started, if there is a process of application A in the background of the terminal device system, the system no longer needs to create a process for application A, and this startup process is recorded as a hot start. It should be noted that in the embodiment of the present application, before application A is enabled, it refers to when application A is about to start; that is, when application A is triggered to start, and within a short period of time before application A is triggered to start.

[0059] In some scenarios, the user's operation triggers the cold start of an application. For example, the desktop of the terminal device includes an application icon 1 of application 1, and the user clicks application icon 1. In response to the user's click operation on application icon 1, application 1 is cold started. For example, the user inputs a voice "open application 1", and in response to receiving the user's voice, application 1 is cold started. In some scenarios, the call of other applications triggers the cold start of an application. For example, application 2 is running on the terminal device, and application 2 pulls up application 1, and application 1 is cold started.

[0060] The cold start process may include, from receiving the user's operation to start the application or the call of other applications, to the application main interface being fully displayed on the terminal screen. Usually, the terminal will accelerate the application cold start process and shorten the application cold start time by increasing the CPU frequency. CPU frequency increase is also called CPU frequency pull, which refers to increasing the CPU's operating frequency to the highest value or higher value of its operating frequency range so that the application is allocated more processing resources. In one implementation, the CPU's operating frequency can be increased to a target frequency; in another implementation, the CPU's operating frequency can be increased by a preset amount.

[0061] Generally speaking, the terminal will set a unified CPU frequency increase duration. When the application cold starts, the CPU frequency increase is triggered; when the CPU frequency increase duration expires, the CPU frequency increase is stopped. This method is a general solution for all applications, and the CPU frequency increase duration for all applications is the same.

[0062] However, the cold start durations of different applications vary greatly. For example, Table 1 shows the cold start durations of 20 different applications on the same terminal.

[0063] Table 1

[0064]

[0065]

[0066] It can be seen that the longest and shortest cold start durations differ by about 3.7 seconds. A unified CPU frequency increase duration configuration cannot be applied to every application.

[0067] refer to Figure 1A If the CPU frequency increase duration is set to a larger value, the CPU usage requirements of applications with slow cold start can be met; when applications with short cold start duration are cold started, long CPU frequency increase will cause a waste of CPU resources and waste too much power. For example, if the CPU frequency increase duration is set to 4714ms; when application 18 is cold started, it can be started in 1053ms, and the remaining 3661ms of CPU frequency increase resources are wasted; when application 12 is cold started, it can be started in 2042ms, and the remaining 2672ms of CPU frequency increase resources are wasted.

[0068] refer to Figure 1B If the CPU frequency increase duration is set to a smaller value, the CPU usage requirements of applications with faster cold start can be met; when an application with a longer cold start duration is cold started, the CPU frequency increase duration has expired and the application has not completed the cold start, which will cause the application to cold start too slowly, affecting the user experience, and the maximum capacity of the CPU cannot be brought into play, resulting in a waste of CPU capacity.

[0069] The embodiment of the present application provides a method for adjusting the CPU frequency. For each application, the corresponding CPU frequency boost duration is dynamically adjusted according to the actual speed of the application during the current cold start process. The CPU frequency boost duration matches the cold start speed of each application, which can not only ensure that the CPU capacity is fully utilized and accelerate the cold start of the application, but also avoid CPU power consumption waste. Moreover, for each application, the CPU frequency boost duration of the application is dynamically acquired based on the actual situation of the application's current cold start. Compared with the method of statically configuring the CPU frequency boost duration of the application, the method for adjusting the CPU frequency provided in the embodiment of the present application can obtain a CPU frequency boost duration that is more in line with the current actual situation of the application and utilize CPU resources more efficiently.

[0070] It can be understood that from the time the terminal device receives the user's operation to start an application or a call from other applications and starts to start the first application, during the time period of the first application's cold start process, the terminal device will load the first application's startup guide interface, advertising interface, welcome interface, main interface, content interface, etc.; until the first application's main interface and various elements, controls, pop-ups, etc. on the main interface are fully presented on the terminal device screen, the cold start process of the first application is completed.

[0071] In the method for adjusting CPU frequency provided by the embodiment of the present application, the terminal device receives the operation of starting an application by the user or the call of other applications, the cold start of the first application starts, and the terminal device triggers CPU frequency increase; at the end of the first stage of the cold start of the first application, the terminal device obtains the first duration of the first stage cold start process, and dynamically obtains the second duration of the second stage cold start process (the stage other than the first stage in the cold start process) according to the first duration; after the second duration after the end of the first stage, the terminal device stops CPU frequency increase. In other words, the total duration of CPU frequency increase is the sum of the first duration and the second duration, that is, the total duration of CPU frequency increase matches the cold start speed of the first application.

[0072] For different terminals, or for the same terminal under different loads, the cold start speed of the same application is different. If the CPU frequency boost duration of each application is pre-configured, the configuration data may not match the actual situation when the application is cold started, and accurate configuration cannot be achieved. The method for adjusting the CPU frequency provided in the embodiment of the present application dynamically adjusts the total duration of the CPU frequency boost (first duration + second duration) according to the actual duration of the first stage of cold start of the first application (first duration), so that the total duration of the CPU frequency boost matches the actual speed of the first application in this cold start; it can provide CPU frequency boost capability throughout the entire process of cold start of the first application, ensure that the CPU capability is fully utilized, and accelerate the cold start of the first application; and avoid the waste of CPU power consumption caused by too long CPU frequency boost time.

[0073] In one embodiment, the first stage of the cold start of the first application is the stage of loading the first frame of the first application. Figure 2 , receiving the user's startup operation (such as the user clicking the application icon of the first application) or the call of other applications, the first application is started, and the CPU frequency increase begins. When the first frame of the first application is loaded, the terminal device obtains the duration of the first frame loading of the first application, that is, obtains the first duration. Among them, the completion of the loading of the first frame of the first application means that the main interface Activity of the first application is started; that is, the first stage is: the first application starts to start (receives the user's operation to start the application or the call of other applications) to the completion of the startup of the main interface Activity (MainActivity) of the first application.

[0074] The terminal device calculates the second duration based on the first duration; the second duration is the duration of loading the remaining frames except the first frame during the startup of the first application, that is, the duration from the completion of loading the first frame of the first application to the completion of the cold start of the first application. The completion of the startup of the first application means that all elements (controls, pop-up windows, etc.) on the main interface Activity (MainActivity) of the first application are loaded, that is, all elements on the main interface Activity of the first application are drawn and successfully displayed.

[0075] In one implementation, the cold start data of the N (e.g., 100) most frequently used applications on the same platform can be collected in advance. The time X taken for the first frame to be loaded during the cold start process of each of the N applications, and the time Y taken from the first frame to be loaded to the cold start of the application are obtained. For example, the data of the cold start process of N applications is collected to obtain (X 1 , Y 1 ), (X 2 , Y 2 ), ..., (X i , Y i ), ..., (X N , Y N ). According to (X 1 , Y 1 ), (X 2 , Y 2 ), ..., (X i , Y i ), ..., (X N , Y N ), perform linear regression to obtain the corresponding relationship between the time X taken to complete the loading of the first frame and the time Y taken from the completion of the loading of the first frame to the completion of the cold start of the first application. For example, the corresponding relationship between X and Y is, Y = aX + b, according to (X 1 , Y 1 ), (X 2, Y 2 ), ..., (X i , Y i ), ..., (X N , Y N ) performs linear regression to calculate the values ​​of a and b; thus, the corresponding relationship between the time X taken to complete the loading of the first frame and the time Y taken from the completion of the loading of the first frame to the completion of the cold start of the first application is obtained.

[0076] It is understandable that in other implementations, it is not necessary to collect actual data of N application cold starts, but to pre-configure the correspondence between X and Y. For example, Y=X is pre-set. In other implementations, X and Y may not be in a linear correspondence. For example, X=Y 2 wait.

[0077] The terminal device can save the correspondence between X and Y in advance, for example, save the values ​​of a and b. When the terminal device completes loading the first frame of the first application, it obtains the first duration, that is, obtains the value of X. The terminal device can calculate the value of Y based on the correspondence between X and Y, that is, obtains the value of the second duration. After the second duration, the terminal device stops CPU frequency increase.

[0078] From the start of CPU frequency increase to the end of CPU frequency increase, the CPU frequency increase duration is the sum of the first duration and the second duration. Since the sum of the first duration and the second duration is also the duration from the start to the completion of the first application startup, the CPU frequency increase duration matches the total duration of the first application startup process.

[0079] In one implementation, a maximum frequency boost duration threshold of the CPU frequency boost can be pre-set, indicating the maximum value of the CPU frequency boost duration of the terminal device. That is, if the second duration is less than or equal to the difference between the maximum frequency boost duration threshold and the first duration, that is, the second duration <= (maximum frequency boost duration threshold - first duration), the CPU frequency boost cutoff time is determined according to the second duration. If the second duration is greater than the difference between the maximum frequency boost duration threshold and the first duration, the CPU frequency boost cutoff time is determined according to the maximum frequency boost duration threshold. In this way, it can be avoided that the cold start of the first application occupies too many CPU resources, resulting in other processes not being able to allocate CPU resources, causing system freezes.

[0080] Figure 3 A schematic diagram of a process for adjusting CPU frequency provided by an embodiment of the present application is shown. Figure 3 As shown, the method may include:

[0081] S101, the first application is started.

[0082] In one implementation, the terminal device receives an operation of starting the first application from the user, and in response to the operation, the first application is started. For example, the user clicks the application icon of the first application, and the first application is started. For example, the terminal device receives a voice input of "open the first application" from the user, and the first application is started.

[0083] In one implementation, the first application is started in response to a call from the second application. For example, the payment application is started in response to a call from the shopping application.

[0084] S102: Determine whether the first application is cold started. If the first application is cold started, execute S103.

[0085] Optionally, the terminal device determines whether the first application is cold started. In one implementation, if it is determined that before the first application is started, there is no process corresponding to the first application in the operating system, it is determined that the first application is cold started. Exemplarily, upon receiving a user's startup operation or responding to a call of the second application, it is determined that there is no process corresponding to the first application in the operating system, and the operating system creates a process corresponding to the first application.

[0086] It should be noted that, in the embodiment of the present application, the cold start process of the first application is used as an example to introduce in detail the method for adjusting the CPU frequency provided in the embodiment of the present application. In other embodiments, the method for adjusting the CPU frequency provided in the embodiment of the present application can be applied to other scenarios that require CPU frequency increase, such as hot starting the first application, performing a sliding operation on the window of the first application, and performing a sliding operation on the interface of the first application. The method for adjusting the CPU frequency in these scenarios can refer to the cold start scenario of the first application, and examples are no longer given one by one in the embodiment of the present application.

[0087] S103, start CPU frequency increase and mark the first moment.

[0088] The first moment is the start moment of CPU frequency increase.

[0089] CPU frequency boosting means increasing the frequency of the CPU; for example, increasing the frequency of the CPU from the current first value to a second value, where the second value is greater than the first value. It is understandable that the CPU may include multiple CPU cores. In one implementation, increasing the frequency of the CPU means increasing the frequency of all CPU cores. In another implementation, the frequency of the CPU core bound to the first application may be increased, that is, increasing the frequency of some of the multiple CPU cores.

[0090] S104: Load a first frame of a first application.

[0091] After the first application is started, the first frame begins to be loaded.

[0092] S105. The first frame of the first application is loaded completely at the second moment, and the duration used to load the first frame of the first application is obtained, that is, the first duration is obtained.

[0093] In one implementation, the main interface Activity of the first application is started up, that is, it is determined that the first frame of the first application is loaded. The time when the main interface Activity of the first application is started up is the second time.

[0094] Among them, the first frame loading duration of the first application (first duration) = the second moment - the first moment.

[0095] S106. Calculate a second duration according to the first duration.

[0096] The second duration is calculated based on the correspondence between the duration X of the first frame loading completion and the duration Y of the first frame loading completion to the first application cold start completion, and the first duration. The second duration is estimated based on the duration of the first frame loading completion and the correspondence between X and Y. In other words, based on the duration of the first frame loading completion, the duration of the first frame loading completion to the first application cold start completion is estimated.

[0097] S107: Determine a CPU frequency increase cutoff time according to the second duration.

[0098] In one implementation, a maximum CPU frequency increase duration threshold is preset.

[0099] If it is determined that the sum of the first frame loading duration (first duration) of the first application and the calculated second duration is less than or equal to the maximum frequency increase duration threshold, the CPU frequency increase cutoff time (third time) is determined to be = second time + second duration.

[0100] If it is determined that the sum of the first frame loading duration (first duration) and the second duration of the first application is greater than the maximum frequency boost duration threshold, the CPU frequency boost cutoff time (fourth time) is determined to be = second time + (maximum frequency boost duration threshold - first duration).

[0101] S108, when the CPU frequency increase cut-off time is reached, the CPU frequency increase is stopped.

[0102] In one implementation, when the CPU frequency increase cut-off time is reached, the CPU frequency is no longer increased. Exemplarily, after the CPU frequency is increased, the CPU frequency is the second value, and when the CPU frequency increase cut-off time is reached, the CPU frequency is reduced. For example, the CPU frequency is reduced from the current second value to the first value.

[0103] If the CPU includes multiple CPU cores. In one possible implementation, the frequency of the CPU core bound to the first application is increased in S103; then the frequency of the CPU core bound to the first application is reduced to the first value. In one possible implementation, the frequency of all CPU cores is increased in S103 (from the first value to the second value). Optionally, in one example, the frequency of all CPU cores can be reduced to the first value. In another example, the frequency of a portion of the multiple CPU cores can be maintained at the second value, and another portion of the multiple CPU cores can be turned off.

[0104] The method for adjusting CPU frequency provided in an embodiment of the present application is that in response to the user's operation of starting the first application, or the second application's call to the first application, the first application is started. The first application is started, and the CPU frequency boost begins. When the main interface Activity of the first application is loaded, the remaining duration of the CPU frequency boost is calculated according to the duration of the first frame loaded by the first application, that is, the CPU frequency boost duration is dynamically adjusted according to the startup duration of the first frame. The CPU frequency boost duration matches the startup speed of the first application, which can not only ensure that the CPU capacity is fully utilized, accelerate the complete process of the cold start of the first application, but also avoid CPU power consumption waste. Since the CPU frequency boost duration of the first application is dynamically acquired based on the actual situation of the first application's startup this time, the determined CPU frequency boost duration is more accurate and the utilization of CPU capacity is more efficient.

[0105] The method for adjusting CPU frequency provided in the embodiment of the present application can be applied to terminal devices that support CPU frequency increase. The above-mentioned terminal devices may include mobile phones, tablet computers, laptops, personal computers (PCs), ultra-mobile personal computers (UMPCs), handheld computers, netbooks, smart home devices (e.g., smart TVs, smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (e.g., smart watches, smart bracelets, etc.), vehicle-mounted devices, virtual reality devices, etc., and the embodiments of the present application do not impose any restrictions on this.

[0106] It should be understood that, in addition to terminal devices, the method provided in the embodiment of the present invention can also be applied to other types of computer systems.

[0107] For example, please refer to Figure 4, which shows a schematic diagram of the structure of a terminal device 100. The terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, an audio module 130, a speaker 130A, a microphone 130B, a display screen 140, a communication module 150, a power module 160, an input device 170, a sensor module 180, etc. Among them, the sensor module 180 may include a pressure sensor, a touch sensor, etc.

[0108] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0109] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), and / or a neural-network processing unit (NPU). Different processing units may be independent components or integrated into one or more processors. In some embodiments, the terminal device 100 may also include one or more processors 110.

[0110] The controller is the nerve center and command center of the terminal device 100. It can generate operation control signals according to instruction operation codes and timing signals to complete the control of fetching and executing instructions.

[0111] The application processor can run the operating system of the terminal device 100, which is used to manage the hardware and software resources of the terminal device 100. For example, it manages and configures memory, determines the priority of system resource supply and demand, controls input and output devices, operates the network, manages the file system, manages drivers, etc. The operating system can also be used to provide an operating interface for users to interact with the system. Among them, various types of software can be installed in the operating system, such as drivers, applications (applications, Apps), etc.

[0112] NPU is a neural network (NN) computing processor, which can quickly process input information and continuously self-learn by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. NPU can realize applications such as intelligent cognition of the terminal device 100.

[0113] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0114] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM card interface, and / or a USB interface, etc.

[0115] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0116] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0117] The internal memory 121 can be used to store one or more computer programs, which include instructions. The processor 110 can execute the above instructions stored in the internal memory 121, so that the terminal device 100 executes the application running method provided in some embodiments of the present application, as well as various applications and data management. The internal memory 121 may include a code storage area and a data storage area. Among them, the data storage area can store data created during the use of the terminal device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage components, flash memory components, universal flash storage (universal flash storage, UFS), etc. In some embodiments, the processor 110 can execute the application running method provided in the embodiment of the present application, as well as other applications and data management by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor 110.

[0118] The terminal device 100 can implement audio functions through the audio module 130, the speaker 130A, the microphone 130B, and the application processor. For example, music playing, recording, etc. The audio module 130 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 130 can also be used to encode and decode audio signals. In some embodiments, the audio module 130 can be arranged in the processor 110, or some functional modules of the audio module 130 can be arranged in the processor 110.

[0119] The speaker 130A, also called a "horn", is used to convert audio electrical signals into sound signals.

[0120] The microphone 130B, also called a "microphone" or "speaker", is used to convert a sound signal into an electrical signal. A user can make a sound by approaching the microphone 130B with his or her mouth, and input the sound signal into the microphone 130B.

[0121] The communication function of the terminal device 100 can be realized through antenna 1, antenna 2 and communication module 150, etc.

[0122] The communication module 150 can provide solutions for wireless communications including cellular, Wi-Fi, Bluetooth (BT), wireless data transmission modules (e.g., 433MHz, 868MHz, 915MHz) applied to the terminal device 100. The communication module 150 can be one or more devices integrating at least one communication processing module. The communication module 150 receives electromagnetic waves via antenna 1 or antenna 2, filters and frequency modulates the electromagnetic wave signals, and sends the processed signals to the processor 110. The communication module 150 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through antenna 1 or antenna 2.

[0123] The terminal device 100 implements the display function through a GPU, a display screen 140, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 140 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0124] The display screen 140 is used to display images, videos, etc. The display screen 140 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal device 100 may include 1 or N display screens 140, where N is a positive integer greater than 1. In the embodiment of the present application, the display screen 140 can be used to display a UI and receive user operations on the UI.

[0125] In some embodiments, the display screen 140 is provided with a pressure sensor, a touch sensor, and the like. The pressure sensor is used to sense pressure signals and can convert pressure signals into electrical signals. When a touch operation is applied to the display screen 140, the terminal device 100 detects the intensity of the touch operation according to the pressure sensor. The terminal device 100 can also calculate the position of the touch according to the detection signal of the pressure sensor. The touch sensor, also known as a "touch panel", can form a touch screen, also known as a "touch screen", with the display screen 140. The touch sensor is used to detect touch operations applied thereto or thereabout. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can also be provided through the display screen 140.

[0126] The power module 160 may be used to supply power to various components included in the terminal device 100. In some embodiments, the power module 160 may be a battery, such as a rechargeable battery.

[0127] The input device 170 may include a keyboard, a mouse, etc. The keyboard is used to input English letters, numbers, punctuation marks, etc. into the terminal device 100, thereby issuing commands to the terminal device 100, inputting data, etc. The mouse is an indicator for the vertical and horizontal coordinates of the display system of the terminal device 100, and is used to input instructions, etc. to the terminal device 100. Among them, the input device 170 can be connected to the terminal device 100 through a wired connection, for example, the input device 170 is connected to the terminal device 100 through a GPIO interface, a USB interface, etc. The input device 170 can also be connected to the terminal device 100 wirelessly, for example, the input device 170 is connected to the terminal device 100 through Bluetooth, infrared, etc.

[0128] In the embodiment of the present application, the terminal device 100 is a terminal device that can run an operating system and install application programs. Optionally, the operating system running on the terminal device can be system, system, System, etc.

[0129] Take the terminal device 100 as an example, which is a mobile phone. The software system of the terminal device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes the Android system of the layered architecture as an example to illustrate the software structure of the terminal device 100.

[0130] Figure 5A It is a software structure block diagram of the terminal device 100 according to an embodiment of the present invention.

[0131] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0132] The application layer can include a series of application packages, such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, application 1, application 2, application 3 and other applications.

[0133] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0134] like Figure 5A As shown, the application framework layer may include a window manager, a content provider, a call manager, a view system, a resource manager, a notification manager, an activity manager service (AMS), a frequency calculation module 1, and the like.

[0135] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0136] The call manager is used to provide communication functions of the terminal device 100, such as management of call status (including connection, disconnection, etc.).

[0137] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0138] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0139] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0140] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, the terminal device vibrates, the indicator light flashes, etc.

[0141] AMS is mainly responsible for the startup, switching, and scheduling of the four major components in the system, as well as the management and scheduling of application processes. Its responsibilities are similar to the process management and scheduling modules in the operating system. When a process or component is started, the request will be passed to AMS through the Binder communication mechanism, and AMS will then handle it uniformly.

[0142] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0143] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0144] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0145] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0146] A 2D graphics engine is a drawing engine for 2D drawings.

[0147] Android runtime is responsible for the scheduling and management of the Android system. Android runtime includes core libraries and virtual machines.

[0148] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0149] The core library includes a frequency increase calculation module 2. The frequency increase calculation module 1 and the frequency increase calculation module 2 jointly manage the CPU frequency increase duration and the like.

[0150] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0151] The kernel layer is the layer between hardware and software. The kernel layer can include display drivers, sensor drivers, CPU kernels, etc.

[0152] The following is an illustrative introduction to the method for adjusting the CPU frequency provided in an embodiment of the present application in conjunction with the software architecture of the terminal device 100.

[0153] For example, Figure 5A As shown, application 1 starts to start. For example, the mobile phone displays a user interface on the screen. The user interface includes an application icon of application 1. The user clicks the application icon of application 1. In response to receiving the operation of the user clicking the application icon of application 1, application 1 sends an application 1 start request to AMS. AMS starts application 1 and notifies the core library that application 1 has started. The core library sends a frequency increase event to the CPU core. The CPU core receives the frequency increase event and triggers CPU frequency increase.

[0154] When the first frame of application 1 is loaded, application 1 notifies frequency increase calculation module 1 that the first frame is loaded. Frequency increase calculation module 1 calculates the loading time of the first frame of application 1. Then frequency increase calculation module 2 in the core library is called to calculate the CPU frequency increase deadline based on the loading time of the first frame of application 1. The core library sends the frequency increase end event and frequency increase deadline to the CPU core. The CPU core receives the frequency increase end event and stops CPU frequency increase when the frequency increase deadline is reached.

[0155] Exemplary, combined Figure 5A The software architecture shown is Figure 5B A schematic diagram of module interaction of a method for adjusting CPU frequency provided in an embodiment of the present application is shown.

[0156] like Figure 5B As shown, the method for adjusting the CPU frequency provided in the embodiment of the present application may include:

[0157] S601: Application 1 receives a start operation from a user.

[0158] Exemplarily, application 1 receives an operation of a user clicking on an application icon of application 1 at a first moment, and records the first moment.

[0159] S602: Application 1 sends a start request to AMS.

[0160] In response to receiving the start operation from the user, application 1 sends a start request to the AMS.

[0161] S603: AMS starts application 1.

[0162] AMS receives the start request, starts loading the first frame of application 1, and creates the Activity corresponding to the first frame.

[0163] S604. AMS notifies the core library that application 1 has been started.

[0164] S605: The core library sends a frequency increase event to the CPU core.

[0165] The core library receives the notification that application 1 has been started and sends a frequency increase event to the CPU core.

[0166] S606: The CPU core triggers CPU frequency increase.

[0167] In one implementation, the CPU core increases the frequency of the CPU from a first value to a second value. The CPU operates at a higher frequency, which can speed up the startup process of the application 1.

[0168] S607 , the first frame of application 1 is loaded completely, and application 1 notifies frequency increase calculation module 1 that the first frame is loaded completely.

[0169] Exemplarily, the Activity corresponding to the first frame of application 1 is started, and application 1 notifies frequency increase calculation module 1 that the loading of the first frame is completed.

[0170] S608. The frequency increase calculation module 1 calculates the loading time of the first frame of the application 1.

[0171] In one implementation, the frequency calculation module 1 receives a notification of completion of loading the first frame at the second moment, and calculates the loading duration of the first frame of application 1 according to the second moment and the saved first moment. The loading duration of the first frame of application 1 is the difference between the second moment and the first moment.

[0172] S609: The frequency increase calculation module 1 sends the calculated first frame loading duration to the frequency increase calculation module 2.

[0173] S610: The frequency increase calculation module 2 calculates the duration from the completion of loading of the first frame to the completion of starting of the application 1 according to the first frame loading duration.

[0174] In one implementation, the frequency increase calculation module 2 calculates the duration from the completion of loading the first frame to the completion of starting the application 1 according to the first frame loading duration and a preset correspondence relationship (pre-saved correspondence relationship between X and Y).

[0175] S611. The frequency increase calculation module 2 obtains a frequency increase cutoff time according to the time from when the first frame is loaded to when the application 1 is started.

[0176] In one implementation, if the duration from the completion of loading the first frame to the completion of launching application 1 is less than or equal to (maximum frequency increase duration threshold - first frame loading duration), the CPU frequency increase deadline is determined to be (second moment + duration from the completion of loading the first frame to the completion of launching application 1). If the duration from the completion of loading the first frame to the completion of launching application 1 is greater than (maximum frequency increase duration threshold - first frame loading duration), the CPU frequency increase deadline is determined to be (first moment + maximum frequency increase duration threshold).

[0177] S612: The frequency increase calculation module 2 sends a frequency increase end event and a frequency increase deadline to the CPU core.

[0178] S613: When the frequency increase cut-off time is reached, the CPU core stops CPU frequency increase.

[0179] In one implementation, when the CPU frequency increase cut-off time is reached, the CPU frequency is no longer increased. Exemplarily, the CPU frequency is reduced from the current second value to the first value.

[0180] The method for adjusting the CPU frequency provided in the embodiment of the present application dynamically calculates the CPU frequency increase duration for each application according to the actual speed of the application during the current cold start process.

[0181] For example, Figure 6 A schematic diagram of a CPU frequency increase processing method when two applications with different cold start speeds are started on a terminal device is shown.

[0182] In one scenario, reference Figure 6 (a), the terminal device receives an operation by the user to start application 1 or a call from other applications, application 1 starts to cold start, and the terminal device triggers CPU frequency boost. Start loading the first frame of application 1. When the first frame of application 1 is loaded, the terminal device obtains the duration of loading the first frame of application 1. The terminal device calculates the duration used to load the remaining frames of application 1 (frames between the end of loading the first frame and the completion of application 1 startup) based on the duration used to load the first frame of application 1 and the saved correspondence, that is, obtains the first frequency boost duration. After the first frequency boost duration after the first frame of application 1 is loaded, the CPU frequency is reduced.

[0183] In one scenario, reference Figure 6(b), the terminal device receives an operation by the user to start application 2 or a call from other applications, application 2 starts to cold start, and the terminal device triggers CPU frequency increase. Start loading the first frame of application 2. When the first frame of application 2 is loaded, the terminal device obtains the duration of loading the first frame of application 2. The terminal device calculates the duration used to load the remaining frames of application 2 (frames between the end of loading the first frame and the completion of starting application 2) based on the duration used to load the first frame of application 2 and the saved correspondence, that is, obtains the second frequency increase duration. After the second frequency increase duration after the first frame of application 2 is loaded, the CPU frequency is reduced.

[0184] It can be seen that when the cold start duration of application 1 is shorter than that of application 2; for example, the cold start duration of application 1 is 1261ms, and the cold start duration of application 2 is 4714ms; the duration used to load the first frame of application 1 is shorter than the duration used to load the first frame of application 2. Since the first frequency increase duration is calculated based on the duration used to load the first frame of application 1 and the saved corresponding relationship, the second frequency increase duration is calculated based on the duration used to load the first frame of application 2 and the saved corresponding relationship; the first frequency increase duration is also shorter than the second frequency increase duration.

[0185] That is to say, when application 1 is cold started, the CPU frequency boost duration is the sum of the duration used to load the first frame of application 1 and the duration used to load the remaining frames of application 1 (frames between the end of loading the first frame and the completion of application 1 startup), and the CPU frequency boost duration matches the cold start speed of application 1. When application 2 is cold started, the CPU frequency boost duration is the sum of the duration used to load the first frame of application 2 and the duration used to load the remaining frames of application 2 (frames between the end of loading the first frame and the completion of application 2 startup), and the CPU frequency boost duration matches the cold start speed of application 2. The CPU frequency boost duration matches the cold start speed of each application, which can ensure that the CPU capacity is fully utilized, accelerate the complete process of application cold start, and avoid CPU power consumption waste.

[0186] In some embodiments, application 2 is started after application 1 is started, that is, the start-up process of application 1 and application 2 does not overlap on the timeline. Figure 7, application 1 starts. When application 1 starts, the CPU frequency is increased. According to the time taken for the first frame of application 1 to load, the duration from the completion of the first frame loading of application 1 to the completion of the startup of application 1 (the first frequency increase duration) is calculated. At the estimated time when application 1 is started, the CPU frequency is reduced. After that, when application 2 is started, the CPU frequency is increased. According to the time taken for the first frame of application 2 to load, the duration from the completion of the first frame loading of application 2 to the completion of the startup of application 2 (the second frequency increase duration) is calculated. At the estimated time when application 2 is started, the CPU frequency is reduced. When two applications are started, the CPU frequency increase duration is adjusted according to the time taken for each first frame to load.

[0187] In some embodiments, application 2 is started during application 1 startup, and application 2 is started after application 1 is started. Figure 8 , application 1 is started. When application 1 is started, the CPU is frequency-increased; for example, the CPU frequency is increased from the first value to the second value. When the first frame of application 1 is loaded, the duration between the completion of the first frame loading of application 1 and the completion of the startup of application 1 (the first frequency-increase duration) is calculated according to the duration used for the first frame loading of application 1. During the loading of the first frame of application 1, application 2 is started. Since the CPU has been frequency-increased in response to the triggering of application 1, the CPU frequency is continued to be increased after application 2 is started (the CPU frequency is increased to the second value). At the calculated time when application 1 is started (the end time of the first frequency-increase duration), since the calculated time when application 2 is started has not been reached, the CPU frequency is continued to be increased (the CPU frequency is increased to the second value). When the first frame of application 2 is loaded, the duration between the completion of the first frame loading of application 2 and the completion of the startup of application 2 (the second frequency-increase duration) is calculated according to the duration used for the first frame loading of application 2. At the calculated time when application 2 is started (the end time of the second frequency-increase duration), the CPU is frequency-reduced; for example, the CPU frequency is reduced to the first value.

[0188] In some embodiments, reference Fig. 9, application 2 is started. When application 2 is started, the CPU is frequency-increased; for example, the CPU frequency is increased from the first value to the second value. When the first frame of application 2 is loaded, the duration between the completion of the first frame loading of application 2 and the completion of the startup of application 2 (the second frequency-increase duration) is calculated according to the duration used for the first frame loading of application 2. During the loading of the first frame of application 2, application 1 is started. Since the CPU has been frequency-increased in response to the triggering of application 2, the CPU frequency is continued to be increased after application 1 is started (the CPU frequency is increased to the second value). When the first frame of application 1 is loaded, the duration between the completion of the first frame loading of application 1 and the completion of the startup of application 1 (the first frequency-increase duration) is calculated according to the duration used for the first frame loading of application 1. At the calculated time when application 1 is started (the end time of the first frequency-increase duration), since the calculated time when application 2 is started has not been reached, the CPU frequency is continued to be increased (the CPU frequency is increased to the second value). At the calculated time when application 2 is started (the end time of the second frequency-increase duration), the CPU is frequency-reduced; for example, the CPU frequency is reduced to the first value.

[0189] That is to say, if the startup processes of multiple applications overlap on the timeline, the CPU frequency is increased when the application with the earliest startup time is started. When the calculated time when the startup completion time of multiple applications arrives, the CPU frequency is reduced.

[0190] It is understandable that the terminal device provided in the embodiment of the present application includes a hardware structure and / or software module corresponding to each function in order to realize the above functions. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiment of the present application.

[0191] The embodiment of the present application can divide the functional modules of the above-mentioned terminal device according to the above-mentioned method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0192] In one example, see Fig.10, which shows a possible structural diagram of the terminal device involved in the above embodiment. The terminal device 700 includes: a processing unit 710 and a storage unit 720.

[0193] The processing unit 710 is used to control and manage the actions of the terminal device 700. The storage unit 720 is used to store the program code and data of the terminal device 700. The processing unit 710 calls the program code stored in the storage unit 720 to execute each step in the above method embodiment.

[0194] Of course, the unit modules in the terminal device 700 include but are not limited to the processing unit 710 and the storage unit 720. For example, the terminal device 700 may also include a display unit, a communication unit, a power supply unit, etc. The display unit is used to display the user interface of the terminal device 700, for example, display application icons, display application interfaces, etc. The communication unit is used for the terminal device 700 to communicate with other electronic devices; the power supply unit is used to supply power to the terminal device 700.

[0195] The processing unit 710 may be a processor or a controller, such as a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The storage unit 720 may be a memory. The display unit may be a display screen, etc.

[0196] For example, the processing unit 710 is a processor (such as Figure 4 The processor 110 shown in FIG. 1 ), the storage unit 720 may be a memory (eg, Figure 4 The internal memory 121 shown in FIG. 1 ) and the display unit may be a display screen (such as Figure 4 The terminal device 700 provided in the embodiment of the present application can be Figure 4 The terminal device 100 shown in FIG. 1 is a terminal device 100. The processor, memory, display screen, etc. may be connected together, for example, via a bus. The processor calls the program code stored in the memory to execute each step in the above method embodiment.

[0197] The present application also provides a chip system (eg, a system on a chip (SoC)), such as Fig.11 As shown, the chip system includes at least one processor 801 and at least one interface circuit 802. The processor 801 and the interface circuit 802 can be interconnected via lines. For example, the interface circuit 802 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 802 can be used to send signals to other devices (such as a processor 801 or a touch screen of a terminal device). Exemplarily, the interface circuit 802 can read instructions stored in the memory and send the instructions to the processor 801. When the instructions are executed by the processor 801, the terminal device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0198] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned terminal device, the terminal device executes each function or step in the above-mentioned method embodiment.

[0199] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step in the above method embodiment.

[0200] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0201] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0202] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0203] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0204] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0205] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for adjusting CPU frequency, applied to a terminal device, wherein the terminal device comprises a central processing unit (CPU), and the terminal device is installed with a first application and a second application. It is characterized in that The method comprises: Receiving a first operation from a user; In response to the first operation, the first application is started, wherein before the first application is started, there is no process of the first application in the background of the terminal device system; Increasing the frequency of the CPU within a first time interval; The first time interval includes a first stage and a second stage, the first stage is a process from the start of the first application to the completion of loading of the first frame of the first application, the second stage is a process from the completion of loading of the first frame of the first application to the end of the first time interval, the first stage lasts for a first duration, and the second stage lasts for a second duration; receiving a second operation of the user; In response to the second operation, the second application is started, wherein before the second application is started, there is no process of the second application in the background of the terminal device system, and the start time of the second application is later than the start time of the first application; Increasing the frequency of the CPU within a second time interval; Among them, the second time interval includes a third stage and a fourth stage, the third stage is a process from the start of the second application to the completion of loading of the first frame of the second application, and the fourth stage is a process from the completion of loading of the first frame of the second application to the end of the second time interval, the third stage lasts for a third duration, and the fourth stage lasts for a fourth duration; when the first duration is less than the third duration, the second duration is also less than the fourth duration.

2. The method according to claim 1, It is characterized in that The first frame of the first application is loaded, including: The main interface Activity of the first application is started.

3. The method according to claim 1 or 2, It is characterized in that The first frame of the second application is loaded, including: The main interface Activity of the second application is started.

4. The method according to claim 1 or 2, It is characterized in that The step of increasing the frequency of the CPU within the first time interval includes: The CPU frequency is increased from a first value to a second value within the first time interval.

5. The method according to claim 4, It is characterized in that The CPU core includes N CPU cores, and increasing the CPU frequency from a first value to a second value within the first time interval includes: Increasing the frequencies of the N CPU cores from the first value to the second value within the first time interval; Alternatively, within the first time interval, the frequency of some of the N CPU cores is increased from the first value to the second value.

6. The method according to claim 5, It is characterized in that Increasing the frequency of some CPU cores among the N CPU cores from the first value to the second value within the first time interval includes: In the first time interval, the frequency of the CPU core bound to the first application among the N CPU cores is increased from the first value to the second value.

7. The method according to claim 1 or 2, It is characterized in that The step of increasing the frequency of the CPU within the second time interval includes: The CPU frequency is increased from a third value to a fourth value within the second time interval.

8. The method according to claim 7, It is characterized in that The CPU core includes N CPU cores, and increasing the CPU frequency from a third value to a fourth value within the second time interval includes: Increasing the frequencies of the N CPU cores from the third value to the fourth value within the second time interval; Alternatively, within the second time interval, the frequencies of some of the N CPU cores are increased from the third value to the fourth value.

9. The method according to claim 8, It is characterized in that Increasing the frequency of some CPU cores among the N CPU cores from the third value to the fourth value within the second time interval includes: In the second time interval, the frequency of the CPU core bound to the second application among the N CPU cores is increased from the third value to the fourth value.

10. The method according to claim 1 or 2, It is characterized in that The second duration is determined based on a preset corresponding relationship and the first duration.

11. A method for adjusting CPU frequency, applied to a terminal device, wherein the terminal device comprises a central processing unit (CPU), and the terminal device is installed with a first application and a second application. It is characterized in that The method comprises: Receiving a first operation from a user; In response to the first operation, the first application is started, wherein before the first application is started, there is no process of the first application in the background of the terminal device system; loading a first frame of the first application during startup of the first application; During the frequency increase duration of the first application, increasing the frequency of the CPU; The frequency increase duration of the first application is composed of the first frame loading duration of the first application and the first frequency increase duration. The first frame loading duration of the first application is the duration from the start of the first application to the completion of the start of the main interface Activity of the first application. The first frequency increase duration is the duration from the completion of the start of the main interface Activity of the first application to the end of the frequency increase of the first application. receiving a second operation of the user; In response to the second operation, the second application is started, wherein before the second application is started, there is no process of the second application in the background of the terminal device system, and the start time of the second application is later than the start time of the first application; loading a first frame of the second application during startup of the second application; During the frequency increase duration of the second application, increasing the frequency of the CPU; The frequency increase duration of the second application is composed of the first frame loading duration of the second application and the second frequency increase duration, wherein the first frame loading duration of the second application is the duration from the start of the second application to the completion of the start of the main interface Activity of the second application, and the second frequency increase duration is the duration from the completion of the start of the main interface Activity of the second application to the end of the frequency increase of the second application; When the first frame loading duration of the first application is shorter than the first frame loading duration of the second application, the first frequency increase duration is also shorter than the second frequency increase duration.

12. The method according to claim 11, It is characterized in that The CPU core includes N CPU cores, and increasing the frequency of the CPU within the frequency increase duration of the first application includes: During the frequency increase duration of the first application, increasing the frequencies of the N CPU cores; Alternatively, within the frequency increase duration of the first application, the frequency of the CPU core bound to the first application among the N CPU cores is increased.

13. An electronic device, It is characterized in that The electronic device comprises a processor, and the processor is used to call a computer program in a memory to execute the method according to any one of claims 1 to 12.

14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 12.

15. A chip system, It is characterized in that The chip system includes a processor, and the processor is used to call a computer program in a memory to execute the method as described in any one of claims 1-12.

Citation Information

Patent Citations

  • Background application control method and user terminal

    CN105302462A

  • Adaptive CPU frequency modulation acceleration method and device, mobile terminal and storage medium

    CN109739641A

  • CPU working frequency adjusting method, CPU working frequency adjusting device and storage medium

    CN111240835A

  • Processor frequency adjusting method and device, storage medium and electronic equipment

    CN112114975A

  • Frequency adjustment method and apparatus applied to terminal, and electronic device

    CN112789651A