CN107122036B - Method and device for adjusting frequency of central processing unit - Google Patents
Method and device for adjusting frequency of central processing unit Download PDFInfo
- Publication number
- CN107122036B CN107122036B CN201710251827.3A CN201710251827A CN107122036B CN 107122036 B CN107122036 B CN 107122036B CN 201710251827 A CN201710251827 A CN 201710251827A CN 107122036 B CN107122036 B CN 107122036B
- Authority
- CN
- China
- Prior art keywords
- frequency
- running
- application program
- cpu
- operating
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/324—Power saving characterised by the action undertaken by lowering clock frequency
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method and a device for adjusting the frequency of a central processing unit, belonging to the field of electronic equipment. The method comprises the following steps: when the application program is started, acquiring a first running frequency, and adjusting the maximum running frequency of the CPU to the first running frequency, wherein the first running frequency is the maximum running frequency determined based on the running condition of the CPU in the last running process of the application program; in the current operation process, acquiring the proportion of the CPU operating at the first operation frequency; and if the proportion is larger than a preset threshold value, increasing the first operating frequency to obtain a second operating frequency, and storing the second operating frequency. According to the invention, the maximum operation frequency of the CPU is continuously corrected according to the actual operation condition of the CPU when the application program operates each time, so that the timeliness of the maximum operation frequency can be ensured, the accuracy of the adjustment of the CPU frequency is improved, and the smooth operation of the application program on equipment can be ensured each time.
Description
Technical Field
The present invention relates to the field of electronic devices, and in particular, to a method and an apparatus for adjusting a frequency of a central processing unit.
Background
During the use of some devices, various applications are often installed to enable the device to provide corresponding functions. When an application program runs, a user has a high requirement on the running smoothness of the application program, for this reason, a Central Processing Unit (CPU) of a device needs to provide a sufficient running speed, and the larger the running speed of the CPU is, the larger the power consumption of the device is. Therefore, different CPU running speeds need to be provided according to actual application requirements, so as to save power consumption of the device while ensuring smooth running of the application program on the device. The running speed of the CPU is greatly influenced by the running frequency of the CPU, so that different running speeds of the CPU can be provided by adjusting the running frequency of the CPU, and the working state of the CPU is optimized.
Currently, the CPU frequency adjustment method is as follows: and testing a certain application program, acquiring the historical operating frequency condition of the CPU when the application program is started and the historical operating frequency condition of the CPU when the application program stops operating in the testing process of the application program, and acquiring the operating frequency and the corresponding operating times of the CPU of the application program in the current operating process according to the difference between the two historical operating frequency conditions. And then the device can acquire the operating frequency with the largest number of operating times as a target operating frequency, and correspondingly store the name of the application program and the target operating frequency to finish the test of the application program. Thus, the device adjusts the maximum operating frequency of the CPU to the target operating frequency each time the application program is run later.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
in the above technology, the application program is tested only once, and according to the test result of this time, the maximum operating frequency of the CPU during each time of running of the application program is adjusted, the situation that the test result is inaccurate easily occurs in this one-time measurement mode, and with the use of the device, the hardware condition of the device changes, and the measurement result cannot match the actual hardware situation of the device, so that it cannot be guaranteed that the application program can run smoothly on the device every time thereafter.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for adjusting a frequency of a central processing unit. The technical scheme is as follows:
in a first aspect, a method for adjusting a frequency of a central processing unit is provided, the method comprising:
when an application program is started, acquiring a first running frequency, and adjusting the maximum running frequency of a CPU (Central processing Unit) to the first running frequency, wherein the first running frequency is the maximum running frequency determined based on the running condition of the CPU in the last running process of the application program;
in the current operation process, acquiring the proportion of the CPU operating at the first operation frequency;
and if the proportion is larger than a preset threshold value, increasing the first operating frequency to obtain a second operating frequency, and storing the second operating frequency.
In a first implementation manner of the first aspect, the adjusting the maximum operating frequency of the CPU to the first operating frequency includes:
determining whether an application identifier of the application program exists in a target array, wherein the target array is used for storing a corresponding relation between the application identifier of the application program and the maximum operating frequency;
and if the application identifier of the application program exists, acquiring the first operating frequency from a target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
In a second implementation manner of the first aspect, the obtaining, in the current operation process, a ratio of the CPU operating at the first operation frequency includes:
when the application program is started, acquiring a first frequency list, wherein the first frequency list is used for recording the historical running frequency and the corresponding running times of a CPU before the application program is started;
when the application program stops running, acquiring a second frequency list, wherein the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and acquiring the proportion of the CPU running at the first running frequency according to the first frequency list and the second frequency list.
In a third implementation manner of the first aspect, the obtaining, according to the first frequency list and the second frequency list, a ratio of the CPU operating at the first operating frequency includes:
performing difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, wherein the third frequency list is used for recording the running frequency of the CPU and the corresponding running times in the current running process of the application program;
and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all running frequencies in the third frequency list.
In a fourth implementation manner of the first aspect, before the obtaining, according to the first frequency list and the second frequency list, a ratio of the CPU operating at the first operating frequency, the method further includes:
calculating the running duration of the application program according to the system time when the application program is started and the system time when the application program stops running;
and if the running time of the application program is longer than the preset time, executing the subsequent proportion obtaining step.
In a second aspect, there is provided a central processing unit frequency adjustment apparatus, the apparatus comprising:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first operating frequency when an application program is started, and the first operating frequency is the maximum operating frequency determined based on the CPU operating condition in the last operating process of the application program;
the adjusting module is used for adjusting the maximum running frequency of the CPU to the first running frequency;
the obtaining module is further configured to obtain, in a current operation process, a ratio of the CPU operating at the first operation frequency;
and the increasing module is used for increasing the first operating frequency to obtain a second operating frequency and storing the second operating frequency if the proportion is greater than a preset threshold value.
In a first implementation manner of the second aspect, the adjusting module is configured to determine whether an application identifier of the application program exists in a target array, where the target array is used to store a corresponding relationship between the application identifier of the application program and a maximum operating frequency; and if the application identifier of the application program exists, acquiring the first operating frequency from a target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
In a second implementation manner of the second aspect, the obtaining module includes:
the first obtaining submodule is used for obtaining a first frequency list when the application program is started, and the first frequency list is used for recording the historical running frequency and the corresponding running times of a CPU before the application program is started;
the second obtaining submodule is used for obtaining a second frequency list when the application program stops running, and the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and the third obtaining submodule is used for obtaining the proportion of the first operating frequency of the CPU according to the first frequency list and the second frequency list.
In a third implementation manner of the second aspect, the third obtaining submodule is configured to perform difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, where the third frequency list is used to record an operating frequency of a CPU and corresponding operating times in a current operating process of the application program; and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all running frequencies in the third frequency list.
In a fourth implementation form of the second aspect, the apparatus further comprises:
the computing module is used for computing the running time of the application program according to the system time when the application program is started and the system time when the application program stops running;
and the acquisition module is used for executing the subsequent step of acquiring the proportion if the running time of the application program is longer than the preset time.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
by acquiring the proportion of the maximum operating frequency of the CPU in the current operating process of the application program, and re-determining and storing the maximum operating frequency of the CPU based on the proportion, the electronic equipment can adjust the maximum operating frequency of the CPU according to the maximum operating frequency determined in the current operating process in the next operating process of the application program. According to the technical scheme, the maximum running frequency of the CPU is continuously corrected according to the actual running condition of the CPU when the application program runs every time, and the timeliness of the maximum running frequency can be guaranteed, so that the accuracy of CPU frequency adjustment is improved, and the application program can smoothly run on equipment every time.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a method for adjusting a frequency of a central processing unit according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for adjusting a frequency of a central processing unit according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a frequency adjustment apparatus for a central processing unit according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a frequency adjustment apparatus for a central processing unit according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device 500 according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for adjusting a frequency of a central processing unit according to an embodiment of the present invention. Referring to fig. 1, the method includes:
101. when the application program is started, acquiring a first operating frequency, and adjusting the maximum operating frequency of the CPU to the first operating frequency, wherein the first operating frequency is the maximum operating frequency determined based on the CPU operating condition in the last operating process of the application program.
102. And in the current operation process, acquiring the proportion of the CPU operating at the first operation frequency.
103. And if the proportion is larger than a preset threshold value, increasing the first operating frequency to obtain a second operating frequency, and storing the second operating frequency.
According to the method provided by the embodiment of the invention, the ratio of the maximum running frequency of the CPU in the current running process of the application program is obtained, and the maximum running frequency of the CPU is re-determined and stored based on the ratio, so that the electronic equipment can adjust the maximum running frequency of the CPU according to the maximum running frequency determined in the current running process in the next running process of the application program. According to the technical scheme, the maximum running frequency of the CPU is continuously corrected according to the actual running condition of the CPU when the application program runs every time, and the timeliness of the maximum running frequency can be guaranteed, so that the accuracy of CPU frequency adjustment is improved, and the application program can smoothly run on equipment every time.
Optionally, the adjusting the maximum operating frequency of the CPU to the first operating frequency includes:
determining whether an application identifier of the application program exists in a target array, wherein the target array is used for storing the corresponding relation between the application identifier of the application program and the maximum operating frequency;
and if the application identification of the application program exists, acquiring the first operating frequency from the target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
Optionally, the obtaining, in the current operation process, a ratio of the CPU operating at the first operation frequency includes:
when the application program is started, acquiring a first frequency list, wherein the first frequency list is used for recording the historical operating frequency and the corresponding operating times of a CPU before the application program is started;
when the application program stops running, acquiring a second frequency list, wherein the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and acquiring the proportion of the CPU running at the first running frequency according to the first frequency list and the second frequency list.
Optionally, the obtaining, according to the first frequency list and the second frequency list, a ratio of the CPU operating at the first operating frequency includes:
performing difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, wherein the third frequency list is used for recording the running frequency of the CPU and the corresponding running times in the current running process of the application program;
and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all the running frequencies in the third frequency list.
Optionally, before the obtaining the ratio of the first operating frequency at which the CPU operates according to the first frequency list and the second frequency list, the method further includes:
calculating the running time of the application program according to the system time when the application program is started and the system time when the application program stops running;
and if the running time of the application program is longer than the preset time, executing the subsequent proportion obtaining step.
All the above-mentioned optional technical solutions can be combined arbitrarily to form the optional embodiments of the present invention, and are not described herein again.
Fig. 2 is a flowchart of a method for adjusting a frequency of a central processing unit according to an embodiment of the present invention. The method is performed by an electronic device, see fig. 2, the method comprising:
201. when the application program is started, it is determined whether an application identifier of the application program exists in a target array, where the target array is used to store a corresponding relationship between the application identifier of the application program and the maximum operating frequency, and if the application identifier of the application program exists, step 202 is executed.
The application identifier may be identification information for uniquely identifying the application, such as a name of the application program or a number of the application program, and the maximum operating frequency may be an operating frequency at which the maximum number of operating times determined based on the operating condition of the CPU is the maximum and the ratio of the number of operating times to the number of operating times of all the operating frequencies reaches a preset threshold in each operating process of the application program. The correspondence may be stored in the form of an array, which refers to a set that organizes several variables (such as application identifiers and corresponding maximum operating frequencies) of the same type in an ordered form. In each operation process of the application program, the electronic device may determine the maximum operation frequency according to the actual operation condition of the CPU, and store the maximum operation frequency in the target array in correspondence with the application identifier of the application program. Therefore, the target array may store application identifiers of all application programs that have been run on the electronic device and corresponding maximum operating frequencies.
In one possible implementation, the electronic device may create a process, such as a service-view. The process is used for monitoring the starting of the application program, and when the application program is started on the electronic equipment, the application program can call the process to enable the process to be started. After the process is started, the electronic device may input the application identifier of the application program to the process, and the process may query the target array to determine whether the application identifier of the currently started application program exists in the target array.
The inventors have realized that the hardware conditions of the electronic device do not change much during a certain time interval. For each application program, the actual running condition of the CPU in the current running process of the application program is approximately the same as the running condition of the CPU in the next running process of the application program. Therefore, the electronic device can correspondingly store the maximum operating frequency determined according to the actual operating condition of the CPU in each operating process of the application program and the application identifier of the application program, so that the electronic device can adjust the maximum operating frequency of the CPU according to the prestored maximum operating frequency in the next operating process of the application program.
202. And acquiring a first operating frequency, and adjusting the maximum operating frequency of the CPU to the first operating frequency, wherein the first operating frequency is the maximum operating frequency determined based on the CPU operating condition in the last operating process of the application program.
In the embodiment of the present invention, when the application program is started, the electronic device may obtain the maximum operating frequency determined in the last operating process of the application program, and adjust the maximum operating frequency of the CPU in the current operating process of the application program according to the maximum operating frequency. Since the first operating frequency is the operating frequency with the largest proportion of the determined operating times according to the actual operating condition of the CPU in the last operating process of the application program, it can be considered that the smooth operation of the application program on the electronic device can be satisfied when the CPU operates at the first operating frequency. After the maximum operation frequency of the CPU is adjusted to the first operation frequency, the CPU will not operate at a higher operation frequency, and the power consumption of the electronic device can be reduced.
In one possible implementation manner, when the application program is started, if it is determined that the application identifier of the application program exists in the target array, the electronic device may obtain a first operating frequency corresponding to the application identifier of the application program from the target array, and adjust the maximum operating frequency of the CPU to the first operating frequency. Of course, the acquisition of the first operating frequency may be performed by the process created in step 201.
203. And in the current operation process, acquiring the proportion of the CPU operating at the first operation frequency.
In the embodiment of the invention, when the application program is started, the electronic equipment can adjust the maximum operating frequency of the CPU to the first operating frequency. Generally, if the CPU runs at the maximum operating frequency for a long time, a large loss is caused to the electronic device, and therefore, the maximum operating frequency of the CPU must be adjusted reasonably to ensure that the CPU does not run at the maximum operating frequency for a long time in order to satisfy smooth running of the application program. Accordingly, to check whether the adjustment is reasonable, the electronic device may determine the ratio of the maximum operating frequency of the CPU according to the actual operating condition of the CPU during the current operation of the application program.
In one possible implementation manner, the electronic device may obtain the proportion of the CPU operating at the first operating frequency through the following steps a to d:
a. when the application program is started, a first frequency list is obtained, and the first frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program is started.
In the embodiment of the invention, the electronic equipment can periodically collect the running frequency of the CPU, and the historical running record of the CPU is updated according to the collected running frequency of the CPU every time, and can be maintained in a frequency list form.
For example, the electronic device may maintain a frequency list for storing a plurality of operating frequencies of the CPU and corresponding operating times, the frequency list being updated according to the result of each acquisition. The plurality of operating frequencies may also be preset by a technician according to hardware conditions of the electronic device, and the number of times of operation corresponding to the plurality of operating frequencies is initially set to 0. Each time the electronic device performs acquisition, the operation frequency corresponding to the acquired operation frequency is added by 1, and of course, if the operation frequency acquired by the electronic device at a certain time is not in the frequency list, the acquired operation frequency may be added to the frequency list, and the operation frequency of the operation frequency is correspondingly stored as 1. Therefore, each time the electronic device acquires the operating frequency of the CPU, it may first determine whether the acquired operating frequency exists in the frequency list, and if not, add the operating frequency to the frequency list, and record the number of times of operation of the operating frequency as 1. And if so, updating the operation times corresponding to the operation frequency.
In the step a, when the application program is started, the electronic device may immediately acquire the first frequency list, and since the first frequency list is acquired when the application program is started, the first frequency list records the historical operating record of the CPU before the application program is started. Of course, the obtaining of the first frequency list may be performed by the process, and in a possible implementation, the obtaining of the first frequency list may include: the process may access a specified field, such as time _ in _ state, in a local storage space of the electronic device, and obtain a value of the specified field as the first frequency list, where the specified field is used to identify a frequency list maintained by the electronic device.
For example, the first frequency list may be as shown in table 1 below:
TABLE 1
Operating frequency (GHz) | Number of runs |
A | X1 |
B | Y1 |
C | Z1 |
D | M1 |
E | N1 |
b. When the application program stops running, acquiring a second frequency list, wherein the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
according to the maintenance process of the electronic device on the frequency list in the step a, the electronic device updates the frequency list according to each acquisition result, that is, the frequency list can change along with time. For example, the frequency list may be a first frequency list when the application starts, and the frequency list may be updated from the first frequency list to a second frequency list when the application stops running.
In step b, when the application program stops running, the electronic device may obtain the second frequency list immediately. Since the second frequency list is obtained when the application stops running, the second frequency list records the historical running record of the CPU before the application stops running. Of course, the acquisition of the second frequency list may be performed by the process created in step 201, and the acquisition of the second frequency list is the same as the acquisition of the first frequency list, and is not described again.
For example, the second frequency list may be as shown in table 2 below:
TABLE 2
Operating frequency (GHz) | Number of runs |
A | X2 |
B | Y2 |
C | Z2 |
D | M2 |
E | N2 |
c. And acquiring the proportion of the CPU running at the first running frequency according to the first frequency list and the second frequency list.
After the first frequency list when the application program is started and the second frequency list when the application program stops operating are obtained through the steps a and b, the electronic device can obtain the operating frequency of the CPU of the application program in the current operating process and the corresponding operating frequency according to the difference between the first frequency list and the second frequency list, and further obtain the proportion of the CPU operating at the first operating frequency.
In one possible implementation, the step c may include: performing difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, wherein the third frequency list is used for recording the running frequency of the CPU and the corresponding running times in the current running process of the application program; and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all the running frequencies in the third frequency list.
For example, the third frequency list may be as shown in table 3 below:
TABLE 3
Operating frequency (GHz) | Number of runs |
A | X2-X1 |
B | Y2-Y1 |
C | Z2-Z1 |
D | M2-M1 |
E | N2-N1 |
Taking the first operating frequency as B in table 3 as an example, in the current operating process of the application program, the number of times of operation of the first operating frequency is (X2-X1), and the number of times of operation of all the operating frequencies is (X2-X1+ Y2-Y1+ Z2-Z1+ M2-M1+ N2-N1), so that the ratio of the operating frequency of the CPU in the current operating process of the application program is (X2-X1)/(X2-X1+ Y2-Y1+ Z2-Z1+ M2-M1+ N2-N1).
If the ratio of the CPU running at the first running frequency is higher, it indicates that the number of times the CPU runs at the maximum running frequency is greater, and further indicates that it is not reasonable to adjust the maximum running frequency of the CPU to the first running frequency, and further correction is required to be performed on the first running frequency, for example, the first running frequency stored in correspondence with the application identifier of the application program is corrected to a second running frequency, and a specific correction process may be implemented in subsequent step 204.
It should be noted that, in order to avoid resource waste caused by some unnecessary modifications, the electronic device may determine whether to modify the maximum operating frequency based on the CPU operating condition in the current operating process of the application according to the actual operating time of the application. Correspondingly, before the electronic device obtains the proportion of the CPU running at the first running frequency, the running duration of the application program may be calculated according to the system time when the application program is started and the system time when the application program stops running; if the running time of the application program is longer than the preset time, such as longer than 10 minutes, the electronic device may execute the step of obtaining the proportion. And if the running time of the application program is less than the preset time, the electronic equipment can record the running time in the target array without executing the subsequent step of acquiring the proportion. For example, when the application program is started, the electronic device may record the system time when the application program is started, and when the application program stops running, the electronic device may record the system time when the application program stops running. Of course, the recording of the system time may be performed by the process created in step 201.
204. And if the proportion is larger than a preset threshold value, increasing the first operating frequency to obtain a second operating frequency, and storing the second operating frequency.
In the embodiment of the present invention, in the current operation process of the application program, if the ratio of the CPU operating at the first operation frequency is greater than the preset threshold, for example, greater than 80%, it indicates that the electronic device operates at the maximum operation frequency most of the time, that is, the first operation frequency is relatively low, so that the electronic device may increase the first operation frequency by one gear to the second operation frequency, for example, increase B to a, and store a as the second operation frequency.
The maximum operation frequency corresponding to the application program is corrected according to the actual operation condition of the CPU when the application program operates every time, so that the timeliness and the accuracy of the maximum operation frequency can be ensured, and the application program can be ensured to smoothly operate on equipment every time due to the fact that the maximum operation frequency is matched with the actual operation condition of the CPU and the actual hardware condition of the equipment.
It should be noted that, in the embodiment of the present invention, the application program is not started for the first time, and the application identifier of the application program exists in the target array. For the case that the application program is started for the first time, the target array in step 201 does not have the application identifier of the application program, and the electronic device may record the application identifier of the application program in real time when the application program is started for the first time. Accordingly, in the first operation process of the application program, the electronic device may obtain a ratio of the CPU operating at a target operation frequency, where the target operation frequency is an operation frequency at which the application program is operated the most times in the first operation process. If the ratio of the target running frequency of the CPU is greater than a target preset threshold, for example, greater than 50%, the electronic device may use the target running frequency as the maximum running frequency of the CPU when the application program runs, and store the target running frequency in the target array in correspondence with the application identifier of the application program. And the target running frequency is used for adjusting the maximum running frequency of the CPU when the application program runs next time.
According to the method provided by the embodiment of the invention, the ratio of the maximum running frequency of the CPU in the current running process of the application program is obtained, and the maximum running frequency of the CPU is re-determined and stored based on the ratio, so that the electronic equipment can adjust the maximum running frequency of the CPU according to the maximum running frequency determined in the current running process in the next running process of the application program. According to the technical scheme, the maximum running frequency of the CPU is continuously corrected according to the actual running condition of the CPU when the application program runs every time, and the timeliness of the maximum running frequency can be guaranteed, so that the accuracy of CPU frequency adjustment is improved, and the application program can smoothly run on equipment every time.
Fig. 3 is a schematic structural diagram of a cpu frequency adjustment apparatus according to an embodiment of the present invention. Referring to fig. 3, the apparatus includes:
an obtaining module 301, configured to obtain a first operating frequency when an application program is started, where the first operating frequency is a maximum operating frequency determined based on a CPU operating condition in a last operating process of the application program;
an adjusting module 302, configured to adjust a maximum operating frequency of the CPU to the first operating frequency;
the obtaining module 301 is further configured to obtain, in a current operation process, a ratio of the CPU operating at the first operation frequency;
an increasing module 303, configured to increase the first operating frequency to obtain a second operating frequency if the ratio is greater than a preset threshold, and store the second operating frequency.
Optionally, the adjusting module 302 is configured to determine whether an application identifier of the application program exists in a target array, where the target array is configured to store a corresponding relationship between the application identifier of the application program and the maximum operating frequency; and if the application identification of the application program exists, acquiring the first operating frequency from the target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
Optionally, the obtaining module 301 includes:
the first obtaining submodule is used for obtaining a first frequency list when the application program is started, and the first frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program is started;
the second obtaining submodule is used for obtaining a second frequency list when the application program stops running, and the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and the third obtaining submodule is used for obtaining the proportion of the first operating frequency of the CPU according to the first frequency list and the second frequency list.
Optionally, the third obtaining submodule is configured to perform difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, where the third frequency list is used to record the operating frequency of the CPU and the corresponding operating frequency in the current operating process of the application program; and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all the running frequencies in the third frequency list.
Optionally, referring to fig. 4, the apparatus further comprises:
a calculating module 304, configured to calculate an operation duration of the application according to the system time when the application is started and the system time when the application stops operating;
the obtaining module 301 is further configured to execute a subsequent step of obtaining the proportion if the running time of the application is longer than a preset time.
In the embodiment of the invention, the proportion of the maximum running frequency of the CPU is obtained in the current running process of the application program, and the maximum running frequency of the CPU is re-determined and stored based on the proportion, so that the electronic equipment can adjust the maximum running frequency of the CPU according to the maximum running frequency determined in the current running process in the next running process of the application program. According to the technical scheme, the maximum running frequency of the CPU is continuously corrected according to the actual running condition of the CPU when the application program runs every time, and the timeliness of the maximum running frequency can be guaranteed, so that the accuracy of CPU frequency adjustment is improved, and the application program can smoothly run on equipment every time.
It should be noted that: the central processing unit frequency adjusting apparatus provided in the above embodiment is only illustrated by dividing the functional modules when the central processing unit frequency adjusts, and in practical application, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the cpu frequency adjusting apparatus provided in the foregoing embodiment and the cpu frequency adjusting method embodiment belong to the same concept, and specific implementation processes thereof are described in detail in the method embodiment and are not described herein again.
An embodiment of the present invention provides an electronic device 500, where the electronic device 500 may be configured to perform the method for adjusting the frequency of the central processing unit provided in the foregoing embodiments. Referring to fig. 5, the electronic device 500 includes:
the electronic device 500 may include RF (Radio Frequency) circuitry 110, memory 120 including one or more computer-readable storage media, an input unit 130, a display unit 140, a sensor 150, audio circuitry 160, a WiFi (Wireless Fidelity) module 170, a processor 180 including one or more processing cores, and a power supply 190. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 5 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 110 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information from a base station and then sends the received downlink information to the one or more processors 180 for processing; in addition, data relating to uplink is transmitted to the base station. In general, the RF circuitry 110 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuitry 110 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), e-mail, SMS (short messaging Service), etc.
The memory 120 may be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by operating the software programs and modules stored in the memory 120. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the electronic device 500, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 120 may further include a memory controller to provide the processor 180 and the input unit 130 with access to the memory 120.
The input unit 130 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 130 may include a touch-sensitive surface 131 as well as other input devices 132. The touch-sensitive surface 131, also referred to as a touch display screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 131 (e.g., operations by a user on or near the touch-sensitive surface 131 using a finger, a stylus, or any other suitable object or attachment), and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 180, and can receive and execute commands sent by the processor 180. Additionally, the touch-sensitive surface 131 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface 131, the input unit 130 may also include other input devices 132. In particular, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 140 may be used to display information input by or provided to a user and various graphical user interfaces of the electronic device 500, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 140 may include a Display panel 141, and optionally, the Display panel 141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and when a touch operation is detected on or near the touch-sensitive surface 131, the touch operation is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of the touch event. Although in FIG. 5, touch-sensitive surface 131 and display panel 141 are shown as two separate components to implement input and output functions, in some embodiments, touch-sensitive surface 131 may be integrated with display panel 141 to implement input and output functions.
The electronic device 500 may also include at least one sensor 150, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 141 and/or the backlight when the electronic device 500 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the electronic device 500, detailed descriptions thereof are omitted.
Audio circuitry 160, speaker 161, and microphone 162 may provide an audio interface between a user and the electronic device 500. The audio circuit 160 may transmit the electrical signal converted from the received audio data to the speaker 161, and convert the electrical signal into a sound signal for output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electric signal, which is received by the audio circuit 160 and converted into audio data, which is then processed by the audio data output processor 180, and then transmitted to, for example, another electronic device via the RF circuit 110, or output to the memory 120 for further processing. The audio circuitry 160 may also include an earbud jack to provide communication of peripheral headphones with the electronic device 500.
WiFi belongs to short-range wireless transmission technology, and the electronic device 500 can help the user send and receive e-mails, browse web pages, access streaming media, etc. through the WiFi module 170, and it provides the user with wireless broadband internet access. Although fig. 5 shows the WiFi module 170, it is understood that it does not belong to the essential constitution of the electronic device 500, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 180 is a control center of the electronic device 500, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the electronic device 500 and processes data by operating or executing software programs and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the mobile phone. Optionally, processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
The electronic device 500 further includes a power supply 190 (e.g., a battery) for supplying power to the various components, which may preferably be logically connected to the processor 180 via a power management system, so as to manage charging, discharging, and power consumption via the power management system. The power supply 190 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, the electronic device 500 may further include a camera, a bluetooth module, and the like, which are not described in detail herein. In this embodiment, the display unit of the electronic device is a touch screen display, and the electronic device further includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors. The one or more programs include instructions for performing the electronic device-side operations in the examples implemented in fig. 1 or fig. 2 described above.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (10)
1. A method for adjusting a frequency of a central processing unit, the method comprising:
when an application program is started, acquiring a first running frequency, and adjusting the maximum running frequency of a CPU (Central processing Unit) to the first running frequency, wherein the first running frequency is the maximum running frequency determined based on the running condition of the CPU in the last running process of the application program;
acquiring the proportion of the first running frequency of the CPU in the current running process of the application program;
and if the proportion is larger than a preset threshold value, increasing the first operating frequency to obtain a second operating frequency, and storing the second operating frequency.
2. The method of claim 1, wherein adjusting the maximum operating frequency of the CPU to the first operating frequency comprises:
determining whether an application identifier of the application program exists in a target array, wherein the target array is used for storing a corresponding relation between the application identifier of the application program and the maximum operating frequency;
and if the application identifier of the application program exists, acquiring the first operating frequency from a target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
3. The method of claim 1, wherein the obtaining the proportion of the application program that the CPU is operating at the first operating frequency during the current operation comprises:
when the application program is started, acquiring a first frequency list, wherein the first frequency list is used for recording the historical running frequency and the corresponding running times of a CPU before the application program is started;
when the application program stops running, acquiring a second frequency list, wherein the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and acquiring the proportion of the CPU running at the first running frequency according to the first frequency list and the second frequency list.
4. The method of claim 3, wherein obtaining the proportion of the CPU operating at the first operating frequency according to the first frequency list and the second frequency list comprises:
performing difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, wherein the third frequency list is used for recording the running frequency of the CPU and the corresponding running times in the current running process of the application program;
and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all running frequencies in the third frequency list.
5. The method of claim 3, wherein before obtaining the proportion of the CPU operating at the first operating frequency based on the first frequency list and the second frequency list, the method further comprises:
calculating the running duration of the application program according to the system time when the application program is started and the system time when the application program stops running;
and if the running time of the application program is longer than the preset time, executing the subsequent proportion obtaining step.
6. An apparatus for adjusting a frequency of a central processing unit, the apparatus comprising:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first operating frequency when an application program is started, and the first operating frequency is the maximum operating frequency determined based on the CPU operating condition in the last operating process of the application program;
the adjusting module is used for adjusting the maximum running frequency of the CPU to the first running frequency;
the obtaining module is further configured to obtain a ratio of the first operating frequency of the CPU in a current operating process of the application program;
and the increasing module is used for increasing the first operating frequency to obtain a second operating frequency and storing the second operating frequency if the proportion is greater than a preset threshold value.
7. The apparatus of claim 6, wherein the adjusting module is configured to determine whether an application identifier of the application program exists in a target array, and the target array is configured to store a correspondence between the application identifier of the application program and a maximum operating frequency; and if the application identifier of the application program exists, acquiring the first operating frequency from a target array, and adjusting the maximum operating frequency of the CPU to the first operating frequency.
8. The apparatus of claim 6, wherein the obtaining module comprises:
the first obtaining submodule is used for obtaining a first frequency list when the application program is started, and the first frequency list is used for recording the historical running frequency and the corresponding running times of a CPU before the application program is started;
the second obtaining submodule is used for obtaining a second frequency list when the application program stops running, and the second frequency list is used for recording the historical running frequency and the corresponding running times of the CPU before the application program stops running;
and the third obtaining submodule is used for obtaining the proportion of the first operating frequency of the CPU according to the first frequency list and the second frequency list.
9. The apparatus according to claim 8, wherein the third obtaining sub-module is configured to perform difference calculation on the second frequency list and the first frequency list to obtain a third frequency list, where the third frequency list is used to record an operating frequency and a corresponding operating frequency of a CPU in a current operating process of the application program; and acquiring the proportion of the CPU running at the first running frequency in the current running process of the application program according to the running times of the first running frequency and the running times of all running frequencies in the third frequency list.
10. The apparatus of claim 8, further comprising:
the computing module is used for computing the running time of the application program according to the system time when the application program is started and the system time when the application program stops running;
the obtaining module is further configured to execute a subsequent step of obtaining the proportion if the running duration of the application program is greater than a preset duration.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710251827.3A CN107122036B (en) | 2017-04-18 | 2017-04-18 | Method and device for adjusting frequency of central processing unit |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710251827.3A CN107122036B (en) | 2017-04-18 | 2017-04-18 | Method and device for adjusting frequency of central processing unit |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107122036A CN107122036A (en) | 2017-09-01 |
CN107122036B true CN107122036B (en) | 2020-01-14 |
Family
ID=59724710
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710251827.3A Active CN107122036B (en) | 2017-04-18 | 2017-04-18 | Method and device for adjusting frequency of central processing unit |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107122036B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112000215A (en) * | 2020-08-25 | 2020-11-27 | 北京字节跳动网络技术有限公司 | Terminal control method and device and electronic equipment |
CN112486683B (en) * | 2020-11-27 | 2023-05-19 | 中国科学技术大学先进技术研究院 | Processor control method, control apparatus, and computer-readable storage medium |
CN113487707B (en) * | 2021-06-30 | 2024-07-30 | 北京达佳互联信息技术有限公司 | Webpage animation processing method and device, electronic equipment and storage medium |
CN114546098B (en) * | 2022-02-15 | 2024-10-25 | 深圳Tcl新技术有限公司 | Method and device for adjusting frequency of processor, storage medium and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103500003A (en) * | 2013-09-30 | 2014-01-08 | 北京奇虎科技有限公司 | Method and device for regulating CPU frequency of portable terminal |
CN104007806A (en) * | 2014-06-20 | 2014-08-27 | 中科创达软件股份有限公司 | Method and device for controlling CPU frequency in Android system and equipment |
CN104794005A (en) * | 2015-03-23 | 2015-07-22 | 北京畅游天下网络技术有限公司 | Method and device for optimizing CPU running frequencies |
CN105975050A (en) * | 2016-05-24 | 2016-09-28 | 青岛海信移动通信技术股份有限公司 | Terminal power consumption control method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9354903B2 (en) * | 2012-07-24 | 2016-05-31 | Beijing Lenovo Software Ltd. | Control method and electronic device |
US20160116954A1 (en) * | 2014-10-28 | 2016-04-28 | Linkedln Corporation | Dynamic adjustment of cpu operating frequency |
-
2017
- 2017-04-18 CN CN201710251827.3A patent/CN107122036B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103500003A (en) * | 2013-09-30 | 2014-01-08 | 北京奇虎科技有限公司 | Method and device for regulating CPU frequency of portable terminal |
CN104007806A (en) * | 2014-06-20 | 2014-08-27 | 中科创达软件股份有限公司 | Method and device for controlling CPU frequency in Android system and equipment |
CN104794005A (en) * | 2015-03-23 | 2015-07-22 | 北京畅游天下网络技术有限公司 | Method and device for optimizing CPU running frequencies |
CN105975050A (en) * | 2016-05-24 | 2016-09-28 | 青岛海信移动通信技术股份有限公司 | Terminal power consumption control method and device |
Also Published As
Publication number | Publication date |
---|---|
CN107122036A (en) | 2017-09-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107094294B (en) | Network connection method and device | |
CN107277912B (en) | Radio frequency interference processing method, device, storage medium and terminal | |
CN107393548B (en) | Method and device for processing voice information collected by multiple voice assistant devices | |
CN108268366B (en) | Test case execution method and device | |
CN106294168B (en) | A kind of method and system carrying out Application testing | |
CN106487984B (en) | A kind of method and apparatus adjusting volume | |
KR20170129197A (en) | Message updating method, device and terminal | |
CN107122036B (en) | Method and device for adjusting frequency of central processing unit | |
CN107219951B (en) | Touch screen control method and device, storage medium and terminal equipment | |
WO2015078342A1 (en) | Method for acquiring memory information, and terminal | |
CN103455330A (en) | Application program management method, terminal, equipment and system | |
CN108492837B (en) | Method, device and storage medium for detecting audio burst white noise | |
CN113286335B (en) | Frequency point switching method and device, storage medium and access point | |
CN106374988B (en) | Method, device and terminal for configuring inter-downlink-band carrier aggregation | |
CN110730013B (en) | Method for improving transmission stray and mobile terminal | |
CN106817324B (en) | Frequency response correction method and device | |
CN105159655B (en) | Behavior event playing method and device | |
CN104954231B (en) | Method and device for sending and displaying recommendation information | |
CN108269223B (en) | Webpage graph drawing method and terminal | |
CN105635379B (en) | Noise suppression method and device | |
CN106341436B (en) | Method and device for detecting acceleration effect | |
CN104836698A (en) | Method monitoring network environment and device | |
CN106982177B (en) | Upgrade control method, device and terminal | |
CN108280798B (en) | Method and device for rendering and displaying browser kernel | |
CN108111553B (en) | Method and device for providing service |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder |
Address after: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11 Patentee after: Qingdao Hisense Mobile Communication Technology Co.,Ltd. Address before: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11 Patentee before: HISENSE MOBILE COMMUNICATIONS TECHNOLOGY Co.,Ltd. |
|
CP01 | Change in the name or title of a patent holder |