Method for adjusting CPU frequency, and terminal device

By dynamically adjusting the CPU frequency extraction time to match the cold start speed of the application, the problem of improper setting of the CPU frequency extraction time in the prior art is solved, and efficient resource utilization and application startup acceleration are achieved.

WO2024234818A1PCT designated stage expired Publication Date: 2024-11-21HONOR DEVICE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/082285
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-16
Filing Date
2024-03-18
Publication Date
2024-11-21

AI Technical Summary

Technical Problem

The prior art is difficult to effectively adjust the CPU frequency, resulting in improper setting of the CPU frequency increase time when the application is started, resulting in waste of resources or slow application start-up, affecting the user experience.

Method used

By dynamically adjusting the CPU frequency extraction time according to the first frame loading time of the application in real time, ensuring that the CPU frequency extraction time matches the cold start speed of the application, avoiding waste of resources and excessive CPU frequency extraction time.

Benefits of technology

It realizes efficient utilization of CPU resources, accelerates the application startup process, avoids waste of CPU power, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024082285_21112024_PF_FP_ABST
    Figure CN2024082285_21112024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of terminals. Provided are a method for adjusting a CPU frequency, and a terminal device. A first application is cold-started first, and a CPU frequency is increased upon the start of the first application; and after a first frequency-increase duration from the completion of the loading of a first frame of the first application, the CPU frequency is decreased. After the first application has been started, a second application is cold-started, and the CPU frequency is increased upon the start of the second application; and after a second frequency-increase duration from the completion of the loading of a first frame of the second application, the CPU frequency is decreased. The first frequency-increase duration is calculated according to the duration used for loading the first frame of the first application, and the second frequency-increase duration is calculated according to the duration used for loading the first frame of the second application. Therefore, the longer the duration used for loading the first frame of the respective application, the longer the calculated frequency-increase duration thereof; and the CPU frequency-increase duration matches an estimated cold-start speed of the respective application. In this way, not only can the CPU capability be fully used, thereby accelerating an overall cold-start process of an application, but the waste of CPU power can also be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Method and terminal device for adjusting CPU frequency

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on May 16, 2023, with application number 202310553047.X and invention name “A method and terminal device for adjusting CPU frequency”, the entire contents of which are incorporated by reference into this application. 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 widespread adoption of smart devices, more and more applications are installed on them, and users often open multiple applications. Application launch is the process from application creation to full display to the user. Naturally, the faster the better for users. Application launch consumes various resources on the terminal device, such as the central processing unit (CPU), graphics processing unit (GPU), memory, and I / O (input / output) resources.

[0004] Generally speaking, a terminal device will maximize the capabilities of various resources to meet application startup requirements. For example, when an application starts, the terminal device will increase the CPU frequency (i.e., boost the CPU frequency). This boost improves CPU processing performance, speeding up application startup and shortening its duration. After the application completes startup, the terminal device will no longer boost the CPU frequency and will instead reduce the CPU frequency.

[0005] Terminal devices can set the duration of CPU frequency boosting. On the one hand, setting the CPU frequency boost duration too long can waste power. On the other hand, setting it too short can hinder the CPU's maximum performance, hindering application startup, resulting in slower application startup and a negative user experience. Optimizing the CPU frequency boost duration is a challenge that needs to be addressed.

[0006] Summary of the Invention

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

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

[0009] In a first aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, the terminal device including a central processing unit (CPU), the terminal device having a first application and a second application installed thereon, the method comprising: cold starting the first application (that is, before the first application is started, no process of the first application exists in the background of the terminal device system); in response to starting the first application, increasing the CPU frequency; and after a first frequency-boosting period after a first frame of the first application is loaded, reducing the CPU frequency. After the first application is started, cold starting the second application (that is, before the second application is started, no process of the second application exists in the background of the terminal device system); in response to starting the second application, increasing the CPU frequency; and after a second frequency-boosting period after a first frame of the second application is loaded, reducing the CPU frequency.

[0010] 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 is; 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.

[0011] 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 the startup of 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 the startup of 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, 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.

[0012] The terminal device stores a preset correspondence relationship. The first frequency boost duration is obtained based on the duration of loading the first frame of the first application and the preset correspondence relationship; the second frequency boost duration is obtained based on the duration of loading the first frame of the second application and the correspondence relationship.

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

[0014] 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.

[0015] In combination with the first aspect, in a possible implementation, increasing the CPU frequency means increasing the CPU frequency from a first value to a second value; and reducing the CPU frequency means reducing the CPU frequency from the second value to the first value.

[0016] In a second aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, the terminal device including a central processing unit (CPU), the terminal device having a first application and a second application installed thereon, the method comprising:

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

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

[0019] Launching a second application; wherein, before the second application is launched, no process of the second application exists in the background of the terminal device system; the second application is launched after the first application is launched, and when the second application is launched, the first application has not yet completed its launch;

[0020] After the first frame of the second application is loaded completely and the second frequency increase duration has passed, the CPU frequency is reduced.

[0021] In combination with the second aspect, in a possible implementation, the method further includes: obtaining a first frequency boost duration based on the duration used for loading the first frame of the first application and a preset corresponding relationship; obtaining a second frequency boost duration based on the duration used for loading the 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.

[0022] In this method, if multiple application startups overlap, the CPU frequency is increased when the earliest application starts. When the latest calculated startup completion time of the multiple applications arrives, the CPU frequency is reduced. This way, the CPU frequency boost duration matches the application's cold start speed, ensuring full CPU utilization and accelerating the complete cold start process while avoiding wasted CPU power.

[0023] In a third aspect, a method for adjusting CPU frequency is provided, which is applied to a terminal device, the terminal device including a central processing unit (CPU), and the terminal device having a first application installed thereon. The method includes:

[0024] A first application is launched at a first moment, and in response to the launch of the first application, the CPU frequency is increased; wherein the launch process of the first application includes a first stage and a second stage, the second stage being a stage in the launch process of the first application other than the first stage, and the second stage being after the first stage. The duration of the first stage is obtained based on the first moment and the second moment (the moment when the first stage of the first application is launched); the duration of the second stage is determined based on the duration of the first stage and a preset corresponding relationship; a third moment (the end time of the second stage) is determined based on the duration of the second stage; and at the third moment, the CPU frequency is reduced.

[0025] 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 time required for the second stage startup of the first application is estimated based on the time taken for the first stage, and the estimated time required for the second stage startup is used as the remaining time of the CPU frequency boost, that is, the CPU frequency boost time is dynamically adjusted according to the time taken for the first stage (for example, the time taken for the first frame startup), so that the CPU frequency boost time is equal to the estimated time taken for the first application startup to be completed; that is, the CPU frequency boost time matches the startup speed of the first application. It can not only ensure that the CPU capacity is fully utilized and accelerate the complete process of the cold start of the first application, but also avoid waste of CPU power consumption. Since the CPU frequency boost time of the first application is dynamically obtained based on the actual situation of the first application startup this time, the determined CPU frequency boost time is more accurate and the utilization of CPU capacity is more efficient.

[0026] 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.

[0027] In conjunction with the third aspect, in a possible implementation manner, the completion of loading the first frame of the first application includes: the completion of starting the main interface Activity of the first application.

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

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

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

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

[0032] In conjunction with the third aspect, in a possible implementation, the terminal device receives a user's start-up operation on the first application; and starts the first application in response to the start-up operation.

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

[0034] In conjunction with the third aspect, in one 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 a preset maximum frequency boost 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 boost duration threshold, a fourth moment is obtained based on the maximum frequency boost duration threshold, the fourth moment being a moment later than the first moment by the maximum frequency boost duration threshold; at the fourth moment, the CPU frequency is reduced.

[0035] In this method, a maximum CPU boost duration threshold is pre-set, representing the maximum CPU boost duration for the terminal device. In other words, the CPU boost duration should be less than or equal to the maximum boost duration threshold. This prevents the first application from cold-starting and consuming too much CPU resources, leading to other processes being starved of CPU resources and causing system lag.

[0036] In a fourth aspect, a terminal device is provided, which has the functionality to implement the method described in the first, second, or third aspects above. The functionality can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the aforementioned functionality.

[0037] 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 execute a method as described in any one of the first, second or third aspects above.

[0038] 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, second or third aspects above according to the instructions.

[0039] In a seventh aspect, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer can execute any one of the methods in the first, second or third aspects above.

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

[0041] In a ninth aspect, a device (for example, a chip system) is provided, which includes a processor for supporting a terminal device to implement the functions involved in the first, second, or third aspects above. 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 can be composed of a chip or include a chip and other discrete devices.

[0042] 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

[0043] FIG1A is a schematic diagram showing that the CPU frequency boost duration is longer than the application cold start duration;

[0044] FIG1B is a schematic diagram showing that the CPU frequency boost duration is shorter than the application cold start duration;

[0045] FIG2 is a schematic diagram showing the principle of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0046] FIG3 is a flow chart of a method for adjusting CPU frequency according to an embodiment of the present application;

[0047] FIG4 is a schematic diagram of the hardware structure of a terminal device to which the method for adjusting CPU frequency provided in an embodiment of the present application is applicable;

[0048] FIG5A is 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;

[0049] FIG5B is a schematic diagram of module interaction of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0050] FIG6 is a schematic diagram of a method for increasing CPU frequency when two applications with different cold start speeds are started on a terminal device according to an embodiment of the present application;

[0051] FIG7 is a schematic diagram of a scenario example of a method for adjusting CPU frequency provided in an embodiment of the present application;

[0052] FIG8 is a schematic diagram of another scenario example of the method for adjusting CPU frequency provided in an embodiment of the present application;

[0053] FIG9 is a schematic diagram of another scenario example of the method for adjusting CPU frequency provided in an embodiment of the present application;

[0054] FIG10 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0055] FIG11 is a schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] 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 on the present application. As used in the specification and claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such 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: the situation where A exists alone, A and B exist at the same time, and B exists alone, wherein 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.

[0057] References to "one embodiment" or "some embodiments" etc. described in this specification mean that the specific features, structures or characteristics described in conjunction with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing 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 another way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in another way. The term "connected" includes direct and indirect connections, unless otherwise stated. "First" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

[0058] In the embodiments of this 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 this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0059] 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 before application A is enabled in the embodiment of the present application, 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.

[0060] In some scenarios, a user action triggers an application cold restart. For example, a terminal device's desktop includes application icon 1 for application 1. A user clicks application icon 1, and in response to the user's click on application icon 1, application 1 cold restarts. For example, a user enters the voice message "Open application 1," and in response to receiving the user's voice message, application 1 cold restarts. In some scenarios, invoking another application triggers an application cold restart. For example, application 2 is running on the terminal device, and application 2 launches application 1, causing application 1 to cold restart.

[0061] The cold start process may include the process from receiving the user's operation to start the application or the call of other applications to the complete display of the application's main interface on the terminal screen. Usually, the terminal will accelerate the application cold start process by increasing the CPU frequency to shorten the application cold start time. CPU frequency increase, also known as CPU frequency pull, refers to increasing the CPU's operating frequency to the highest value or a higher value in 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.

[0062] Typically, a terminal sets a uniform CPU boost duration. This triggers the CPU boost when an application cold starts, and stops when the CPU boost duration expires. This approach is universal for all applications, and all applications have the same CPU boost duration.

[0063] However, the cold start duration of different applications varies greatly. For example, Table 1 shows the cold start duration of 20 different applications on the same terminal.

[0064] Table 1

[0065] As can be seen, the difference between the longest and shortest cold start times is approximately 3.7 seconds. A uniform CPU frequency boost duration configuration may not be suitable for every application.

[0066] Referring to Figure 1A, if the CPU boost duration is set to a larger value to meet the CPU usage needs of applications with slower cold start times, the prolonged CPU boost during the cold start of applications with shorter cold start times will waste CPU resources and excessive power consumption. For example, if the CPU boost duration is set to 4714ms, application 18 will complete its cold start in 1053ms, wasting the remaining 3661ms of CPU boost time. Application 12 will complete its cold start in 2042ms, wasting the remaining 2672ms of CPU boost time.

[0067] Referring to Figure 1B, if the CPU boost duration is set to a smaller value, the CPU usage requirements of applications with faster cold start times can be met; when an application with a longer cold start time is cold started, the CPU boost duration has expired and the application has not yet 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 utilized, resulting in a waste of CPU capacity.

[0068] 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 ensure that the CPU capacity is fully utilized, accelerate the cold start of the application, and avoid waste of CPU power consumption. Moreover, for each application, the CPU frequency boost duration of the application is dynamically obtained 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 by 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 more efficiently utilize CPU resources.

[0069] It can be understood that from the time the terminal device receives the user's operation to start the application or the call of 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 completely presented on the terminal device screen, the cold start process of the first application ends.

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

[0071] For different terminals, or the same terminal under different loads, the cold start speed of the same application is different. If the CPU frequency boosting 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 boosting (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 boosting matches the actual speed of the first application's cold start; it can provide CPU frequency boosting capabilities throughout the cold start process of the first application, ensure that the CPU capabilities are 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 boosting time.

[0072] 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. Exemplarily, referring to Figure 2, upon receiving the user's startup operation (such as the user clicking on 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.

[0073] The terminal device calculates a 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-ups, 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.

[0074] In one implementation, the cold start data of the N (for example, 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 application in the N applications, and the time Y taken from the completion of the first frame loading to the completion of the cold start of the application are obtained. For example, the data of the cold start process of N applications are collected to obtain (X1, Y1), (X2, Y2), ..., (X i , Y i ),……,(X N , Y N ). According to (X1, Y1), (X2, Y2), ..., (X i , Y i ),……,(X N , Y N ), perform linear regression to obtain the corresponding relationship between the time X it takes to load the first frame and the time Y it takes from the completion of the first frame loading to the completion of the first application cold start. For example, the corresponding relationship between X and Y is, Y = aX + b, according to (X1, Y1), (X2, Y2), ..., (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.

[0075] 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 corresponding relationship between X and Y. For example, pre-set Y=X, etc. In other implementations, X and Y may not be in a linear corresponding relationship. For example, X=Y 2 wait.

[0076] The terminal device can pre-store the correspondence between X and Y, for example, saving the values ​​of a and b. When the first frame of the first application is loaded, the terminal device obtains the first duration, that is, the value of X. Based on the correspondence between X and Y, the terminal device can calculate the value of Y, that is, the value of the second duration. After the second duration, the terminal device stops the CPU frequency increase.

[0077] The CPU boost duration, from the start to the end of the CPU boost, is the sum of the first and second durations. Since the sum of the first and second durations also represents the duration from the start to the completion of the first application's startup, the CPU boost duration matches the total duration of the first application's startup process.

[0078] 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 is possible to avoid the first application cold start occupying too many CPU resources, resulting in other processes not being able to allocate CPU resources, causing system freezes.

[0079] FIG3 shows a flow chart of a method for adjusting CPU frequency provided by an embodiment of the present application. As shown in FIG3 , the method may include:

[0080] S101: Start the first application.

[0081] In one implementation, a terminal device receives a user operation to launch a first application, and in response to the operation, the first application is launched. For example, the user clicks the application icon of the first application, and the first application is launched. For example, the terminal device receives a user voice input of "open the first application", and the first application is launched.

[0082] 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.

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

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

[0085] 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 will not be illustrated one by one in the embodiment of the present application.

[0086] S103: Start CPU frequency boosting and mark the first moment.

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

[0088] CPU frequency boosting refers to increasing the CPU frequency; for example, increasing the CPU frequency from a current first value to a second value, where the second value is greater than the first value. It is understood that a CPU may include multiple CPU cores. In one implementation, increasing the CPU frequency 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.

[0089] S104: Load the first frame of the first application.

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

[0091] 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.

[0092] In one implementation, the completion of the startup of the main interface Activity of the first application indicates that the loading of the first frame of the first application is completed. The moment when the startup of the main interface Activity of the first application is completed is the second moment.

[0093] The first frame loading duration of the first application (first duration) = the second moment - the first moment.

[0094] S106: Calculate a second duration based on the first duration.

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

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

[0097] In one implementation, a maximum CPU frequency boost duration threshold is preset.

[0098] 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 boost duration threshold, the CPU frequency boost cutoff time (third time) is determined to be the second time + the second duration.

[0099] 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).

[0100] S108: When the CPU frequency increase cut-off time is reached, stop the CPU frequency increase.

[0101] In one implementation, when the CPU frequency increase cutoff time is reached, the CPU frequency is no longer increased. For example, after the CPU frequency increase, the CPU frequency is at the second value. When the CPU frequency increase cutoff time is reached, the CPU frequency is reduced. For example, the CPU frequency is reduced from the current second value to the first value.

[0102] 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 some of the multiple CPU cores can be maintained at the second value, and another part of the multiple CPU cores can be turned off.

[0103] The method for adjusting the CPU frequency provided in the embodiment of the present application is that the first application is started 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, 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 waste of CPU power consumption. Since the CPU frequency boost duration of the first application is dynamically obtained 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.

[0104] The method for adjusting CPU frequency provided in the embodiments 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 (such as smart TVs, smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (such as 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.

[0105] 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.

[0106] 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 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.

[0107] It should be understood that the structures illustrated in the embodiments of the present application do 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0108] 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 processing unit (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.

[0109] The controller is the nerve center and command center of the terminal device 100. It can generate operation control signals based on instruction operation codes and timing signals to complete the control of instruction fetching and execution.

[0110] The application processor can run the terminal device 100's operating system, which manages the terminal device's hardware and software resources. For example, it manages and configures memory, prioritizes system resource supply and demand, controls input and output devices, operates the network, manages the file system, and manages drivers. The operating system also provides an interface for users to interact with the system. Various software, such as drivers and application programs (apps), can be installed within the operating system.

[0111] The NPU is a neural network (NN) computing processor that rapidly processes input information and can continuously self-learn by drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain. The NPU can enable applications such as intelligent cognition in the terminal device 100.

[0112] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0113] In some embodiments, the processor 110 may include one or more interfaces. The interfaces 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.

[0114] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative 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 a different interface connection method from the above embodiments, or a combination of multiple interface connection methods.

[0115] 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 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0116] 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 (UFS), etc. In some embodiments, the processor 110 can execute the application running method provided in the embodiments of the present application, as well as other applications and data management by running the instructions stored in the internal memory 121, and / or the instructions stored in the memory provided in the processor 110.

[0117] The terminal device 100 can implement audio functions through the audio module 130, speaker 130A, microphone 130B, and application processor. For example, music playback, 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 provided in the processor 110, or some functional modules of the audio module 130 can be provided in the processor 110.

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

[0119] The microphone 130B, also called a "microphone" or "speaker", is used to convert sound signals into electrical signals. A user can speak by putting their mouth close to the microphone 130B to input the sound signal into the microphone 130B.

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

[0121] The communication module 150 can provide wireless communication solutions 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 transmitted from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through antenna 1 or antenna 2.

[0122] The terminal device 100 implements display functions through a GPU, display screen 140, and an application processor. The GPU is a microprocessor for image processing that 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 modify display information.

[0123] 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.

[0124] 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 based on the pressure sensor. The terminal device 100 can also calculate the position of the touch based on 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 nearby. 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.

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

[0126] 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 and inputting data. The mouse is an indicator that indicates the vertical and horizontal coordinates of the terminal device 100 display system and is used to input instructions to the terminal device 100. The input device 170 can be connected to the terminal device 100 via a wired connection, for example, via a GPIO interface, a USB interface, etc. The input device 170 can also be connected to the terminal device 100 wirelessly, for example, via Bluetooth, infrared, etc.

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

[0128] For example, the terminal device 100 is a mobile phone. The software system of the terminal device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In this embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate the software structure of the terminal device 100.

[0129] FIG5A is a software structure block diagram of the terminal device 100 according to an embodiment of the present invention.

[0130] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0131] 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.

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

[0133] As shown in FIG5A , 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.

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

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

[0136] 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.

[0137] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.

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

[0139] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically, without requiring user interaction. For example, the Notification Manager can be used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include displaying text messages in the status bar, emitting alert sounds, vibrating the device, or flashing indicator lights.

[0140] The AMS is primarily responsible for starting, switching, and scheduling the four major components of the system, as well as managing and scheduling application processes. Its responsibilities are similar to those of the process management and scheduling module in an operating system. When a process or component is started, the request is passed to the AMS via the Binder communication mechanism, and the AMS then handles it uniformly.

[0141] The system library can 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.

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

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

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

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

[0146] The Android runtime is responsible for scheduling and management of the Android system. The Android runtime includes the core library and the virtual machine.

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

[0148] The core library includes frequency boost calculation module 2. Frequency boost calculation module 1 and frequency boost calculation module 2 jointly manage the CPU frequency boost duration, etc.

[0149] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

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

[0151] 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.

[0152] For example, as shown in FIG5A , Application 1 begins to start. For example, a mobile phone displays a user interface on the screen. The user interface includes an application icon for Application 1. The user clicks the application icon for Application 1. In response to receiving the user's click on the application icon for Application 1, Application 1 sends an application 1 start request to the AMS. The 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 a CPU frequency increase.

[0153] When the first frame of application 1 finishes loading, it notifies frequency boost calculation module 1 of the completion. Frequency boost calculation module 1 calculates the loading duration of application 1's first frame. Frequency boost calculation module 2 in the core library is then called to calculate the CPU frequency boost deadline based on the loading duration of application 1's first frame. The core library sends a frequency boost end event and the frequency boost deadline to the CPU core. Upon receiving the frequency boost end event, the CPU core stops CPU frequency boosting when the frequency boost deadline is reached.

[0154] For example, in combination with the software architecture shown in FIG5A , FIG5B shows a schematic diagram of module interaction of the method for adjusting CPU frequency provided in an embodiment of the present application.

[0155] As shown in FIG5B , the method for adjusting the CPU frequency provided in the embodiment of the present application may include:

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

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

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

[0159] In response to receiving the user's start operation, application 1 sends a start request to the AMS.

[0160] S603: The AMS starts application 1.

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

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

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

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

[0165] S606: The CPU core triggers a CPU frequency increase.

[0166] In one implementation, the CPU core increases the CPU frequency 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.

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

[0168] 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 complete.

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

[0170] In one implementation, the frequency increase calculation module 1 receives a notification of completion of loading the first frame at a second time, and calculates the loading duration of the first frame of application 1 based on the second time and the saved first time. The loading duration of the first frame of application 1 is the difference between the second time and the first time.

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

[0172] S610: 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.

[0173] 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 (pre-saved correspondence between X and Y).

[0174] S611: The frequency increase calculation module 2 obtains a frequency increase deadline according to the duration from the completion of loading the first frame to the completion of starting the application 1.

[0175] In one implementation, if the duration from the completion of the first frame loading to the completion of the launch of Application 1 is less than or equal to (the maximum frequency boost duration threshold - the first frame loading duration), the CPU frequency boost cutoff time is determined to be (the second time + the duration from the completion of the first frame loading to the completion of the launch of Application 1). If the duration from the completion of the first frame loading to the completion of the launch of Application 1 is greater than (the maximum frequency boost duration threshold - the first frame loading duration), the CPU frequency boost cutoff time is determined to be (the first time + the maximum frequency boost duration threshold).

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

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

[0178] In one implementation, when the CPU frequency increase cutoff 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.

[0179] 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 based on the actual speed of the application during the current cold start process.

[0180] For example, FIG6 shows a schematic diagram of a method for increasing CPU frequency when two applications with different cold start speeds are started on a terminal device.

[0181] In one scenario, referring to (a) of Figure 6, 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 starting application 1) 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.

[0182] In one scenario, referring to (b) of Figure 6, 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 boost. 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 (the 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 boost duration. After the second frequency boost duration after the first frame of application 2 is loaded, the CPU frequency is reduced.

[0183] 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 time taken to load the first frame of application 1 is shorter than the time taken to load the first frame of application 2. Since the first frequency boost duration is calculated based on the time taken to load the first frame of application 1 and the saved corresponding relationship, and the second frequency boost duration is calculated based on the time taken to load the first frame of application 2 and the saved corresponding relationship, the first frequency boost duration is also shorter than the second frequency boost duration.

[0184] That is, when application 1 is cold-started, the CPU boost duration is the sum of the time it takes to load the first frame of application 1 and the remaining frames of application 1 (the frames between the completion of the first frame loading and the completion of application 1 startup). This CPU boost duration matches the cold-start speed of application 1. When application 2 is cold-started, the CPU boost duration is the sum of the time it takes to load the first frame of application 2 and the remaining frames of application 2 (the frames between the completion of the first frame loading and the completion of application 2 startup). This CPU boost duration matches the cold-start speed of application 2. Matching the CPU boost duration to the cold-start speed of each application ensures full CPU utilization, accelerates the complete application cold-start process, and avoids wasted CPU power.

[0185] In some embodiments, application 2 is started after application 1 is started, that is, the startup processes of application 1 and application 2 do not overlap on the timeline. Referring to Figure 7, application 1 is started. When application 1 is started, the CPU frequency is increased. According to the time taken for the first frame of application 1 to be loaded, 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 moment when application 1 is started, the CPU is frequency reduced. Afterwards, when application 2 is started, the CPU frequency is increased. According to the time taken for the first frame of application 2 to be loaded, 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 moment when application 2 is started, the CPU is frequency reduced. When two applications are started, the CPU frequency increase duration is adjusted according to the time taken for each first frame to be loaded.

[0186] In some embodiments, application 2 is started while application 1 is starting, and application 2 completes its startup after application 1 completes its startup. Referring to Figure 8 , application 1 is started. When application 1 starts, the CPU frequency is increased; for example, the CPU frequency is increased from a first value to a 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 application 1 startup (the first frequency increase duration) is calculated based on the duration of time it took to load the first frame of application 1. During the loading of the first frame of application 1, application 2 is started. Because the CPU frequency has already been increased in response to the triggering of application 1, the CPU frequency increase continues after application 2 is started (the CPU frequency is increased to the second value). At the calculated time when application 1 is completed (the end time of the first frequency increase duration), since the calculated time when application 2 is completed has not yet been reached, the CPU frequency increase continues (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 application 2 startup (the second frequency increase duration) is calculated based on the duration of time it took to load the first frame of application 2. At the calculated time when the application 2 is started and completed (the time when the second frequency increase duration ends), the CPU is frequency-reduced; for example, the CPU frequency is reduced to the first value.

[0187] In some embodiments, referring to FIG9 , Application 2 is launched. When Application 2 is launched, the CPU frequency is increased; for example, the CPU frequency is increased from a first value to a 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 Application 2 startup (the second frequency increase duration) is calculated based on the duration of the first frame loading of Application 2. While the first frame of Application 2 is loading, Application 1 is launched. Because the CPU frequency has already been increased in response to the triggering of Application 2, the CPU frequency is maintained at this increased frequency after Application 1 is launched (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 Application 1 startup (the first frequency increase duration) is calculated based on the duration of the first frame loading of Application 1. At the calculated time when Application 1 is launched (the end time of the first frequency increase duration), since the calculated time when Application 2 is launched has not yet arrived, the CPU frequency is maintained at this increased frequency (the CPU frequency is increased to the second value). At the calculated time when Application 2 is launched (the end time of the second frequency increase duration), the CPU frequency is reduced; for example, the CPU frequency is reduced to the first value.

[0188] That is, if multiple application startups overlap on the timeline, the CPU frequency is increased when the earliest application starts, and the CPU frequency is reduced when the latest application startup completion time is reached.

[0189] It is understandable that the terminal device provided in the embodiment of the present application includes a hardware structure and / or software module for performing 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 a hardware or computer software driven hardware manner 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.

[0190] The embodiment of the present application can divide the functional modules of the terminal device according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules 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 functional division. In actual implementation, there may be other division methods.

[0191] In an example, please refer to FIG10 , which shows a possible structural diagram of a terminal device involved in the above embodiment. The terminal device 700 includes: a processing unit 710 and a storage unit 720 .

[0192] 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 program codes and data of the terminal device 700. The processing unit 710 calls the program codes stored in the storage unit 720 to execute the various steps in the above method embodiment.

[0193] 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, such as displaying application icons and application interfaces. The communication unit is used for the terminal device 700 to communicate with other electronic devices; and the power supply unit is used to supply power to the terminal device 700.

[0194] The processing unit 710 may be a processor or 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.

[0195] For example, the processing unit 710 is a processor (the processor 110 shown in Figure 4), the storage unit 720 can be a memory (the internal memory 121 shown in Figure 4), and the display unit can be a display screen (the display screen 140 shown in Figure 4). The terminal device 700 provided in the embodiment of the present application can be the terminal device 100 shown in Figure 4. The above-mentioned processor, memory, display screen, etc. can be connected together, for example, via a bus. The processor calls the program code stored in the memory to execute the various steps in the above method embodiment.

[0196] An embodiment of the present application also provides a chip system (for example, a system on a chip (SoC)). As shown in Figure 11, 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 (for example, a memory of an electronic device). For another example, the interface circuit 802 can be used to send signals to other devices (for example, the 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 can also include other discrete components, which are not specifically limited in the embodiments of the present application.

[0197] 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.

[0198] The embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute each function or step in the above method embodiment.

[0199] 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.

[0200] In the several embodiments provided in this 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 merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, 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.

[0201] The units described as separate components may or may not be physically separate, 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 places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0202] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0203] 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 and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0204] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for adjusting CPU frequency, 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, characterized in that: The method comprises: Starting the 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; In response to starting the first application, increasing the frequency of the CPU; After a first frequency increase time after the first frame of the first application is loaded, reducing the frequency of the CPU; Starting the 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, and the second application is started after the first application is started; In response to starting the second application, increasing the frequency of the CPU; After a second frequency increase time after the first frame of the second application is loaded, reducing the frequency of the CPU; 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, and the first frequency increase duration is shorter than the second frequency increase duration.

2. The method according to claim 1, characterized in that The first frequency increase duration is obtained according to the duration used for loading the first frame of the first application and a 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.

3. The method according to claim 2, characterized in that 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.

4. The method according to any one of claims 1 to 3, characterized in that: In response to starting the first application, increasing the frequency of the CPU includes: In response to starting the first application, increasing the frequency of the CPU from a first value to a second value; The step of reducing the frequency of the CPU after the first frame of the first application is loaded completely for a first frequency increase duration includes: After a first frequency increase time after the first frame of the first application is loaded, the frequency of the CPU is reduced from the second value to the first value.

5. The method according to claim 4, characterized in that In response to starting the second application, increasing the frequency of the CPU includes: In response to starting the second application, increasing the frequency of the CPU from a first value to a second value; The step of reducing the frequency of the CPU after the second frequency increase time after the first frame of the second application is loaded completely includes: After a second frequency increase time after the first frame of the second application is loaded, the frequency of the CPU is reduced from the second value to the first value.

6. A method for adjusting CPU frequency, applied to a terminal device, the terminal device comprising a central processing unit (CPU), the terminal device having a first application installed, characterized in that: The method comprises: Starting the first application at a first moment, wherein the starting 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 starting process of the first application, and the second stage is after the first stage; In response to starting the first application, increasing the frequency of the CPU; Acquire the duration of the first stage according to the first moment and the second moment, wherein the second moment is the moment when the first stage of the first application is started and completed; Determining the duration of the second stage according to the duration of the first stage and the preset corresponding relationship; Obtaining a third moment according to the duration of the second stage, wherein the third moment is the end moment of the second stage; At the third moment, the frequency of the CPU is reduced.

7. The method according to claim 6, characterized in that The first stage is a stage in which the first frame of the first application is loaded.

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

9. The method according to any one of claims 6 to 8, characterized in that: The step of increasing the frequency of the CPU comprises: Increasing the frequency of the CPU from a first value to a second value; The step of reducing the frequency of the CPU comprises: The frequency of the CPU is reduced from the second value to the first value.

10. The method according to any one of claims 6 to 9, characterized in that: The corresponding relationship is obtained by linear regression based on the startup data of N applications; 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.

11. The method according to any one of claims 6 to 10, characterized in that: Before the first application is started, there is no process of the first application in the background of the terminal device system.

12. The method according to any one of claims 6 to 11, characterized in that: The starting the first application includes: The terminal device receives a user's start operation on the first application; In response to the start operation, the first application is started.

13. The method according to any one of claims 6 to 11, characterized in that: The starting the first application includes: In response to a call from a second application, the first application is started.

14. The method according to any one of claims 6 to 13, characterized in that: Before obtaining the third time according to the duration of the second stage, the method further includes: 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 a preset maximum frequency increase duration threshold.

15. The method according to claim 14, characterized in that The method further comprises: 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 a preset maximum frequency increase duration threshold, obtaining a fourth time according to the maximum frequency increase duration threshold, the fourth time being a time later than the first time by the maximum frequency increase duration threshold; At the fourth moment, the frequency of the CPU is reduced.

16. A terminal device, characterized in that: The terminal device comprises: a processor and a memory, the processor being coupled to the memory; the memory being used to store computer program code; the computer program code comprising computer instructions, and when the processor executes the above-mentioned computer instructions, the terminal device executes the method described in any one of claims 1-15.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes 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 15.

Citation Information

Patent Citations

  • Method for adjusting CPU frequency and terminal equipment

    CN119003141A

  • CPU frequency modulation method and device, mobile terminal and computer readable storage medium

    CN109739642A

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

    CN111240835A

  • CPU frequency adjusting method and system and storage medium

    CN115686178A

  • Method for adjusting CPU frequency and terminal equipment

    CN117149409A