WO2014135129A1 - Processor operating frequency control method and device - Google Patents

Processor operating frequency control method and device Download PDF

Info

Publication number
WO2014135129A1
WO2014135129A1 PCT/CN2014/073405 CN2014073405W WO2014135129A1 WO 2014135129 A1 WO2014135129 A1 WO 2014135129A1 CN 2014073405 W CN2014073405 W CN 2014073405W WO 2014135129 A1 WO2014135129 A1 WO 2014135129A1
Authority
WO
WIPO (PCT)
Prior art keywords
processor
application
frequency
operating frequency
running time
Prior art date
Application number
PCT/CN2014/073405
Other languages
French (fr)
Chinese (zh)
Inventor
古幼鹏
钟声
胡炜
徐立锋
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014135129A1 publication Critical patent/WO2014135129A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power
    • G06F1/3203Power management, i.e. event-based initiation of a power-saving mode
    • G06F1/3234Power saving characterised by the action undertaken
    • G06F1/324Power saving characterised by the action undertaken by lowering clock frequency
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power
    • G06F1/3203Power management, i.e. event-based initiation of a power-saving mode
    • G06F1/3206Monitoring of events, devices or parameters that trigger a change in power modality
    • G06F1/3228Monitoring task completion, e.g. by use of idle timers, stop commands or wait commands
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the field of processor power consumption control technologies, and in particular, to a method and an apparatus for controlling a processor operating frequency.
  • the power consumption problem has become an important limiting factor for various electronic devices, especially mobile device development.
  • the processor of the mobile device that is, the CPU
  • CPU power consumption becomes the main mobile device. Power consumer. Therefore, CPU power consumption control is important to extend the use time of mobile devices.
  • the basic idea of CPU power consumption control is to dynamically adjust the CPU operating frequency according to the system load.
  • the classic dynamic frequency modulation algorithm is to periodically count the CPU usage and increase or decrease the CPU operating frequency according to the CPU usage.
  • the system load has a sudden characteristic, and the timing frequency modulation will not respond to sudden tasks (such as the user's touch operation), which affects the user's touch operation experience.
  • an immediate up-conversion operation is added on the basis of time-frequency modulation, that is, when the user has a touch operation, the CPU operating frequency is immediately raised to a default high frequency, and then the frequency is raised and lowered according to the timing dynamic frequency modulation algorithm.
  • the existing dynamic frequency modulation algorithm is a fixed value in the frequency range setting. If this value is large, it will affect the energy saving effect. If it is small, it will affect the application performance. Therefore, there is an urgent need for a method that does not affect the performance of the application and reduces the power consumption of the CPU.
  • the technical problem to be solved by the embodiments of the present invention is to provide a method and a device for controlling the operating frequency of a processor, so as to flexibly adjust the operating frequency of the processor according to the usage of the application.
  • the technical solution adopted by the embodiment of the present invention is that the method for controlling the operating frequency of the processor includes: when the application is started in the foreground, based on the running time of the processor corresponding to the application program at each working frequency The highest processor operating frequency required by the application is used as the upper operating frequency limit that the processor can achieve at this application runtime.
  • the process of acquiring the running time of the processor corresponding to the application in each of the working frequencies in the past includes: counting the running time of the processor on each working frequency in the time period during which the application runs in the foreground; The statistical average of the running time of the processor on each working frequency before the application is started is performed, and the statistical average result is used as the running time of the processor corresponding to the application corresponding to the previous operating frequency.
  • the counting the running time of the processor on each working frequency in the time period in which the application runs in the foreground includes: when the application is started in the foreground, recording the processor at each working frequency
  • the running time value T0 when the application exits the foreground, records the running time value Tl of the processor at each operating frequency
  • the highest processor operating frequency required by the application is selected, which specifically includes: The frequency is from high to low, and the running time on each working frequency is sequentially compared with the set corresponding threshold.
  • the working frequency is selected as the application requirement.
  • the highest processor operating frequency stop continuing to compare.
  • the highest processor operating frequency required by the application is selected, which specifically includes: From high to low, the running time on each working frequency is compared with the corresponding threshold set in turn.
  • the comparison is stopped: First case: If the running time is once on a working frequency If the threshold is greater than or equal to the corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application; the second case: if the total running time on the compared operating frequency reaches the set total duration threshold, The smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application.
  • the highest processor operating frequency required by the application is selected, which includes: The running time of the current maximum operating frequency of the device is compared with the corresponding threshold set.
  • the operating frequency is selected as the application requirement.
  • the highest processor operating frequency is required, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application.
  • the highest processor operating frequency required by the application is used as an upper operating frequency limit that can be achieved by the application runtime processor, and specifically includes: setting a maximum processor operating frequency required by the application to the operation
  • the system kernel by the operating system kernel, limits the maximum frequency of automatic frequency conversion when the application is running cannot exceed the maximum processor operating frequency required by the application.
  • the embodiment of the present invention further provides a processor operating frequency control device, including: a frequency control module, configured to: when the application is started in the foreground, based on the running time of the processor corresponding to the application program at each working frequency, Select the highest processor operating frequency required by the application and use it as the upper operating frequency limit that the processor can achieve at this application runtime.
  • the device further includes: a duration statistics module, configured to count a running time of the processor on each working frequency in a time period during which the application runs in the foreground, the processor before starting the application The running time on each working frequency is statistically averaged, and the statistical average result is used as the running time of the processor corresponding to the application in each working frequency.
  • the duration statistics module is specifically configured to: when the application is started in the foreground, record the running time value ⁇ of the processor on each working frequency, and when the application exits the foreground, the processor is recorded.
  • the frequency control module is specifically configured to: compare the running time on each working frequency with the set corresponding threshold value in turn according to the working frequency from high to low, once a certain If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, and the comparison is stopped.
  • the frequency control module is specifically configured to: In order to compare the running time of each working frequency with the corresponding threshold value, the running time is sequentially compared with the set corresponding threshold. If one of the following two conditions occurs, the comparison is stopped: First case: If a working frequency occurs once If the running time is greater than or equal to the set corresponding threshold, the working frequency is selected as the highest processor operating frequency required by the application; the second case: if the running time of the compared operating frequency reaches the set total The duration threshold takes the smallest of the compared operating frequencies as the highest operating frequency value required by the application.
  • the frequency control module is specifically configured to: compare a running time of the current highest operating frequency of the processor with a set corresponding threshold, and if the working frequency is running If it is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application.
  • the frequency control module is specifically configured to: set a maximum processor operating frequency required by the application to an operating system kernel, and the operating system kernel limits the maximum frequency of automatic frequency conversion when the application program is running. Exceeding the maximum processor operating frequency required by the application.
  • the embodiment of the present invention has at least the following advantages:
  • the method and device for controlling the operating frequency of the processor according to the embodiment of the present invention statistically learning the processor performance required when each application runs in the foreground, and then when the application When the program is running in the foreground, the processor's dynamic frequency modulation range is limited to the appropriate range, which ensures the performance of the application and maximizes energy saving.
  • FIG. 1 is a flowchart of a method for controlling a working frequency of a processor according to a first embodiment of the present invention
  • a first embodiment of the present invention includes the following specific steps: Step S101, counting the operating time of the processor at each working frequency in a period of time during which the application runs in the foreground The length of the run on. Specifically, when the application is running in the foreground, the running time values of the processor at each working frequency are updated in a time slice cumulative manner.
  • the runtime value ⁇ of the processor at each working frequency is recorded, and when the application exits the foreground, the running time value ⁇ of the processor at each working frequency is recorded.
  • the embodiment of the present invention only counts the processor usage of the application when running in the foreground, because usually the application does not need to perform touch interaction with the user when running in the background, and the burst operation requirement of the processor is less, basically cannot The performance of the application when interacting with the user is reflected. Therefore, in order to satisfy the user's instant use experience, the embodiment of the present invention only focuses on the application when the foreground has a touch interaction with the user.
  • the number of operating frequencies of the processor and the value of each operating frequency are related to the model of the specific processor. Therefore, the embodiment of the present invention does not limit this.
  • Step S102 when the application is started in the foreground, statistically average the running time of the processor on each operating frequency before starting the application, and the statistical average result is used as the processing corresponding to the application in the past.
  • the process of acquiring the running time of the processor corresponding to the application at each working frequency in the past includes: calculating the running time of the processor on each working frequency each time the application runs in the foreground based on the statistics in step S102
  • the statistical average of the running time of the processor at each working frequency set by the number of times before starting the application, for example: averaging or weighting the running time of each time for each working frequency,
  • the statistical average result is used as the running time of the processor corresponding to the application in the past at each operating frequency.
  • the processor is set in each work only for the number of times before the application is started this time.
  • the running time on the frequency is statistically averaged, instead of statistically averaging the running time of all the processors at each working frequency before starting the application, on the one hand, in order to save system storage space, at this time It is necessary to age the statistics that exceed the set number of times. On the other hand, it is due to the statistics of the CPU usage during the recent application running, which is closer to the user's current demand for the application.
  • Step S103 selecting, according to the running time of the processor corresponding to the application program at each operating frequency, the highest processor operating frequency required by the application, and using the processor as the running time of the application. The upper limit of the operating frequency reached.
  • the highest processor operating frequency required by the application is selected, which specifically includes: according to the operating frequency from high to In a low order, the running time on each working frequency is sequentially compared with the set corresponding threshold. If the running time on a certain operating frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as required by the application.
  • the highest processor operating frequency is used to stop the comparison; preferably, if the total running time on the compared operating frequency reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the application required
  • the highest operating frequency value, stop the comparison, to avoid the system is slow to respond due to the low frequency limit.
  • step S103 the following method may also be used to determine the highest processor operating frequency required by the application, and the specific process includes: setting the running time and setting of the current highest operating frequency of the processor. The threshold is compared. If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the The highest processor operating frequency required by the application.
  • the highest processor operating frequency required by the application is used as the upper limit of the operating frequency that the processor can achieve at the time of the application running, and specifically includes: setting the highest processor operating frequency required by the application. To the operating system kernel, the maximum frequency that limits automatic frequency conversion by the operating system kernel while the application is running cannot exceed the maximum processor operating frequency required by the application.
  • a second embodiment of the present invention a processor operating frequency control device, as shown in FIG. 2, includes: 1) The duration statistics module 100 is configured to count the running time of the processor on each working frequency in the time period during which the application runs in the foreground, and the processor is set to the number of times before starting the application.
  • the running time on the working frequency is statistically averaged, for example: For each working frequency, the running time of each time is averaged or weighted average, and the statistical average result is used as the processor corresponding to the application in the past. The length of the run on the frequency.
  • the duration statistics module 100 is configured to: when the application is started in the foreground, record the running time value ⁇ of the processor at each working frequency, and record the processor in each work while the application exits the foreground.
  • the frequency control module 200 is configured to select the highest processor working required by the application when the application is started in the foreground, based on the running time of the processor corresponding to the application in each working frequency. Frequency, and as the upper limit of the operating frequency that the processor can achieve at this application runtime.
  • the frequency control module 200 determines the highest processor operating frequency required by the application in the following manner: according to the order of the operating frequency from high to low, sequentially the running time on each working frequency and the corresponding threshold set. For comparison, if the running time of a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, and the comparison is stopped; preferably, if the operating frequency is compared If the sum of the running time reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application, and the comparison is stopped to avoid the system response being too low. slow.
  • the frequency control module 200 can also determine the highest processor operating frequency required by the application in the following convenient manner: comparing the running time of the current working frequency of the processor with the set threshold, if If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the highest processor required by the application. working frequency.
  • the frequency control module 200 sets the highest processor operating frequency required by the application to the operating system kernel, and the operating system kernel limits the maximum frequency of the automatic frequency conversion to exceed the application requirement when the application program is running. The highest processor operating frequency.
  • This application example provides a method for controlling the operating frequency of the CPU based on the running statistics of the application, without loss of generality.
  • An arbitrary application A is taken as an example to illustrate, as shown in FIG. 3, the method is executed cyclically. Each cycle is the time period from the start of the application to the exit of the foreground. The steps in each cycle are as follows: Step a, when the application A switches to the foreground, the CPU is acquired at each working frequency. The running time value TO; Step a2, determining whether the statistical number of running statistics of the application A reaches the set value, and if so, the statistical data is considered to reflect the CPU performance when the application A interacts with the user normally.
  • step a6 otherwise, it is considered that the CPU performance when the application A interacts with the user normally cannot be reflected.
  • Time value T1; Step a4, the value obtained by subtracting TO from T1 is deltaT, which is the application A in this running time period.
  • the usage of the CPU; in step a5, the deltaT value obtained in step a4 is recorded in the data structure of the application A, and the process proceeds to step a8; in step a6, the statistical statistics of the running statistics of the application A are statistically processed, and then processed according to the statistical average.
  • step a7 the f determined in the step a6 is set to the operating system kernel, so that the operating system kernel limits the maximum conversion value to not exceed f when the automatic frequency conversion is performed.
  • step a3 the process ends.
  • step a8 the process ends.
  • Application Example 2 This application example introduces a frequency control process implemented on an Android mobile phone. In the Android system,
  • the ActivityManagerService module is responsible for switching the application interface Activity.
  • the specific implementation process in the Android system is as follows: Step bl, when the ActivityManagerService module switches the application display interface Activity, according to the ActivityRecord information, the application program to which the display interface belongs is obtained; Step b2, if the application is different from the application to which the Activity before the switch belongs, indicating that the foreground application has occurred.
  • Step b3 finds the corresponding Uid.Pkg object inside the system (that is, the data structure mentioned in the application instance 1), the Uid.Pkg object internally records the corresponding application
  • the CPU of the program runs statistical data, calculates the CPU time spent on an application in the foreground, and saves the data value in the Uid.Pkg object corresponding to an application in the foreground;
  • Step b4 determines whether the recorded CPU running statistics reaches 3 If yes, indicating that the statistics are valid, go to step b5, otherwise, go to step b6 ;
  • step b5 calculate the maximum CPU operating frequency that can be used by the application based on the recorded CPU running statistics of the application 3 times, and Write this frequency value to the file "/sys/devices/syste m/cpu/cpuO/cpufreq/scaling_max_freq" ⁇ , in this way, the operating system kernel can automatically limit the maximum operating frequency

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Power Sources (AREA)

Abstract

Disclosed are a processor operating frequency control method and device, the method comprising: when an application program is running in the foreground, performing statistics on the running time lengths of a processor on different operating frequencies; when the application program initiates in the foreground at the present time, selecting, on the basis of the past running time lengths of the processor corresponding to the application program on different operating frequencies, the highest processor operating frequency required for the application program and treating said frequency as the operating frequency upper limit that the processor can reach during the application program running. The device comprises: a time length statistics module and a frequency control module. In the present invention, the processor function required during the time each application program runs in the foreground is studied and analyzed for statistics. When an application program is running in the foreground, the frequency of the processor is dynamically adjusted to be within an appropriate range, thereby ensuring the program application function and maximizing energy conservation.

Description

一种处理器工作频率的控制方法及装置 技术领域 本发明涉及处理器功耗控制技术领域, 尤其涉及一种处理器工作频率的控制方法 及装置。 背景技术 功耗问题已经成为各种电子设备, 尤其是移动设备发展的一个重要限制因素, 随 着移动设备的处理器即 CPU向高频率和多核的方向发展, CPU功耗成为了移动设备 主要的电源消耗者。 因此, CPU功耗控制对延长移动设备的使用时间有重要意义。  TECHNICAL FIELD The present invention relates to the field of processor power consumption control technologies, and in particular, to a method and an apparatus for controlling a processor operating frequency. BACKGROUND OF THE INVENTION The power consumption problem has become an important limiting factor for various electronic devices, especially mobile device development. As the processor of the mobile device, that is, the CPU, develops toward high frequency and multi-core, CPU power consumption becomes the main mobile device. Power consumer. Therefore, CPU power consumption control is important to extend the use time of mobile devices.
CPU功耗控制的基本思路是根据系统负荷对 CPU工作频率进行动态调频, 经典 的动态调频算法是定时统计 CPU的占用率,根据 CPU占用率的情况提升或者降低 CPU 工作频率。 对于手机等设备来说, 其系统负荷具有突发性的特点, 定时调频会对突发 任务 (如用户的触控操作) 响应不及时, 影响对用户触控操作体验。 对这类系统, 在 定时调频基础上增加一个立即升频操作, 即当用户有触控操作时, 立即把 CPU工作频 率升高到一个默认高频, 然后再按定时动态调频算法进行频率升降。 不管具体的动态 调频算法如何变化, 均需要设定一个频率调整范围, 即最大可能达到的频率和最小可 能达到的频率。 同样的动态调频算法, 由于频率范围的设置不同, 所能起到的节能效 果也是不同的。 但是, 现有的动态调频算法, 在频率范围设置上都是一个固定值, 这 个值取大了则影响节能效果, 取小了会影响应用程序性能。 因此, 目前急需一种既不影响应用程序的性能, 又能降低 CPU功耗的方法。 发明内容 本发明实施例要解决的技术问题是,提供一种处理器工作频率的控制方法及装置, 以实现根据应用程序的使用情况灵活调整处理器工作频率。 本发明实施例采用的技术方案是, 所述处理器工作频率的控制方法, 包括: 在前台启动应用程序时, 基于以往所述应用程序对应的处理器在各工作频率上的 运行时长, 选择出所述应用程序需要的最高处理器工作频率, 并将其作为本次应用程 序运行时处理器所能达到的工作频率上限。 优选地,以往所述应用程序对应的处理器在各工作频率上的运行时长的获取过程, 包括: 统计该应用程序每次在前台运行的时间段内处理器在各工作频率上的运行时长; 对本次启动应用程序之前所述处理器在各工作频率上的运行时长做统计平均, 将 统计平均的结果作为以往所述应用程序对应的处理器在各工作频率上的运行时长。 优选地, 所述统计该应用程序每次在前台运行的时间段内处理器在各工作频率上 的运行时长, 具体包括: 当应用程序在前台启动的同时, 记录下处理器在各工作频率上的运行时间值 T0, 当应用程序退出前台的同时, 记录下处理器在各工作频率上的运行时间值 Tl, 则该应 用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0。 优选地, 作为一种可选的技术方案, 基于以往所述应用程序对应的处理器在各工 作频率上的运行时长, 选择出所述应用程序需要的最高处理器工作频率, 具体包括: 以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值进行比 较, 一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所 述应用程序需要的最高处理器工作频率, 停止继续比较。 优选地, 作为一种优选的技术方案, 基于以往所述应用程序对应的处理器在各工 作频率上的运行时长, 选择出所述应用程序需要的最高处理器工作频率, 具体包括: 以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值进行比 较, 若出现下面两个情况之一, 则停止继续比较: 第一个情况: 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该 工作频率作为所述应用程序需要的最高处理器工作频率; 第二个情况: 若比较过的工作频率上的运行时长总和达到设定的总时长阈值, 则 取比较过的工作频率中的最小者作为所述应用程序需要的最高工作频率值。 优选地, 作为一种可选的技术方案, 基于以往所述应用程序对应的处理器在各工 作频率上的运行时长, 选择出所述应用程序需要的最高处理器工作频率, 具体包括: 将处理器的当前最高工作频率上的运行时长与设定的相应阈值进行比较, 若该工 作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所述应用程序需 要的最高处理器工作频率, 否则选择处理器的次高工作频率作为所述应用程序需要的 最高处理器工作频率。 优选地, 将所述应用程序需要的最高处理器工作频率作为本次应用程序运行时处 理器所能达到的工作频率上限, 具体包括: 将所述应用程序需要的最高处理器工作频率设置到操作系统内核, 由操作系统内 核在所述应用程序运行时, 限制自动变频的最高频率不能超过所述应用程序需要的最 高处理器工作频率。 The basic idea of CPU power consumption control is to dynamically adjust the CPU operating frequency according to the system load. The classic dynamic frequency modulation algorithm is to periodically count the CPU usage and increase or decrease the CPU operating frequency according to the CPU usage. For mobile phones and other devices, the system load has a sudden characteristic, and the timing frequency modulation will not respond to sudden tasks (such as the user's touch operation), which affects the user's touch operation experience. For this type of system, an immediate up-conversion operation is added on the basis of time-frequency modulation, that is, when the user has a touch operation, the CPU operating frequency is immediately raised to a default high frequency, and then the frequency is raised and lowered according to the timing dynamic frequency modulation algorithm. Regardless of how the specific dynamic frequency modulation algorithm changes, it is necessary to set a frequency adjustment range, that is, the maximum possible frequency and the minimum possible frequency. The same dynamic frequency modulation algorithm, due to the different frequency range settings, can also achieve different energy saving effects. However, the existing dynamic frequency modulation algorithm is a fixed value in the frequency range setting. If this value is large, it will affect the energy saving effect. If it is small, it will affect the application performance. Therefore, there is an urgent need for a method that does not affect the performance of the application and reduces the power consumption of the CPU. SUMMARY OF THE INVENTION The technical problem to be solved by the embodiments of the present invention is to provide a method and a device for controlling the operating frequency of a processor, so as to flexibly adjust the operating frequency of the processor according to the usage of the application. The technical solution adopted by the embodiment of the present invention is that the method for controlling the operating frequency of the processor includes: when the application is started in the foreground, based on the running time of the processor corresponding to the application program at each working frequency The highest processor operating frequency required by the application is used as the upper operating frequency limit that the processor can achieve at this application runtime. Preferably, the process of acquiring the running time of the processor corresponding to the application in each of the working frequencies in the past includes: counting the running time of the processor on each working frequency in the time period during which the application runs in the foreground; The statistical average of the running time of the processor on each working frequency before the application is started is performed, and the statistical average result is used as the running time of the processor corresponding to the application corresponding to the previous operating frequency. Preferably, the counting the running time of the processor on each working frequency in the time period in which the application runs in the foreground includes: when the application is started in the foreground, recording the processor at each working frequency The running time value T0, when the application exits the foreground, records the running time value Tl of the processor at each operating frequency, then the running time of the processor at each working frequency of the running time of the application is deltaT= Tl-T0. Preferably, as an optional technical solution, based on the running time of the processor corresponding to the application program at each working frequency, the highest processor operating frequency required by the application is selected, which specifically includes: The frequency is from high to low, and the running time on each working frequency is sequentially compared with the set corresponding threshold. Once the running time on a working frequency is greater than or equal to the set corresponding threshold, the working frequency is selected as the application requirement. The highest processor operating frequency, stop continuing to compare. Preferably, as a preferred technical solution, based on the running time of the processor corresponding to the application program at each working frequency, the highest processor operating frequency required by the application is selected, which specifically includes: From high to low, the running time on each working frequency is compared with the corresponding threshold set in turn. If one of the following two conditions occurs, the comparison is stopped: First case: If the running time is once on a working frequency If the threshold is greater than or equal to the corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application; the second case: if the total running time on the compared operating frequency reaches the set total duration threshold, The smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application. Preferably, as an optional technical solution, based on the running time of the processor corresponding to the application program at each working frequency, the highest processor operating frequency required by the application is selected, which includes: The running time of the current maximum operating frequency of the device is compared with the corresponding threshold set. If the running time of the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the application requirement. The highest processor operating frequency is required, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application. Preferably, the highest processor operating frequency required by the application is used as an upper operating frequency limit that can be achieved by the application runtime processor, and specifically includes: setting a maximum processor operating frequency required by the application to the operation The system kernel, by the operating system kernel, limits the maximum frequency of automatic frequency conversion when the application is running cannot exceed the maximum processor operating frequency required by the application.
本发明实施例还提供一种处理器工作频率的控制装置, 包括: 频率控制模块, 设置为在前台启动应用程序时, 基于以往所述应用程序对应的处 理器在各工作频率上的运行时长, 选择出所述应用程序需要的最高处理器工作频率, 并将其作为本次应用程序运行时处理器所能达到的工作频率上限。 优选地, 所述装置还包括: 时长统计模块, 设置为统计该应用程序每次在前台运行的时间段内处理器在各工 作频率上的运行时长, 对本次启动应用程序之前所述处理器在各工作频率上的运行时 长做统计平均, 将统计平均的结果作为以往所述应用程序对应的处理器在各工作频率 上的运行时长。 优选地, 所述时长统计模块, 具体设置为- 当应用程序在前台启动的同时, 记录下处理器在各工作频率上的运行时间值 το, 当应用程序退出前台的同时, 记录下处理器在各工作频率上的运行时间值 Tl, 则该应 用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0。 优选地, 作为一种可选的技术方案, 所述频率控制模块, 具体设置为: 以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值进行比 较, 一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所 述应用程序需要的最高处理器工作频率, 停止继续比较。 优选地, 作为一种优选的技术方案, 所述频率控制模块, 具体设置为: 以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值进行比 较, 若出现下面两个情况之一, 则停止继续比较: 第一个情况: 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该 工作频率作为所述应用程序需要的最高处理器工作频率; 第二个情况: 若比较过的工作频率上的运行时长总和达到设定的总时长阈值, 则 取比较过的工作频率中的最小者作为所述应用程序需要的最高工作频率值。进一步的, 作为一种可选的技术方案, 所述频率控制模块, 具体设置为: 将处理器的当前最高工作频率上的运行时长与设定的相应阈值进行比较, 若该工 作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所述应用程序需 要的最高处理器工作频率, 否则选择处理器的次高工作频率作为所述应用程序需要的 最高处理器工作频率。 优选地, 所述频率控制模块, 具体设置为- 将所述应用程序需要的最高处理器工作频率设置到操作系统内核, 由操作系统内 核在所述应用程序运行时, 限制自动变频的最高频率不能超过所述应用程序需要的最 高处理器工作频率。 采用上述技术方案, 本发明实施例至少具有下列优点: 本发明实施例所述处理器工作频率的控制方法及装置, 统计学习每个应用程序在 前台运行时需要的处理器性能, 然后当这个应用程序在前台运行时就把处理器动态调 频范围限制在合适的范围, 这样既保证了应用程序的性能, 又能最大限度地节能。 附图说明 图 1 为本发明第一实施例的处理器工作频率的控制方法流程图; 图 2 为本发明第二实施例的处理器工作频率的控制装置组成示意图; 图 3 为本发明应用实例一的基于应用程序运行统计对 CPU工作频率进行控制的 方法流程图。 具体实施方式 为更进一步阐述本发明为达成预定目的所采取的技术手段及功效, 以下结合附图 及较佳实施例, 对本发明进行详细说明如后。 本发明第一实施例, 一种处理器工作频率的控制方法, 如图 1所示, 包括以下具 体步骤: 步骤 S101,统计该应用程序每次在前台运行的时间段内处理器在各工作频率上的 运行时长。 具体的, 应用程序在前台运行时, 处理器在各工作频率上的运行时间值均是以时 间片累计的方式更新的。 当该应用程序在前台启动的同时, 记录下处理器在各工作频 率上的运行时间值 το, 当该应用程序退出前台的同时, 记录下处理器在各工作频率上 的运行时间值 τι, 则该应用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0, 本领域技术人员应当理解, TO和 T1均为包括多个工作频率上运行时 间值的向量, 而 deltaT为各工作频率上的运行时间值对应相减得到的一个新的向量。 本发明实施例只统计应用程序在前台运行时的处理器使用情况, 因为通常应用程序在 后台运行时, 不需与用户进行触控交互, 对处理器工作频率的突发需求较少, 基本不 能反映出应用程序与用户交互时的性能, 所以为了满足用户即时的使用体验, 本发明 实施例只关注在前台与用户有触控交互时的应用程序。 处理器的工作频率的个数以及各工作频率的数值与具体处理器的型号有关, 因此 本发明实施例对此不作限定。 步骤 S102, 当本次在前台启动应用程序时, 对本次启动应用程序之前所述处理器 在各工作频率上的运行时长做统计平均, 将统计平均的结果作为以往所述应用程序对 应的处理器在各工作频率上的运行时长。 具体的,以往所述应用程序对应的处理器在各工作频率上的运行时长的获取过程, 包括: 基于步骤 S102 统计的该应用程序每次在前台运行时处理器在各工作频率上的运 行时长, 对本次启动应用程序之前设定次数的所述处理器在各工作频率上的运行时长 做统计平均, 比如: 针对每一个工作频率, 对各次的运行时长取平均值或者做加权平 均, 将统计平均的结果作为以往所述应用程序对应的处理器在各工作频率上的运行时 长。 本实施例中, 之所以只对本次启动应用程序之前设定次数的所述处理器在各工作 频率上的运行时长做统计平均, 而不是对本次启动应用程序之前所有的所述处理器在 各工作频率上的运行时长做统计平均, 一方面是出于节省系统存储空间的考虑, 此时 需要对超过设定次数的统计数据进行老化, 另一方面是由于对近期应用程序运行时 CPU的使用情况进行统计, 更贴近于用户目前对该应用程序的使用需求。 步骤 S103, 基于以往所述应用程序对应的处理器在各工作频率上的运行时长, 选 择出所述应用程序需要的最高处理器工作频率, 并将其作为本次应用程序运行时处理 器所能达到的工作频率上限。 优选的,在步骤 S103中,基于以往所述应用程序对应的处理器在各工作频率上的 运行时长, 选择出所述应用程序需要的最高处理器工作频率, 具体包括: 按照工作频率从高到低的顺序, 依次将各工作频率上的运行时长与设定的相应阈 值进行比较, 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工作 频率作为所述应用程序需要的最高处理器工作频率, 停止继续比较; 优选的, 若比较 过的工作频率上的运行时长总和达到设定的总时长阈值, 则取比较过的工作频率中的 最小者作为所述应用程序需要的最高工作频率值, 停止继续比较, 以避免限频过低导 致系统响应变慢。 可选的,在步骤 S103中,也可以采用如下简便的方式来确定出所述应用程序需要 的最高处理器工作频率, 具体过程包括: 将处理器的当前最高工作频率上的运行时长与设定的阈值进行比较, 若该工作频 率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所述应用程序需要的 最高处理器工作频率, 否则选择处理器的次高工作频率作为所述应用程序需要的最高 处理器工作频率。 在步骤 S103中,将所述应用程序需要的最高处理器工作频率作为本次应用程序运 行时处理器所能达到的工作频率上限, 具体包括: 将所述应用程序需要的最高处理器工作频率设置到操作系统内核, 由操作系统内 核在所述应用程序运行时, 限制自动变频的最高频率不能超过所述应用程序需要的最 高处理器工作频率。 The embodiment of the present invention further provides a processor operating frequency control device, including: a frequency control module, configured to: when the application is started in the foreground, based on the running time of the processor corresponding to the application program at each working frequency, Select the highest processor operating frequency required by the application and use it as the upper operating frequency limit that the processor can achieve at this application runtime. Preferably, the device further includes: a duration statistics module, configured to count a running time of the processor on each working frequency in a time period during which the application runs in the foreground, the processor before starting the application The running time on each working frequency is statistically averaged, and the statistical average result is used as the running time of the processor corresponding to the application in each working frequency. Preferably, the duration statistics module is specifically configured to: when the application is started in the foreground, record the running time value το of the processor on each working frequency, and when the application exits the foreground, the processor is recorded. The running time value T1 at each operating frequency, the running time of the processor at each operating frequency of the application is deltaT=Tl-T0. Preferably, as an optional technical solution, the frequency control module is specifically configured to: compare the running time on each working frequency with the set corresponding threshold value in turn according to the working frequency from high to low, once a certain If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, and the comparison is stopped. Preferably, as a preferred technical solution, the frequency control module is specifically configured to: In order to compare the running time of each working frequency with the corresponding threshold value, the running time is sequentially compared with the set corresponding threshold. If one of the following two conditions occurs, the comparison is stopped: First case: If a working frequency occurs once If the running time is greater than or equal to the set corresponding threshold, the working frequency is selected as the highest processor operating frequency required by the application; the second case: if the running time of the compared operating frequency reaches the set total The duration threshold takes the smallest of the compared operating frequencies as the highest operating frequency value required by the application. Further, as an optional technical solution, the frequency control module is specifically configured to: compare a running time of the current highest operating frequency of the processor with a set corresponding threshold, and if the working frequency is running If it is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application. Preferably, the frequency control module is specifically configured to: set a maximum processor operating frequency required by the application to an operating system kernel, and the operating system kernel limits the maximum frequency of automatic frequency conversion when the application program is running. Exceeding the maximum processor operating frequency required by the application. With the above technical solution, the embodiment of the present invention has at least the following advantages: The method and device for controlling the operating frequency of the processor according to the embodiment of the present invention, statistically learning the processor performance required when each application runs in the foreground, and then when the application When the program is running in the foreground, the processor's dynamic frequency modulation range is limited to the appropriate range, which ensures the performance of the application and maximizes energy saving. BRIEF DESCRIPTION OF DRAWINGS FIG. 1 is a flowchart of a method for controlling a working frequency of a processor according to a first embodiment of the present invention; FIG. 2 is a schematic diagram of a composition of a processor for operating frequency of a processor according to a second embodiment of the present invention; A flow chart of a method for controlling CPU operating frequency based on application running statistics. DETAILED DESCRIPTION OF THE INVENTION The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments. A first embodiment of the present invention, a method for controlling a working frequency of a processor, as shown in FIG. 1, includes the following specific steps: Step S101, counting the operating time of the processor at each working frequency in a period of time during which the application runs in the foreground The length of the run on. Specifically, when the application is running in the foreground, the running time values of the processor at each working frequency are updated in a time slice cumulative manner. When the application is started in the foreground, the runtime value το of the processor at each working frequency is recorded, and when the application exits the foreground, the running time value τι of the processor at each working frequency is recorded. The running time of the application at each operating frequency of the application is deltaT=Tl-T0, and those skilled in the art should understand that TO and T1 are vectors including running time values at multiple operating frequencies, and deltaT A new vector obtained by subtracting the running time values at each working frequency. The embodiment of the present invention only counts the processor usage of the application when running in the foreground, because usually the application does not need to perform touch interaction with the user when running in the background, and the burst operation requirement of the processor is less, basically cannot The performance of the application when interacting with the user is reflected. Therefore, in order to satisfy the user's instant use experience, the embodiment of the present invention only focuses on the application when the foreground has a touch interaction with the user. The number of operating frequencies of the processor and the value of each operating frequency are related to the model of the specific processor. Therefore, the embodiment of the present invention does not limit this. Step S102, when the application is started in the foreground, statistically average the running time of the processor on each operating frequency before starting the application, and the statistical average result is used as the processing corresponding to the application in the past. The runtime of the device at each operating frequency. Specifically, the process of acquiring the running time of the processor corresponding to the application at each working frequency in the past includes: calculating the running time of the processor on each working frequency each time the application runs in the foreground based on the statistics in step S102 The statistical average of the running time of the processor at each working frequency set by the number of times before starting the application, for example: averaging or weighting the running time of each time for each working frequency, The statistical average result is used as the running time of the processor corresponding to the application in the past at each operating frequency. In this embodiment, the processor is set in each work only for the number of times before the application is started this time. The running time on the frequency is statistically averaged, instead of statistically averaging the running time of all the processors at each working frequency before starting the application, on the one hand, in order to save system storage space, at this time It is necessary to age the statistics that exceed the set number of times. On the other hand, it is due to the statistics of the CPU usage during the recent application running, which is closer to the user's current demand for the application. Step S103, selecting, according to the running time of the processor corresponding to the application program at each operating frequency, the highest processor operating frequency required by the application, and using the processor as the running time of the application. The upper limit of the operating frequency reached. Preferably, in step S103, based on the running time of the processor corresponding to the application program in each working frequency, the highest processor operating frequency required by the application is selected, which specifically includes: according to the operating frequency from high to In a low order, the running time on each working frequency is sequentially compared with the set corresponding threshold. If the running time on a certain operating frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as required by the application. The highest processor operating frequency is used to stop the comparison; preferably, if the total running time on the compared operating frequency reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the application required The highest operating frequency value, stop the comparison, to avoid the system is slow to respond due to the low frequency limit. Optionally, in step S103, the following method may also be used to determine the highest processor operating frequency required by the application, and the specific process includes: setting the running time and setting of the current highest operating frequency of the processor. The threshold is compared. If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the The highest processor operating frequency required by the application. In step S103, the highest processor operating frequency required by the application is used as the upper limit of the operating frequency that the processor can achieve at the time of the application running, and specifically includes: setting the highest processor operating frequency required by the application. To the operating system kernel, the maximum frequency that limits automatic frequency conversion by the operating system kernel while the application is running cannot exceed the maximum processor operating frequency required by the application.
本发明第二实施例, 一种处理器工作频率的控制装置, 如图 2所示, 包括: 1 ) 时长统计模块 100, 设置为统计该应用程序每次在前台运行的时间段内处理器 在各工作频率上的运行时长, 对本次启动应用程序之前设定次数的所述处理器在各工 作频率上的运行时长做统计平均, 比如: 针对每一个工作频率, 对各次的运行时长取 平均值或者做加权平均, 将统计平均的结果作为以往所述应用程序对应的处理器在各 工作频率上的运行时长。 具体的, 时长统计模块 100, 设置为- 当应用程序在前台启动的同时, 记录下处理器在各工作频率上的运行时间值 το, 当应用程序退出前台的同时, 记录下处理器在各工作频率上的运行时间值 Tl, 则该应 用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0。 2)频率控制模块 200, 设置为当本次在前台启动应用程序时, 基于以往所述应用 程序对应的处理器在各工作频率上的运行时长, 选择出所述应用程序需要的最高处理 器工作频率, 并将其作为本次应用程序运行时处理器所能达到的工作频率上限。 优选的, 频率控制模块 200采用如下方式来确定出所述应用程序需要的最高处理 器工作频率: 按照工作频率从高到低的顺序, 依次将各工作频率上的运行时长与设定的相应阈 值进行比较, 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工作 频率作为所述应用程序需要的最高处理器工作频率, 停止继续比较; 优选的, 若比较 过的工作频率上的运行时长总和达到设定的总时长阈值, 则取比较过的工作频率中的 最小者作为所述应用程序需要的最高工作频率值, 停止继续比较, 以避免限频过低导 致系统响应变慢。 或者, 频率控制模块 200也可以采用如下简便的方式来确定出所述应用程序需要 的最高处理器工作频率: 将处理器的当前最高工作频率上的运行时长与设定的阈值进行比较, 若该工作频 率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所述应用程序需要的 最高处理器工作频率, 否则选择处理器的次高工作频率作为所述应用程序需要的最高 处理器工作频率。 接下来, 频率控制模块 200将所述应用程序需要的最高处理器工作频率设置到操 作系统内核, 由操作系统内核在所述应用程序运行时, 限制自动变频的最高频率不能 超过所述应用程序需要的最高处理器工作频率。 基于上述实施例, 介绍两个本发明实施例技术方案的应用实例。 应用实例一 本应用实例提供一种基于应用程序运行统计对 CPU工作频率进行控制的方法,不 失一般性, 以任意的一个应用程序 A为例子来说明, 如图 3所示, 该方法循环执行, 每个循环周期即为应用程序 A从在前台启动到退出前台的时间段, 每个循环周期内的 步骤如下: 步骤 al, 当应用程序 A切换到前台的同时, 获取 CPU在各个工作频率上的运行 时间值 TO; 步骤 a2, 判断应用程序 A的运行统计数据的统计次数是否达到了设定的数值, 如 果是, 则认为统计数据能够反映出应用程序 A与用户正常交互时的 CPU性能, 转步 骤 a6; 否则认为不能反映出应用程序 A与用户正常交互时的 CPU性能, 此时转步骤 a3; 步骤 a3, 当应用程序 A被切换到后台的同时, 获取 CPU在各个运行频率上的运 行时间值 T1 ; 步骤 a4, 用 T1减去 TO获得的值为 deltaT, 这个值就是应用程序 A在本次运行时 间段内对 CPU的使用情况; 步骤 a5,将步骤 a4获得的 deltaT值记录在应用程序 A的数据结构中,转步骤 a8; 步骤 a6, 对应用程序 A的运行统计数据进行统计平均处理, 再根据统计平均处理 的结果确定出应用程序 A可以使用的最高 CPU工作频率 f; 步骤 a7,把步骤 a6中确定出的 f设置到操作系统内核, 从而操作系统内核在自动 变频时, 限制最高变频值不能超过 f, 转步骤 a3; 步骤 a8, 流程结束。 应用实例二 本应用实例介绍一个在 Android手机上实现的频率控制过程。 在 Android系统中,A second embodiment of the present invention, a processor operating frequency control device, as shown in FIG. 2, includes: 1) The duration statistics module 100 is configured to count the running time of the processor on each working frequency in the time period during which the application runs in the foreground, and the processor is set to the number of times before starting the application. The running time on the working frequency is statistically averaged, for example: For each working frequency, the running time of each time is averaged or weighted average, and the statistical average result is used as the processor corresponding to the application in the past. The length of the run on the frequency. Specifically, the duration statistics module 100 is configured to: when the application is started in the foreground, record the running time value το of the processor at each working frequency, and record the processor in each work while the application exits the foreground. The running time value T1 on the frequency, the running time of the processor at each working frequency of the application is deltaT=Tl-T0. 2) The frequency control module 200 is configured to select the highest processor working required by the application when the application is started in the foreground, based on the running time of the processor corresponding to the application in each working frequency. Frequency, and as the upper limit of the operating frequency that the processor can achieve at this application runtime. Preferably, the frequency control module 200 determines the highest processor operating frequency required by the application in the following manner: according to the order of the operating frequency from high to low, sequentially the running time on each working frequency and the corresponding threshold set. For comparison, if the running time of a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, and the comparison is stopped; preferably, if the operating frequency is compared If the sum of the running time reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application, and the comparison is stopped to avoid the system response being too low. slow. Alternatively, the frequency control module 200 can also determine the highest processor operating frequency required by the application in the following convenient manner: comparing the running time of the current working frequency of the processor with the set threshold, if If the running time on the working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, otherwise the second highest operating frequency of the processor is selected as the highest processor required by the application. working frequency. Next, the frequency control module 200 sets the highest processor operating frequency required by the application to the operating system kernel, and the operating system kernel limits the maximum frequency of the automatic frequency conversion to exceed the application requirement when the application program is running. The highest processor operating frequency. Based on the foregoing embodiments, two application examples of the technical solutions of the embodiments of the present invention are introduced. Application Example 1 This application example provides a method for controlling the operating frequency of the CPU based on the running statistics of the application, without loss of generality. An arbitrary application A is taken as an example to illustrate, as shown in FIG. 3, the method is executed cyclically. Each cycle is the time period from the start of the application to the exit of the foreground. The steps in each cycle are as follows: Step a, when the application A switches to the foreground, the CPU is acquired at each working frequency. The running time value TO; Step a2, determining whether the statistical number of running statistics of the application A reaches the set value, and if so, the statistical data is considered to reflect the CPU performance when the application A interacts with the user normally. Go to step a6; otherwise, it is considered that the CPU performance when the application A interacts with the user normally cannot be reflected. At this point, go to step a3; Step a3, when the application A is switched to the background, obtain the CPU running at each running frequency. Time value T1; Step a4, the value obtained by subtracting TO from T1 is deltaT, which is the application A in this running time period. The usage of the CPU; in step a5, the deltaT value obtained in step a4 is recorded in the data structure of the application A, and the process proceeds to step a8; in step a6, the statistical statistics of the running statistics of the application A are statistically processed, and then processed according to the statistical average. The result determines the highest CPU operating frequency f that can be used by the application A; in step a7, the f determined in the step a6 is set to the operating system kernel, so that the operating system kernel limits the maximum conversion value to not exceed f when the automatic frequency conversion is performed. Go to step a3 ; in step a8, the process ends. Application Example 2 This application example introduces a frequency control process implemented on an Android mobile phone. In the Android system,
ActivityManagerService模块负责应用程序界面 Activity的切换。 在 Android系统中的 具体实施流程如下: 步骤 bl, ActivityManagerService模块切换应用程序显示界面 Activity 时, 根据 ActivityRecord信息获得该显示界面所属的应用程序; 步骤 b2, 如果应用程序跟切换前的 Activity所属的应用程序不一样, 说明发生了 前台应用程序的切换, 转步骤 b3, 否则流程结束; 步骤 b3, 根据应用程序名称, 找到系统内部对应的 Uid.Pkg对象 (即应用实例一 中所说的数据结构), 该 Uid.Pkg对象内部记录了对应应用程序的 CPU运行统计数据, 计算前台上一个应用所花费的 CPU时间,并把这个数据值保存在前台上一个应用所对 应的 Uid.Pkg对象; 步骤 b4, 判断记录的 CPU运行统计数据是否达到 3次, 如果是, 说明统计数据 有效, 转步骤 b5, 否则, 转步骤 b6; 步骤 b5, 根据已记录的 3次本应用程序的 CPU运行统计数据, 计算本应用可以 使 用 的 CPU 最 高 工 作 频 率 , 并 把 这 个 频 率 值 写 到 文 件 "/sys/devices/system/cpu/cpuO/cpufreq/scaling_max_freq" Φ , 这样, 操作系统内核就能自 动限制最高运行频率不超过这个频率值; 步骤 b6, 流程结束。 通过具体实施方式的说明, 应当可对本发明为达成预定目的所采取的技术手段及 功效得以更加深入且具体的了解, 然而所附图示仅是提供参考与说明之用, 并非用来 对本发明加以限制。 工业实用性 本发明实施例提供的技术方案可以应用于处理器功耗控制技术领域, 通过统计学 习每个应用程序在前台运行时需要的处理器性能, 然后当这个应用程序在前台运行时 就把处理器动态调频范围限制在合适的范围, 这样既保证了应用程序的性能, 又能最 大限度地节能。 The ActivityManagerService module is responsible for switching the application interface Activity. The specific implementation process in the Android system is as follows: Step bl, when the ActivityManagerService module switches the application display interface Activity, according to the ActivityRecord information, the application program to which the display interface belongs is obtained; Step b2, if the application is different from the application to which the Activity before the switch belongs, indicating that the foreground application has occurred. Switching, go to step b3, otherwise the process ends; Step b3, according to the application name, find the corresponding Uid.Pkg object inside the system (that is, the data structure mentioned in the application instance 1), the Uid.Pkg object internally records the corresponding application The CPU of the program runs statistical data, calculates the CPU time spent on an application in the foreground, and saves the data value in the Uid.Pkg object corresponding to an application in the foreground; Step b4, determines whether the recorded CPU running statistics reaches 3 If yes, indicating that the statistics are valid, go to step b5, otherwise, go to step b6 ; step b5, calculate the maximum CPU operating frequency that can be used by the application based on the recorded CPU running statistics of the application 3 times, and Write this frequency value to the file "/sys/devices/syste m/cpu/cpuO/cpufreq/scaling_max_freq" Φ , in this way, the operating system kernel can automatically limit the maximum operating frequency to not exceed this frequency value; Step b6, the process ends. The technical means and functions of the present invention for achieving the intended purpose can be more deeply and specifically understood by the description of the specific embodiments. However, the accompanying drawings are only for the purpose of illustration and description, and are not intended to limit. Industrial Applicability The technical solution provided by the embodiments of the present invention can be applied to the technical field of processor power consumption control, and learns the processor performance required when each application runs in the foreground by statistics, and then when the application is running in the foreground, The processor's dynamic frequency range is limited to the right range, which guarantees the performance of the application while maximizing energy savings.

Claims

权 利 要 求 书 、 一种处理器工作频率的控制方法, 包括:  Claims, a method of controlling the operating frequency of a processor, including:
在前台启动应用程序时, 基于以往所述应用程序对应的处理器在各工作频 率上的运行时长, 选择出所述应用程序需要的最高处理器工作频率, 并将其作 为本次应用程序运行时处理器所能达到的工作频率上限。 、 根据权利要求 1所述的处理器工作频率的控制方法, 其中, 以往所述应用程序 对应的处理器在各工作频率上的运行时长的获取过程, 包括:  When the application is started in the foreground, based on the running time of the processor corresponding to the application in each working frequency, the highest processor operating frequency required by the application is selected and used as the running time of the application. The upper limit of the operating frequency that the processor can achieve. The method for controlling the operating frequency of the processor according to claim 1, wherein the process of acquiring the running time of the processor corresponding to the application at each working frequency in the past includes:
统计该应用程序每次在前台运行的时间段内处理器在各工作频率上的运行 时长;  Counting the running time of the processor at each working frequency during the time period during which the application runs in the foreground;
对本次启动应用程序之前所述处理器在各工作频率上的运行时长做统计平 均, 将统计平均的结果作为以往所述应用程序对应的处理器在各工作频率上的 运行时长。 、 根据权利要求 2所述的处理器工作频率的控制方法, 其中, 所述统计该应用程 序每次在前台运行的时间段内处理器在各工作频率上的运行时长, 具体包括: 当应用程序在前台启动的同时, 记录下处理器在各工作频率上的运行时间 值 T0, 当应用程序退出前台的同时, 记录下处理器在各工作频率上的运行时间 值 Tl, 则该应用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0。 、 根据权利要求 1所述的处理器工作频率的控制方法, 其中, 基于以往所述应用 程序对应的处理器在各工作频率上的运行时长, 选择出所述应用程序需要的最 高处理器工作频率, 具体包括:  The running time of the processor at each operating frequency is statistically averaged before the application is started, and the statistical average result is used as the running time of the processor corresponding to the application in each working frequency. The method for controlling the operating frequency of the processor according to claim 2, wherein the counting the running time of the processor on each working frequency in the time period during which the application runs in the foreground includes: While the foreground is started, record the running time value T0 of the processor at each working frequency. When the application exits the foreground, record the running time value Tl of the processor at each operating frequency, then the application is this time. The runtime of the runtime processor at each operating frequency is deltaT=Tl-T0. The processor operating frequency control method according to claim 1, wherein the highest processor operating frequency required by the application is selected based on a running time of the processor corresponding to the application program at each working frequency. Specifically, including:
以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值 进行比较, 一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工 作频率作为所述应用程序需要的最高处理器工作频率, 停止继续比较; 或者,  The working frequency is sequentially compared with the set corresponding threshold value according to the working frequency from high to low. Once the operating time on a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the application. The maximum processor operating frequency required by the program, stop continuing to compare; or,
以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值 进行比较, 若出现下面两个情况之一, 则停止继续比较: 第一个情况: 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则 选择该工作频率作为所述应用程序需要的最高处理器工作频率; In order to compare the operating time of each operating frequency with the corresponding threshold set in the operating frequency from high to low, if one of the following two conditions occurs, the comparison is stopped: The first case: if the running time of a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application;
第二个情况: 若比较过的工作频率上的运行时长总和达到设定的总时长阈 值, 则取比较过的工作频率中的最小者作为所述应用程序需要的最高工作频率 值;  The second case: if the sum of the running time on the compared operating frequency reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application;
或者,  Or,
将处理器的当前最高工作频率上的运行时长与设定的相应阈值进行比较, 若该工作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所 述应用程序需要的最高处理器工作频率, 否则选择处理器的次高工作频率作为 所述应用程序需要的最高处理器工作频率。 、 根据权利要求 1~4中任一项所述的处理器工作频率的控制方法, 其中, 将所述 应用程序需要的最高处理器工作频率作为本次应用程序运行时处理器所能达到 的工作频率上限, 具体包括: 将所述应用程序需要的最高处理器工作频率设置到操作系统内核, 由操作 系统内核在所述应用程序运行时, 限制自动变频的最高频率不能超过所述应用 程序需要的最高处理器工作频率。 、 一种处理器工作频率的控制装置, 包括:  Comparing the running time of the current working frequency of the processor with the set corresponding threshold, if the running time on the working frequency is greater than or equal to the set corresponding threshold, selecting the working frequency as the highest processing required by the application The operating frequency of the processor, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application. The processor operating frequency control method according to any one of claims 1 to 4, wherein the highest processor operating frequency required by the application is used as a work that the processor can achieve at the time of the application running. The upper limit of the frequency includes: setting the highest processor operating frequency required by the application to the operating system kernel, and the operating system kernel limits the maximum frequency of the automatic frequency conversion to be less than that required by the application program when the application program is running. Maximum processor operating frequency. A control device for operating a processor frequency, comprising:
频率控制模块, 设置为在前台启动应用程序时, 基于以往所述应用程序对 应的处理器在各工作频率上的运行时长, 选择出所述应用程序需要的最高处理 器工作频率,并将其作为本次应用程序运行时处理器所能达到的工作频率上限。 、 根据权利要求 6所述的处理器工作频率的控制装置, 其中, 所述装置还包括: 时长统计模块, 设置为统计该应用程序每次在前台运行的时间段内处理器 在各工作频率上的运行时长, 对本次启动应用程序之前所述处理器在各工作频 率上的运行时长做统计平均, 将统计平均的结果作为以往所述应用程序对应的 处理器在各工作频率上的运行时长。 、 根据权利要求 7所述的处理器工作频率的控制装置,其中,所述时长统计模块, 具体设置为- 当应用程序在前台启动的同时, 记录下处理器在各工作频率上的运行时间 值 T0, 当应用程序退出前台的同时, 记录下处理器在各工作频率上的运行时间 值 Tl, 则该应用程序本次运行时处理器在各工作频率上的运行时长为 deltaT=Tl-T0。 、 根据权利要求 6所述的处理器工作频率的控制装置,其中,所述频率控制模块, 具体设置为- 以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值 进行比较, 一旦某工作频率上运行时长大于等于设定的相应阈值, 则选择该工 作频率作为所述应用程序需要的最高处理器工作频率, 停止继续比较; 或者, The frequency control module is configured to, when the application is started in the foreground, select the maximum processor operating frequency required by the application based on the running time of the processor corresponding to the application in each working frequency, and use The upper limit of the operating frequency that the processor can achieve when the application is running. The apparatus for controlling the operating frequency of the processor according to claim 6, wherein the apparatus further comprises: a duration counting module, configured to count the processor at each operating frequency during each time period in which the application runs in the foreground The running time of the processor is statistically averaged for the running time of the processor at each working frequency before starting the application, and the statistical average result is used as the running time of the processor corresponding to the application in each working frequency. . The apparatus for controlling the operating frequency of the processor according to claim 7, wherein the duration counting module is specifically configured to: when the application is started in the foreground, record the running time value of the processor at each working frequency T0, when the application exits the foreground, record the running time of the processor at each working frequency The value T1, the running time of the processor at each operating frequency of the application is deltaT=Tl-T0. The apparatus for controlling the operating frequency of the processor according to claim 6, wherein the frequency control module is specifically configured to - in accordance with the operating frequency from high to low, sequentially corresponding to the running time of each working frequency and the setting The threshold is compared, and if the running time on a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application, and the comparison is stopped; or
以工作频率从高到低, 依次将各工作频率上的运行时长与设定的相应阈值 进行比较, 若出现下面两个情况之一, 则停止继续比较:  In order to compare the running time of each working frequency with the corresponding threshold set in order from the high to low operating frequency, if one of the following two conditions occurs, the comparison is stopped:
第一个情况: 若一旦某工作频率上运行时长大于等于设定的相应阈值, 则 选择该工作频率作为所述应用程序需要的最高处理器工作频率;  The first case: if the running time on a working frequency is greater than or equal to the set corresponding threshold, the operating frequency is selected as the highest processor operating frequency required by the application;
第二个情况: 若比较过的工作频率上的运行时长总和达到设定的总时长阈 值, 则取比较过的工作频率中的最小者作为所述应用程序需要的最高工作频率 值;  The second case: if the sum of the running time on the compared operating frequency reaches the set total duration threshold, the smallest of the compared operating frequencies is taken as the highest operating frequency value required by the application;
或者,  Or,
所述频率控制模块, 具体设置为:  The frequency control module is specifically configured as:
将处理器的当前最高工作频率上的运行时长与设定的相应阈值进行比较, 若该工作频率上运行时长大于等于设定的相应阈值, 则选择该工作频率作为所 述应用程序需要的最高处理器工作频率, 否则选择处理器的次高工作频率作为 所述应用程序需要的最高处理器工作频率。 、 根据权利要求 6~9中任一项所述的处理器工作频率的控制装置, 其中, 所述频 率控制模块, 具体设置为:  Comparing the running time of the current working frequency of the processor with the set corresponding threshold, if the running time on the working frequency is greater than or equal to the set corresponding threshold, selecting the working frequency as the highest processing required by the application The operating frequency of the processor, otherwise the second highest operating frequency of the processor is selected as the highest processor operating frequency required by the application. The apparatus for controlling the operating frequency of the processor according to any one of claims 6 to 9, wherein the frequency control module is specifically configured to:
将所述应用程序需要的最高处理器工作频率设置到操作系统内核, 由操作 系统内核在所述应用程序运行时, 限制自动变频的最高频率不能超过所述应用 程序需要的最高处理器工作频率。  The highest processor operating frequency required by the application is set to the operating system kernel, and the operating system kernel, when the application is running, limits the maximum frequency of automatic frequency conversion to no more than the highest processor operating frequency required by the application.
PCT/CN2014/073405 2013-08-23 2014-03-13 Processor operating frequency control method and device WO2014135129A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310373208.3 2013-08-23
CN201310373208.3A CN104424031B (en) 2013-08-23 2013-08-23 Method and device for controlling working frequency of processor

Publications (1)

Publication Number Publication Date
WO2014135129A1 true WO2014135129A1 (en) 2014-09-12

Family

ID=51490648

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/073405 WO2014135129A1 (en) 2013-08-23 2014-03-13 Processor operating frequency control method and device

Country Status (2)

Country Link
CN (1) CN104424031B (en)
WO (1) WO2014135129A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017128664A1 (en) * 2016-01-29 2017-08-03 北京小米移动软件有限公司 Method and device for calling process
CN108541054A (en) * 2018-07-16 2018-09-14 深圳市本牛科技有限责任公司 Keeping method, computer equipment and the storage medium of terminal low-power consumption

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794005A (en) * 2015-03-23 2015-07-22 北京畅游天下网络技术有限公司 Method and device for optimizing CPU running frequencies
CN106155733B (en) * 2015-04-23 2020-07-17 腾讯科技(深圳)有限公司 Method and device for running application program
CN106200707B (en) * 2015-05-08 2017-12-26 展讯通信(上海)有限公司 The temprature control method and device of a kind of electronic equipment
CN106569574A (en) * 2015-10-10 2017-04-19 中兴通讯股份有限公司 Frequency management method and device for multicore CPU (Central Processing Unit)
CN105867582A (en) * 2015-12-31 2016-08-17 乐视移动智能信息技术(北京)有限公司 Frequency modulation parameter adjustment method and apparatus, frequency modulator, and mobile terminal
CN105975050A (en) * 2016-05-24 2016-09-28 青岛海信移动通信技术股份有限公司 Terminal power consumption control method and device
CN106055070B (en) * 2016-05-24 2019-08-09 青岛海信移动通信技术股份有限公司 Terminal power consumption control method and device
CN106249844A (en) * 2016-07-29 2016-12-21 宇龙计算机通信科技(深圳)有限公司 Processor working frequency and/or the work method of adjustment of check figure, device and terminal
CN109117262B (en) * 2017-06-22 2022-01-11 深圳市中兴微电子技术有限公司 Baseband processing chip CPU dynamic frequency modulation method and wireless terminal
CN109298774B (en) * 2018-09-30 2022-05-31 联想(北京)有限公司 Adjusting method and device
CN109739642B (en) * 2018-12-18 2023-08-11 努比亚技术有限公司 CPU frequency modulation method and device, mobile terminal and computer readable storage medium
CN109739641B (en) * 2018-12-18 2023-08-11 努比亚技术有限公司 Self-adaptive CPU frequency modulation acceleration method and device, mobile terminal and storage medium
CN109886542B (en) * 2019-01-15 2021-11-02 新奥数能科技有限公司 Equipment alternate rest recommendation method and device, readable medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210740A1 (en) * 2008-02-14 2009-08-20 Song Huang Off-chip access workload characterization methodology for optimizing computing efficiency
CN101699368A (en) * 2009-11-02 2010-04-28 中兴通讯股份有限公司 Method and device for adaptive dynamic frequency or voltage adjustment of CPU
CN102129392A (en) * 2010-01-18 2011-07-20 扬智科技股份有限公司 Method for adaptive frequency regulation and electronic device related thereto
US20120284546A1 (en) * 2005-07-14 2012-11-08 Nytell Software LLC Using historic load profiles to dynamically adjust operating frequency and available power to a handheld multimedia device processor core
CN103019367A (en) * 2012-12-03 2013-04-03 福州瑞芯微电子有限公司 Embedded type GPU (Graphic Processing Unit) dynamic frequency modulating method and device based on Android system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1622044A (en) * 2003-11-24 2005-06-01 顺德市顺达电脑厂有限公司 Method of adjusting processor frequency for portable digital devices
US7594128B2 (en) * 2004-08-04 2009-09-22 Hewlett-Packard Development Company, L.P. Systems and methods to determine processor utilization
CN100371859C (en) * 2005-06-23 2008-02-27 英特维数位科技股份有限公司 Method for regulating processor working frequency during video data playing
CN101216727A (en) * 2008-01-16 2008-07-09 浙江大学 Embedded type low-power consumption operating system dynamic frequency regulation mapping method
CN101477398A (en) * 2008-12-25 2009-07-08 深圳华为通信技术有限公司 Terminal power consumption control method and apparatus
CN101770274A (en) * 2008-12-29 2010-07-07 大唐移动通信设备有限公司 Energy-saving digital signal processor system, device and realizing method thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120284546A1 (en) * 2005-07-14 2012-11-08 Nytell Software LLC Using historic load profiles to dynamically adjust operating frequency and available power to a handheld multimedia device processor core
US20090210740A1 (en) * 2008-02-14 2009-08-20 Song Huang Off-chip access workload characterization methodology for optimizing computing efficiency
CN101699368A (en) * 2009-11-02 2010-04-28 中兴通讯股份有限公司 Method and device for adaptive dynamic frequency or voltage adjustment of CPU
CN102129392A (en) * 2010-01-18 2011-07-20 扬智科技股份有限公司 Method for adaptive frequency regulation and electronic device related thereto
CN103019367A (en) * 2012-12-03 2013-04-03 福州瑞芯微电子有限公司 Embedded type GPU (Graphic Processing Unit) dynamic frequency modulating method and device based on Android system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017128664A1 (en) * 2016-01-29 2017-08-03 北京小米移动软件有限公司 Method and device for calling process
CN108541054A (en) * 2018-07-16 2018-09-14 深圳市本牛科技有限责任公司 Keeping method, computer equipment and the storage medium of terminal low-power consumption
CN108541054B (en) * 2018-07-16 2020-12-18 深圳市本牛科技有限责任公司 Terminal low power consumption keeping method, computer equipment and storage medium

Also Published As

Publication number Publication date
CN104424031A (en) 2015-03-18
CN104424031B (en) 2021-01-26

Similar Documents

Publication Publication Date Title
WO2014135129A1 (en) Processor operating frequency control method and device
US9176572B2 (en) System and method for controlling central processing unit power with guaranteed transient deadlines
US9104411B2 (en) System and method for controlling central processing unit power with guaranteed transient deadlines
CN107209546B (en) Suppression of power spikes
US10929179B2 (en) Scheduling method and electronic device
KR101659705B1 (en) System and method for controlling central processing unit power with guaranteed transient deadlines
KR101618939B1 (en) System and method for controlling central processing unit power with guaranteed transient deadlines
US8775838B2 (en) Limiting the number of unexpected wakeups in a computer system implementing a power-saving preemptive wakeup method from historical data
US20160077571A1 (en) Heuristic Processor Power Management in Operating Systems
JP2017517812A (en) Virtual machine power management
CN104391554A (en) Method for adjusting terminal temperature
JP5696603B2 (en) Computer system, power control method and program for computer system
US20220393960A1 (en) Technologies for performance monitoring and management with empty polling
JP2013530465A (en) Dynamic voltage dithering
KR101578336B1 (en) System and method for controlling central processing unit power with guaranteed transient deadlines
JP6211622B2 (en) Channel-aware job scheduling
CN104317611A (en) Application rousing setting device and method and mobile terminal
CN110795323A (en) Load statistical method, device, storage medium and electronic equipment
CN110673958B (en) Frequency modulation method, frequency modulation device, storage medium and electronic equipment
CN110647401B (en) Frequency modulation method, frequency modulation device, storage medium and electronic equipment
Mendis et al. Impact of memory frequency scaling on user-centric smartphone workloads
JP6341066B2 (en) Timer control program, timer control method, and information processing apparatus
JP2014239401A (en) Portable terminal device and frequency control method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14760516

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14760516

Country of ref document: EP

Kind code of ref document: A1