WO2023142906A1 - 一种功耗控制方法及装置 - Google Patents

一种功耗控制方法及装置 Download PDF

Info

Publication number
WO2023142906A1
WO2023142906A1 PCT/CN2023/070110 CN2023070110W WO2023142906A1 WO 2023142906 A1 WO2023142906 A1 WO 2023142906A1 CN 2023070110 W CN2023070110 W CN 2023070110W WO 2023142906 A1 WO2023142906 A1 WO 2023142906A1
Authority
WO
WIPO (PCT)
Prior art keywords
processor
cpu
electronic device
application
load
Prior art date
Application number
PCT/CN2023/070110
Other languages
English (en)
French (fr)
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 荣耀终端有限公司
Priority to EP23745791.6A priority Critical patent/EP4280060A1/en
Priority to US18/548,037 priority patent/US20240236863A9/en
Publication of WO2023142906A1 publication Critical patent/WO2023142906A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • G06F9/4893Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues taking into account power or heat criteria
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5094Allocation of resources, e.g. of the central processing unit [CPU] where the allocation takes into account power or heat criteria
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/725Cordless telephones
    • H04M1/73Battery saving arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0261Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level
    • H04W52/0264Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by selectively disabling software applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0261Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level
    • H04W52/0274Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by switching on or off the equipment or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5022Workload threshold
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0261Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level
    • H04W52/0274Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by switching on or off the equipment or parts thereof
    • H04W52/0277Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by switching on or off the equipment or parts thereof according to available power supply, e.g. switching off when a low battery condition is detected
    • 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 application relates to the field of terminal technologies, and in particular to a power consumption control method and device.
  • Embodiments of the present application provide a power consumption control method and device, which can reduce processor resources occupied by abnormally high-load processes, reduce processor power consumption, and improve processor performance.
  • a power consumption control method is provided, which is applied to an electronic device.
  • the electronic device includes a processor, a first process runs on the processor, and a first application corresponding to the first process runs in the background of the electronic device.
  • the method includes : If it is detected that the load of the first process is higher than the preset load threshold and the running time is greater than or equal to the preset duration threshold, and it is determined that the running of the first application is not perceived by the user, reduce the processor usage of the first process.
  • the load of the first process is higher than the preset load threshold and the running duration is greater than or equal to the preset duration threshold, indicating that the first process is a high-load process.
  • the running of the first application is not perceived by the user, which means that the first process abnormally occupies processor resources in the background.
  • the processor utilization rate of the first process is reduced; that is, the occupation of the processor resource by the first process is reduced, and the processor resource is released; the processor resource can be used for other processes , reduce processor load, thus reducing processor power consumption and improving processor performance.
  • the method for reducing the processor usage rate of the first process provided by the embodiment of the present application can reduce the probability of accidentally killing the background process and avoid causing system abnormality.
  • the condition for reducing the processor usage of the first process further includes: determining that the electronic device meets a preset abnormal condition; wherein the abnormal condition includes at least one of the following: the electronic device The processor temperature of the electronic device is greater than the preset temperature threshold; the battery power of the electronic device drops by more than the preset power threshold within a preset period of time; the foreground application running on the electronic device freezes.
  • the first process is an abnormally high-load background process.
  • reducing the processor usage rate of the first process includes: controlling the first process to sleep periodically; when the first process sleeps, the first process does not use processor resources, That is, the processor usage rate of the first process is reduced.
  • each sleep period includes running time and sleep time of the first process; during the running time of the first process, the first process uses processor resources according to the scheduling of the processor. In this way, the first process can use the processor resource within the duration allocated to it by the processor.
  • the sum of the length of running time and the length of sleep time is the sleep period.
  • the sleep time of the first process in each sleep cycle is equal, and the sleep time is a preset value.
  • the sleep time in the current sleep cycle is determined according to the current load of the processor and the preset target load.
  • reducing the processor usage of the first process includes: reducing the scheduling priority of the first process, and the scheduling priority is used to indicate the order in which the processes are allocated processor resources by the processor . In this way, the probability that the first process is allocated processor resources is reduced, and the processor usage rate of the first process is reduced.
  • reducing the scheduling priority of the first process includes: increasing the scheduling priority value of the first process.
  • reducing the processor usage of the first process includes: lowering a processor usage threshold of the first process.
  • the fact that the running of the first application is not perceived by the user includes: the first application does not perform audio input or output; and the first application does not receive or send audio through mobile communication or wireless communication. data.
  • the running of the first application in the background of the electronic device includes: the first application does not have a human-computer interaction interface; or, the human-computer interaction interface of the first application stops on the screen of the electronic device on display.
  • an electronic device in a second aspect, has a function of implementing the method described in the first aspect above.
  • This function may be implemented by hardware, or may be implemented by executing corresponding software on the hardware.
  • the hardware or software includes one or more modules corresponding to the above functions.
  • an electronic device including: a processor and a memory; the memory is used to store computer-executable instructions, and when the electronic device is running, the processor executes the computer-executable instructions stored in the memory, so that the The electronic device performs the following steps:
  • the load of the first process is higher than the preset load threshold and the running duration is greater than or equal to the preset duration threshold, indicating that the first process is a high-load process.
  • the running of the first application is not perceived by the user, which means that the first process abnormally occupies processor resources in the background.
  • the processor utilization rate of the first process is reduced; that is, the occupation of the processor resource by the first process is reduced, and the processor resource is released; the processor resource can be used for other processes , reduce processor load, thus reducing processor power consumption and improving processor performance.
  • the method for reducing the processor usage rate of the first process provided by the embodiment of the present application can reduce the probability of accidentally killing the background process and avoid causing system abnormality.
  • the condition for reducing the processor usage rate of the first process further includes: determining that the electronic device meets a preset abnormal condition; wherein the abnormal condition includes at least one of the following: the electronic device The processor temperature of the electronic device is greater than the preset temperature threshold; the battery power of the electronic device drops by more than the preset power threshold within a preset period of time; the foreground application running on the electronic device freezes.
  • the first process is an abnormally high-load background process.
  • reducing the processor usage rate of the first process includes: controlling the first process to sleep periodically; when the first process sleeps, the first process does not use processor resources, That is, the processor usage rate of the first process is reduced.
  • each sleep period includes running time and sleep time of the first process; during the running time of the first process, the first process uses processor resources according to the scheduling of the processor. In this way, the first process can use the processor resource within the duration allocated to it by the processor.
  • the sum of the length of running time and the length of sleep time is the sleep period.
  • the sleep time of the first process in each sleep cycle is equal, and the sleep time is a preset value.
  • the sleep time in the current sleep cycle is determined according to the current load of the processor and the preset target load.
  • reducing the processor usage of the first process includes: reducing the scheduling priority of the first process, and the scheduling priority is used to indicate the order in which the processes are allocated processor resources by the processor . In this way, the probability that the first process is allocated processor resources is reduced, and the processor usage rate of the first process is reduced.
  • reducing the scheduling priority of the first process includes: increasing the scheduling priority value of the first process.
  • reducing the processor usage of the first process includes: lowering a processor usage threshold of the first process.
  • the fact that the running of the first application is not perceived by the user includes: the first application does not perform audio input or output; and the first application does not receive or send audio through mobile communication or wireless communication. data.
  • the running of the first application in the background of the electronic device includes: the first application does not have a human-computer interaction interface; or, the human-computer interaction interface of the first application stops on the screen of the electronic device on display.
  • an electronic device including: a processor; the processor is configured to be coupled with a memory, and after reading the instructions in the memory, execute according to the instructions as described in any one of the above first aspects. power consumption control method.
  • a computer-readable storage medium stores instructions, and when it is run on a computer, the computer can perform the power consumption described in any one of the above-mentioned first aspects. Control Method.
  • a computer program product including instructions, which, when run on a computer, enable the computer to execute the power consumption control method described in any one of the above first aspects.
  • an apparatus for example, the apparatus may be a system on chip
  • the apparatus includes a processor, configured to support an electronic device to implement the functions involved in the above first aspect.
  • the device further includes a memory, and the memory is used for storing necessary program instructions and data of the electronic device.
  • the device When the device is a system-on-a-chip, it may consist of chips, or may include chips and other discrete devices.
  • FIG. 1A is a schematic diagram of a scene where the power consumption control method provided by the embodiment of the present application is applicable;
  • FIG. 1B is a schematic diagram of a scenario where the power consumption control method provided in the embodiment of the present application is applicable;
  • FIG. 2A is a schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present application.
  • FIG. 2B is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application.
  • FIG. 3 is a flowchart of a power consumption control method provided in an embodiment of the present application.
  • FIG. 4A is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 4B is a schematic diagram of a scene example of a power consumption control method provided by an embodiment of the present application.
  • FIG. 5A is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 5B is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 5C is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 5D is a schematic diagram of a scene example of the power consumption control method provided by the embodiment of the present application.
  • FIG. 6 is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 10 is a schematic flowchart of a power consumption control method provided in an embodiment of the present application.
  • FIG. 11 is a schematic diagram of a scene example of a power consumption control method provided in an embodiment of the present application.
  • FIG. 12 is a schematic flowchart of a power consumption control method provided by an embodiment of the present application.
  • FIG. 13A is a schematic diagram of the implementation effect of the power consumption control method provided by the embodiment of the present application.
  • FIG. 13B is a schematic diagram of the implementation effect of the power consumption control method provided by the embodiment of the present application.
  • FIG. 14 is a schematic diagram of a power consumption control device provided by an embodiment of the present application.
  • a and/or B may indicate: A exists alone, A and B exist simultaneously, and B exists alone, Wherein A and B can be singular or plural.
  • the character "/" generally indicates that the contextual objects are an "or" relationship.
  • references to "one embodiment” or “some embodiments” or the like in this specification means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.
  • the terms “including”, “comprising”, “having” and variations thereof mean “including but not limited to”, unless specifically stated otherwise.
  • the term “connected” includes both direct and indirect connections, unless otherwise stated. "First” and “second” are used for descriptive purposes only, and should not be understood as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features.
  • the electronic device there are some application programs (for example, third-party applications or system applications) running in the background.
  • the application program runs in the background, that is, the application program runs on the electronic device, but the human-computer interaction interface of the application program is not displayed on the screen of the electronic device.
  • the user opens a chat application on the electronic device, and a human-computer interaction interface of the chat application is displayed.
  • the chat application the user opens the video application, and the electronic device displays a human-computer interaction interface of the video application.
  • the human-computer interaction interface of the chat application is hidden or closed or completely blocked by the human-computer interaction interface of the video application, and the human-computer interaction interface of the chat application stops being displayed on the screen of the electronic device; that is, the chat application runs in the background.
  • the user opens the music application, starts playing music, and closes the human-computer interaction interface of the music application; the music application continues to play music, that is, the music application runs in the background.
  • the operating system starts some system applications in the background, and these system applications do not have a human-computer interaction interface.
  • background applications Application programs running in the background (referred to as background applications in this application) generally do not occupy a large amount of processor resources; or occupy more processor resources based on user needs (such as fast downloading of large files).
  • the processor resource refers to the computing capability of the processor.
  • applications running in the background can experience unusually high loads. For example, if the instructions executed by the application enter an infinite loop and fail to exit normally, the load will be abnormally high.
  • Application load is a statistic of the sum of the number of processes for that application that the processor is processing and those that are waiting to be processed by the processor over a period of time. Abnormally high loads of background applications may abnormally occupy more processor resources, resulting in high processor loads or even full processor loads.
  • the processor load is the statistical information of the sum of the number of processes being processed by the processor and the number of processes waiting to be processed by the processor within a period of time, that is, the statistical information of the length of the processor usage queue. It can be understood that the lower the processor load, the shorter the process waits to be scheduled by the processor; the higher the processor load, the longer the process waits to be scheduled by the processor. If there is an application running in the foreground (referred to as the foreground application in this application), the abnormally high load of the background application will cause the foreground application to be unable to be scheduled in time, and there will be a freeze (for example, the dynamic picture played by the application is not continuous, and the sound played is intermittent etc.), affecting user experience. In addition, the abnormally high load of background applications will also cause problems such as high power consumption and heating of electronic equipment.
  • the processor described in the embodiment of the present application may include a central processing unit (central processing unit, CPU), a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a digital signal processor (digital signal processor, DSP), or neural network processor (neural-network processing unit, NPU), etc.
  • CPU central processing unit
  • GPU graphics processing unit
  • ISP image signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • FIG. 1A shows a schematic diagram of monitoring the CPU load when there is an abnormally high background application load on the mobile phone.
  • FIG. 1A shows a schematic diagram of monitoring the CPU load when there is an abnormally high background application load on the mobile phone.
  • the user is using the mobile phone normally, and there is a foreground application running on the mobile phone, and the CPU load changes in real time according to the user's usage. Due to the abnormally high load of the background application, it takes up a lot of CPU resources; when the user uses the mobile phone, the foreground application freezes, which affects the user experience. After 1:30, the user does not use the mobile phone, the foreground application does not run on the mobile phone, and only the background application exists on the mobile phone, but the CPU load remains at a high value.
  • the remaining power of the mobile phone is 80%, at 1:30, the remaining power of the mobile phone is 40%, and at 6:00, the remaining power of the mobile phone is close to 0. It can be seen that when the user does not use the mobile phone, the mobile phone consumes 40% of the power within 4 and a half hours between 1:30 and 6:00; the power consumption of background applications is relatively high. Through monitoring, it is found that between 22:45 and 6:00, the total power consumption of the mobile phone is 1583.71 mAh, the power consumption of the foreground application is 3.44mAh, and the power consumption of the background application is 1580.27mAh; it can be seen that the power consumption of the background application The power consumption is much greater than that of the foreground application. The background application consumes a lot of power, the standby time of the mobile phone will be greatly shortened, and it may also generate heat, which will reduce the user experience.
  • FIG. 1B shows a schematic diagram of monitoring the CPU load when there is an abnormally high background application load on another mobile phone.
  • the application 1 on the mobile phone is running in the foreground (referred to as the foreground application 1 in this application), and the CPU load varies with the application 1 load.
  • foreground app 1 stops running.
  • background application 2 in this application has a high load of 98%, and the CPU load remains at a high value.
  • the embodiment of the present application provides a power consumption control method. If it is detected that the background process (the background process is the process of the background application) is abnormally high load, then reduce the length of time the background process uses the CPU to solve the problem of electronic equipment caused by the high load of the background process. There are problems such as freezing during use, rapid power failure, and easy heating.
  • the power consumption control method provided in the embodiment of the present application may be applied to an electronic device including a processor.
  • the aforementioned electronic devices may include mobile phones, tablet computers, notebook computers, personal computers (personal computers, PCs), ultra-mobile personal computers (ultra-mobile personal computers, UMPCs), handheld computers, netbooks, smart home devices (such as smart TVs, Smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (personal digital assistant, PDA), wearable devices (such as smart watches, smart bracelets, etc.), vehicle-mounted devices, virtual reality devices, etc., this application
  • PDA personal digital assistant
  • wearable devices such as smart watches, smart bracelets, etc.
  • vehicle-mounted devices virtual reality devices, etc.
  • FIG. 2A is a schematic structural diagram of an electronic device 100 provided in an embodiment of the present application.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, sensor module 170, camera 180, display screen 190, etc.
  • the sensor module 170 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
  • the illustrated components can be realized in hardware, software or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example: the processor 110 may include a central processing unit (central processing unit, CPU), an application processor (application processor, AP), a modem processor, a graphics processor ( graphics processing unit (GPU), image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network Processor (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input and output
  • subscriber identity module subscriber identity module
  • SIM subscriber identity module
  • USB universal serial bus
  • the charging management module 140 is configured to receive a charging input from a charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 can receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive a wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 is charging the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives the input from the battery 142 and/or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the external memory, the display screen 190 , the camera 180 , and the wireless communication module 160 .
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
  • the power management module 141 may also be disposed in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be set in the same device.
  • the wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the mobile communication module 150 , the wireless communication module 160 , a modem processor, a baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
  • Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
  • the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves and radiate them through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 150 may be set in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be set in the same device.
  • a modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator sends the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low-frequency baseband signal is passed to the application processor after being processed by the baseband processor.
  • the application processor outputs a sound signal through an audio device, or displays an image or video through a display screen 190 .
  • the modem processor may be a stand-alone device. In some other embodiments, the modem processor may be independent from the processor 110, and be set in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wireless Fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite, etc. applied on the electronic device 100.
  • System global navigation satellite system, GNSS
  • frequency modulation frequency modulation, FM
  • near field communication near field communication, NFC
  • infrared infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
  • the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR techniques, etc.
  • GSM global system for mobile communications
  • GPRS general packet radio service
  • code division multiple access code division multiple access
  • CDMA broadband Code division multiple access
  • WCDMA wideband code division multiple access
  • time division code division multiple access time-division code division multiple access
  • TD-SCDMA time-division code division multiple access
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • Beidou navigation satellite system beidou navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 implements a display function through a GPU, a display screen 190 , and an application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 190 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 190 is used for displaying images, videos and the like.
  • the display screen 190 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
  • the electronic device 100 may include 1 or N display screens 190 , where N is a positive integer greater than 1.
  • the electronic device 100 can realize the shooting function through the ISP, the camera 180 , the video codec, the GPU, the display screen 190 and the application processor.
  • the ISP is used for processing the data fed back by the camera 193 .
  • the light is transmitted to the photosensitive element of the camera through the lens, and the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin color.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be located in the camera 193 .
  • Camera 180 is used to capture still images or video.
  • the object generates an optical image through the lens and projects it to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other image signals.
  • the electronic device 100 may include 1 or N cameras 180 , where N is a positive integer greater than 1.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos in various encoding formats, for example: moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG moving picture experts group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be realized through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, so as to expand the storage capacity of the electronic device 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. Such as saving music, video and other files in the external memory card.
  • the internal memory 121 may be used to store computer-executable program codes including instructions.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 .
  • the internal memory 121 may include an area for storing programs and an area for storing data.
  • the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like.
  • the storage data area can store data created during the use of the electronic device 100 (such as audio data, phonebook, etc.) and the like.
  • the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (universal flash storage, UFS) and the like.
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture.
  • the embodiment of the present invention uses a layered architecture as an example to illustrate the software structure of the electronic device 100 .
  • FIG. 2B is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces.
  • the system is divided into four layers, from top to bottom are application program layer, application program framework layer, Android runtime (Android runtime) and system library, and kernel layer.
  • the application layer can consist of a series of application packages.
  • the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • Content providers are used to store and retrieve data and make it accessible to applications.
  • Said data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on.
  • the view system can be used to build applications.
  • a display interface can consist of one or more views.
  • a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide communication functions of the electronic device 100 . For example, the management of call status (including connected, hung up, etc.).
  • the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
  • the notification manager is used to notify the download completion, message reminder, etc.
  • the notification manager can also be a notification that appears on the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window.
  • prompting text information in the status bar issuing a prompt sound, vibrating the electronic device, and flashing the indicator light, etc.
  • the Android Runtime includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
  • a system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
  • the implementation of the power consumption control method provided by the embodiment of the present application may be a processor (the embodiment of the present application uses a CPU as an example), or other processing units (such as chips) in the electronic device, or can communicate with the electronic device
  • An apparatus for controlling a processor in an electronic device through communication, etc., the embodiment of the present application does not limit the execution subject of the method.
  • the power consumption control method provided in this embodiment of the present application may include:
  • a process corresponding to a background application is called a background process.
  • the load of a process is the statistical information of the sum of the number of processes that the processor is processing and waiting for the process to be processed by the processor during a period of time.
  • the preset condition includes: the load is higher than a preset load threshold, and the running duration is greater than or equal to the preset duration threshold.
  • the load is higher than 30% and the runtime is greater than or equal to 5 minutes; for example, the load is higher than 20% and the runtime is greater than or equal to 8 minutes; for example, the load is higher than 10% and the runtime is greater than or equal to 15 minutes; for example, The load is above 5% and the runtime is greater than or equal to 60 minutes.
  • the execution of the application that can be perceived by the user includes: the application performs audio input or output.
  • a music playback application runs in the background and plays music, that is, there is audio output.
  • the call application runs in the background to perform voice input and output.
  • the execution of the application program that can be perceived by the user includes: the application program receives or sends data through mobile communication or wireless communication.
  • the application program receives or sends data through mobile communication or wireless communication.
  • applications such as Thunder Download
  • navigation applications such as AutoNavi Maps and Baidu Maps
  • they upload or download data.
  • sports and health applications obtain user location information through GPS.
  • S304 Determine whether the electronic device satisfies an abnormal condition. If the abnormal condition is satisfied, execute S305; if it is determined that the abnormal condition is not satisfied, execute S301.
  • the abnormal condition includes at least one of the following: the CPU temperature is greater than the preset temperature threshold; the value of the battery power drop within the preset time period is greater than the preset power threshold; the foreground application runs stuck .
  • judging whether the electronic device meets the abnormal condition includes S3041-S3043:
  • S3041. Determine whether the CPU temperature is greater than a preset temperature threshold. If it is determined that the CPU temperature is greater than the preset temperature threshold, it is determined that the electronic device meets the abnormal condition; if it is determined that the CPU temperature is less than or equal to the preset temperature threshold, perform S3042.
  • the electronic device monitors the temperature of the CPU through a temperature sensor.
  • the preset temperature threshold is 40°C. If the temperature sensor detects that the temperature of the CPU is greater than 40° C., it is determined that the electronic device meets the abnormal condition.
  • S3042. Determine whether the value of battery power drop within a preset time period is greater than a preset power threshold. If it is determined that the battery power drop within the preset time period is greater than the preset power threshold, it is determined that the electronic device meets the abnormal condition; if it is determined that the battery power drop within the preset time is less than or equal to the preset power threshold, execute S3043.
  • the preset duration is 10 minutes
  • the preset power threshold is 20%. If it is determined that the battery power drops by more than 20% within a preset time period, it is determined that the electronic device meets the abnormal condition.
  • the preset first frame rate threshold is 20fps.
  • the first frame rate value (for example, 50fps) of the average frame rate of the normal playback of the foreground application is determined by counting historical data on the electronic device. If it is determined that the difference between the second frame rate value played by the application program and the first frame rate value is greater than the preset second frame rate threshold, it is determined that the application program runs stuck. Wherein, the second frame rate value is smaller than the first frame rate value. For example, if the first frame rate value is 80fps, the second frame rate value is 40fps, and the second frame rate threshold value is 30fps, then it is determined that the application is stuck.
  • sequence of performing S302, S303, and S304 is not limited in this embodiment of the present application. In some other implementation manners, S303 or S304 may be performed first.
  • the CPU usage time of a process can be reflected by the CPU usage rate of the process (that is, the processor usage rate).
  • the CPU usage rate of the process is the duration of the CPU resource usage of the process per unit time. Reducing the CPU usage of a process means reducing the duration of the process using CPU resources within a unit duration.
  • the CPU usage rate of a process the sum of the duration of each CPU resource used by the process/the sum of the running duration of each CPU.
  • Method 1 Reduce the CPU usage of the process by reducing the scheduling priority of the abnormally high-load background process.
  • Allocate CPU resources within a time period to processes that is, CPU scheduling processes.
  • the CPU schedules the processes in descending order of the scheduling priorities of the processes.
  • a process with a higher scheduling priority is scheduled by the CPU prior to a process with a lower scheduling priority.
  • processes with the same scheduling priority are scheduled according to the order in which they enter the scheduling queue.
  • the scheduling priority is represented by a scheduling priority value; the larger the scheduling priority value is, the lower the scheduling priority is.
  • the scheduling priority is represented by an integer from -20 to 19, and each number represents a scheduling priority; -20 indicates the highest scheduling priority, and 19 indicates the lowest scheduling priority.
  • the CPU schedules each process in a time slice round-robin manner; the duration of the time slice is a preset value, for example, 20ms.
  • the CPU allocates CPU resources within a time slice to a process, that is, schedules the process within a time slice. When there are multiple processes waiting to use CPU resources, the CPU can allocate time slices to each process in turn.
  • the CPU allocates time slices to the processes in descending order of the scheduling priorities of the processes.
  • the CPU saves the process scheduling queue; the processes waiting for the CPU to process are sorted in the process scheduling queue according to the scheduling priority of the process from high to low; if the scheduling priorities are the same, the processes arrive in the process scheduling queue in the order Sort.
  • the CPU checks the process scheduling queue, and assigns the time slice to the process (process 1) at the head of the process scheduling queue.
  • Process 1 uses CPU resources during this time slice.
  • process 1 stops using CPU resources.
  • Process 1 enters the process scheduling queue again. In this way, a process with a high scheduling priority has a high probability of being scheduled, and the CPU usage rate is high.
  • the probability of the process being scheduled by the CPU is reduced by reducing the scheduling priority of the abnormally high-load background process.
  • the scheduling priority of the process is changed by adjusting the scheduling priority value of the process.
  • the scheduling priority value of the abnormally high-load background process may be increased to decrease the scheduling priority of the abnormally high-load background process.
  • other processes such as foreground processes and non-abnormal background processes
  • are scheduled by the CPU more preferentially than abnormally high-load background processes reducing the probability of the process being allocated CPU resources, thereby reducing the duration of the process using the CPU.
  • the scheduling priority value of process 1 is -20.
  • the CPU allocates 6 time slices to process 1; the CPU usage rate of process 1 is 60%. If process 1 is detected as an abnormally high-load background process, the scheduling priority value of process 1 is changed to 19, and the scheduling priority of process 1 is lowered. The probability that process 1 is at the head of the process scheduling queue is reduced, that is, the probability of being allocated a time slice is reduced.
  • the CPU allocates 3 time slices to process 1; the CPU usage of process 1 drops to 30%.
  • the scheduling priority (NI) of the background process whose process identifier (PID) is 6508 is -20 (the highest scheduling priority), and the probability of the process being called is relatively high, and the process load was 247%.
  • the scheduling priority (NI) of the background process with PID 6508 is changed to 19 (the lowest scheduling priority) through the nice command.
  • the process load of the background process whose process ID (PID) is 6508 drops to 232%. It can be seen that after reducing the scheduling priority of the abnormally high-load background process, the process load of the process is reduced, that is, the running frequency of the process is reduced, thereby reducing the CPU usage of the process.
  • Method 2 Reduce the CPU usage of the process by setting the CPU usage threshold of the abnormally high-load background process.
  • the CPU usage threshold of the process is used to limit the CPU usage of the process (the CPU usage of the process is less than or equal to the CPU usage threshold of the process), that is, the CPU usage time of the process is limited.
  • the CPU usage threshold of the process is set to the first threshold. For example, if it is determined that process 1 is an abnormally high-load background process, set the CPU usage threshold of process 1 to the first threshold, so that in each scheduling cycle, the CPU time allocated to process 1 accounts for less than or is equal to the first threshold, the CPU usage time of the process 1 within a scheduling period is less than or equal to (first threshold*scheduling period), that is, the CPU usage of the process 1 is less than or equal to the first threshold.
  • the value of the first threshold may be set smaller. In this way, the CPU usage time of the abnormally high-load background process in each scheduling cycle is kept in a low range, reducing the CPU usage time of the abnormally high-load background process.
  • the CPU usage threshold of process 1 is the first threshold, and it is determined that the process 1 is an abnormally high-load background process, then the CPU usage threshold of process 1 is set as the second threshold; wherein, the second threshold is less than first threshold. In this way, the CPU usage of the abnormally high-load background process is reduced, that is, the CPU usage time of the abnormally high-load background process in each scheduling cycle is reduced, that is, the CPU usage time of the abnormally high-load background process is reduced.
  • cpu.shares may be used to set the relative weight of CPU time occupied by each process. For example, use cpu.shares to set the relative weight (shares value) of process 1's CPU time to 1024, set the shares value of process 2 to 512, and set the shares value of process 3 to 512.
  • the CPU usage of process 1 does not exceed 50%, that is, the CPU time occupied by process 1 does not exceed 50%*single
  • the CPU usage of process 2 does not exceed 25%, that is, the CPU time occupied by process 2 does not exceed 25% * the total running time of a single CPU
  • the CPU usage of process 3 does not exceed 25%, that is, the CPU occupied by process 3
  • the CPU time does not exceed 25% * the total running time of a single CPU.
  • the processes on the CPU are divided into multiple process groups, and each process group includes one or more processes; for example, process group 1 includes processes of video-type applications, and process group 2 includes processes of navigation-type applications process.
  • process group 1 includes processes of video-type applications
  • process group 2 includes processes of navigation-type applications process.
  • the CPU usage rate of the process may be greater than a corresponding CPU usage rate threshold.
  • the CPU usage threshold of each process may be set through the second instruction.
  • the scheduling period of the CPU and the duration of the process using the CPU within one scheduling period are set through the second instruction.
  • cpu.cfs_period_us and cpu.cfs_quota_us are used as an example.
  • cpu.cfs_period_us is used to set the scheduling period of the CPU, such as 100000 (unit: microseconds);
  • cpu.cfs_quota_us is used to set the duration (microseconds) that the process occupies the CPU in each scheduling period, such as 50000 ( Unit: microsecond).
  • the CPU usage threshold of the abnormally high-load background process is reduced by the second instruction, so that when the CPU schedules the process, the CPU usage of the abnormally high-load background process is reduced, that is, the duration of the process occupying the CPU is reduced.
  • Method 3 Reduce the CPU usage of the process by periodically triggering process hibernation.
  • the CPU scheduling process is to allocate CPU resources within a period of time to the process.
  • the abnormally high-load background process if an abnormally high-load background process (the first process) is detected, the abnormally high-load background process is controlled to sleep periodically. When the first process sleeps, the first process does not use CPU resources. That is to say, the CPU does not allocate CPU resources to the process when it is sleeping. For example, the CPU schedules each process in a time slice round-robin manner. If it is determined that the first process sleeps within a period of time, the CPU does not allocate a time slice to the first process within the time period, that is, the first process does not participate in time slice rotation. In this way, the abnormally high-load background process does not use CPU resources during sleep, which reduces the CPU usage time of the process per unit time, that is, reduces the CPU usage of the abnormally high-load background process.
  • the time interval during which a process sleeps periodically is called a time slot, and the time interval or time slot is also called a sleep cycle.
  • Each time slot includes the running time of the first process and the sleeping time of the first process.
  • the first process may be scheduled by the CPU to use CPU resources.
  • the sleep time of the first process the CPU does not schedule the first process, and the first process does not use CPU resources.
  • the sleep time length (sleep duration) of the first process is equal.
  • the CPU schedules each process in a time slice round-robin manner, the time slice duration is 20 ms, the time slot length is 200 ms, and each time slot includes 10 time slices.
  • the first process is an abnormally high load background process, and during time slot 1, the CPU usage of the first process is 60%.
  • the first process sleeps periodically, the running duration in each time slot is the first running duration (140ms), and the sleep duration is the first sleep duration (60ms).
  • the first running duration and the first sleep duration are preset values.
  • the CPU determines the first running duration and the first sleep duration, it allocates CPU resources for the first process according to CPU scheduling rules (such as time slice rotation) within the first running duration; within the first sleep duration CPU resources are not allocated for the first process.
  • CPU scheduling rules such as time slice rotation
  • the CPU periodically sends a start-run instruction and a pause-run instruction to the first process; the start-run instruction is used to instruct the first process to start running, and the pause-run instruction is used to instruct the first process to start running.
  • the process starts sleeping.
  • the CPU sends the start-up instruction to the first process
  • the first process starts running according to the start-up instruction, and can be scheduled by the CPU.
  • the CPU sends a suspending instruction to the first process, and the first process starts to sleep according to the suspending instruction.
  • the CPU sends a start-up instruction to the first process, and the first process starts running according to the start-up instruction. In this way, the first process periodically runs for the first running duration and sleeps for the first sleep duration.
  • the running time is 7 consecutive time slices, and the sleep time is 3 consecutive time slices.
  • the running time may not be a continuous time slice, and the sleep time may not be a continuous time slice.
  • the sleep time in each time slot may not be at the end of the time slot, and the sleep time may be at any position in the time slot.
  • the positions of the sleep time may be the same or different. This embodiment of the present application does not limit it.
  • the CPU schedules each process in a round-robin fashion.
  • time slot 2 the CPU allocates 4 time slices to the first process, and the CPU usage rate of the first process in time slot 2 is 40%.
  • time slot 3 the CPU allocates 3 time slices to the first process, and the CPU usage rate of the first process in time slot 3 is 30%.
  • time slot 4 the CPU allocates 4 time slices to the first process, and the CPU usage rate of the first process in time slot 2 is 40%.
  • the CPU may schedule various processes in other manners.
  • the CPU schedules processes in order of scheduling priority from high to low, and schedules another process after one process quits using CPU resources.
  • the power consumption control method provided in the embodiment of the present application does not limit the scheduling mode of the CPU.
  • the sleep time length (sleep duration) of the first process may be unequal.
  • the CPU schedules each process in a time slice round-robin manner.
  • the time slice duration is 20 ms
  • the time slot length is 200 ms
  • each time slot includes 10 time slices.
  • the CPU usage of the first process is 60%. It is detected that the first process is an abnormally high-load background process.
  • the first process sleeps periodically.
  • the running duration and sleep duration of the first process in the current time slot are calculated according to the current CPU load and the preset target CPU load.
  • the target CPU load may be obtained based on statistics of historical CPU operation data. For example, according to historical data, when the CPU load is less than or equal to 20%, the battery temperature is lower than the preset temperature threshold; then the preset target CPU load is determined to be 20%.
  • the current CPU load is 50%
  • the current CPU load is greater than the target CPU load
  • the running duration in time slot 2 is determined to be the first running duration (for example, 100 ms)
  • the sleep duration is the first Sleep duration (for example, 100ms).
  • the CPU allocates 4 time slices to the first process by means of time slice rotation within the first running duration.
  • the CPU usage of the first process in time slot 2 is 40%. Since in time slot 2, the CPU usage of the first process (an abnormally high load background process) is reduced, the CPU load is reduced.
  • the current CPU load is 40%, and the current CPU load is greater than the target CPU load, and it is determined to increase the sleep duration in time slot 3.
  • the running time in time slot 3 is the second running time (such as 80ms), and the dormancy time is the second dormancy time (such as 120ms); wherein, the second running time ⁇ the first running time, the second dormancy time>the second A sleep duration.
  • the CPU allocates 3 time slices to the first process by means of time slice rotation during the second running duration.
  • the CPU usage of the first process in time slot 3 is 30%. Since in time slot 3, the CPU usage of the first process (an abnormally high load background process) is reduced, the CPU load is reduced. At the beginning of time slot 4, it is obtained that the current CPU load is 25%, and the current CPU load is greater than the target CPU load, and it is determined to increase the sleep duration in time slot 4.
  • the CPU allocates 2 time slices to the first process by means of time slice rotation during the third running duration.
  • the CPU usage of the first process in time slot 4 is 20%. Since during time slot 4, the CPU usage of the first process (an abnormally high load background process) is reduced, the CPU load is reduced.
  • the CPU determines the running time and sleep time in each time slot, it allocates CPU resources for the first process according to CPU scheduling rules (such as time slice rotation) during the running time;
  • the first process allocates CPU resources.
  • the first process starts running according to the start-and-run instruction, and may be scheduled by the CPU.
  • the CPU sends a suspending instruction to the first process, and the first process starts to sleep according to the suspending instruction.
  • the CPU sends a start-up instruction to the first process, and the first process starts running according to the start-up instruction, and can be scheduled by the CPU.
  • the CPU sends a suspending instruction to the first process, and the first process starts to sleep according to the suspending instruction.
  • the CPU After the second sleep period, the CPU sends a start-up instruction to the first process, and the first process starts running according to the start-up instruction, and can be scheduled by the CPU.
  • the CPU After the third running time, the CPU sends a suspending instruction to the first process, and the first process starts to sleep according to the suspending instruction.
  • the CPU After the third sleep period, the CPU sends a start-up instruction to the first process, and the first process starts running according to the start-up instruction, and can be scheduled by the CPU. In this way, the first process sleeps periodically.
  • the power consumption control method provided by the embodiment of the present application detects an abnormally high load of the background process, and then reduces the CPU usage rate of the background process, thereby reducing the CPU load, and solving the problem of electronic device freezing and power failure caused by the high load of the background process Fast, easy to heat and other issues.
  • the abnormally high load of the background process causes the CPU load to remain at a relatively high value (about 40%), and the CPU temperature From 31.5°C to 36.5°C.
  • the time spent by the background process on the CPU is reduced, the CPU load is reduced to about 20%, and the CPU temperature is reduced to 33°C.
  • the overall CPU load is high before 17:45 due to the presence of abnormally high-load background processes.
  • the overall load of the CPU is reduced from 86% to 56%, and the frequency points of small-core CPUs and medium-core CPUs are both significantly reduced. Due to the presence of foreground applications, the frequency of large-core CPUs remains basically unchanged.
  • the electronic device provided in the embodiment of the present application includes corresponding hardware structures and/or software modules for performing various functions.
  • the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software in combination with the example units and algorithm steps described in the embodiments disclosed herein. Whether a certain function is executed by hardware or computer software drives hardware depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the embodiments of the present application.
  • the embodiments of the present application may divide the above-mentioned electronic device into functional modules according to the above-mentioned method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules. It should be noted that the division of modules in the embodiment of the present application is schematic, and is only a logical function division, and there may be other division methods in actual implementation.
  • FIG. 14 shows a schematic structural diagram of a possible structure of the electronic device involved in the foregoing embodiments.
  • the electronic device 1400 includes: a processing unit 1410 and a storage unit 1420 .
  • the processing unit 1410 is configured to control and manage the actions of the electronic device 1400 .
  • the storage unit 1420 is used to store program codes and data of the electronic device 1400, and the processing unit 1410 invokes the program codes stored in the storage unit 1420 to execute various steps in the above method embodiments.
  • the unit modules in the above-mentioned electronic device 1400 include but not limited to the above-mentioned processing unit 1410 and storage unit 1420 .
  • the electronic device 1400 may further include a display unit, a power supply unit, and the like.
  • the display unit is used to display the display interface of the electronic device 1400 ;
  • the power supply unit is used to supply power to the electronic device 1400 .
  • the processing unit 1410 may be a processor or a controller, such as a central processing unit (central processing unit, CPU), a digital signal processor (digital signal processor, DSP), an application-specific integrated circuit (application-specific integrated circuit, ASIC) ), field programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
  • the storage unit 1420 may be a memory.
  • the display unit may be a display screen or the like.
  • the processing unit 1410 is a processor (such as the processor 110 shown in FIG. 2A ), the storage unit 1420 can be a memory (such as the internal memory 121 shown in FIG. 2A ), and the display unit can be a display screen (as shown in FIG. 2A ). display screen 190).
  • the electronic device 1400 provided in the embodiment of the present application may be the electronic device 100 shown in FIG. 2A .
  • the above-mentioned processor, memory, display screen, etc. may be connected together, for example, through a bus.
  • the processor invokes the program code stored in the memory to execute the steps in the above method embodiments.
  • An embodiment of the present application further provides a chip system, where the chip system includes at least one processor and at least one interface circuit.
  • the processor and interface circuitry may be interconnected by wires.
  • interface circuits may be used to receive signals from other devices, such as the memory of an electronic device.
  • an interface circuit may be used to send signals to other devices, such as a processor.
  • the interface circuit can read instructions stored in the memory and send the instructions to the processor.
  • the electronic device can be made to execute various steps in the above-mentioned embodiments.
  • the chip system may also include other discrete devices, which is not specifically limited in this embodiment of the present application.
  • An embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes computer instructions, and when the computer instructions are run on the above-mentioned electronic device, the electronic device is made to execute the method executed by the mobile phone in the above-mentioned method embodiment. individual functions or steps.
  • the embodiment of the present application also provides a computer program product, which, when the computer program product is run on a computer, causes the computer to execute each function or step performed by the mobile phone in the method embodiment above.
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be Incorporation or may be integrated into another device, or some features may be omitted, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the unit described as a separate component may or may not be physically separated, and the component displayed as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places . Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium Among them, several instructions are included to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Power Sources (AREA)

Abstract

本申请实施例提供一种功耗控制方法及装置,涉及终端技术领域。检测到后台应用对应的进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值;并且确定该后台应用的运行不被用户感知;则降低该后台应用对应的进程在单位时长内使用处理器资源的时长,降低该进程的处理器使用率。这样可以减少该异常高负载后台进程对处理器资源的占用,释放处理器资源,降低处理器负载,减少处理器功耗,提高了处理器性能。

Description

一种功耗控制方法及装置
本申请要求于2022年01月28日提交国家知识产权局、申请号为202210108275.1、发明名称为“一种功耗控制方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及终端技术领域,尤其涉及一种功耗控制方法及装置。
背景技术
电子设备使用过程中,可能出现应用进程或系统进程异常高负载,占用处理器的大量资源,导致处理器高负载甚至满载。电子设备的处理器高负载甚至满载,会导致前台运行的应用出现卡顿,还会带来高耗电、发热等问题。如何降低异常高负载进程对处理器性能的影响,是亟待解决的问题。
发明内容
本申请实施例提供一种功耗控制方法及装置,可以减少异常高负载进程占用处理器资源,降低处理器功耗,提高处理器性能。
为达到上述目的,本申请的实施例采用如下技术方案:
第一方面,提供了一种功耗控制方法,应用于电子设备,电子设备包括处理器,处理器上运行有第一进程,第一进程对应的第一应用在电子设备后台运行,该方法包括:如果检测到第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值,并且确定第一应用的运行不被用户感知,则降低第一进程的处理器使用率。
检测到第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值,表示第一进程为高负载进程。第一应用的运行不被用户感知,表示第一进程是异常地在后台占用处理器资源。当确定第一进程是异常高负载后台进程,则降低第一进程的处理器使用率;即降低了第一进程对处理器资源的占用,释放了处理器资源;处理器资源可以用于其他进程,降低处理器负载,这样就降低了处理器功耗,提高了处理器性能。
相比直接将第一进程杀掉,本申请实施例提供的降低第一进程的处理器使用率的方法可以降低误杀后台进程的几率,避免引起系统异常。
结合第一方面,在一种可能的实施方式中,降低第一进程的处理器使用率的条件还包括:确定电子设备满足预设的异常条件;其中,异常条件包括下列至少一项:电子设备的处理器温度大于预设温度阈值;电子设备的电池电量在预设时长内下降的值大于预设电量阈值;电子设备上运行的前台应用运行卡顿。
结合电子设备的异常,可以更准确地判断第一进程是异常高负载后台进程。
结合第一方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:控制第一进程周期性地休眠;在第一进程休眠时,第一进程未使用处理器资源,即降低了第一进程的处理器使用率。
在一种可能的实施方式中,每个休眠周期内包括第一进程的运行时间和休眠时间;在第一进程的运行时间内,第一进程根据处理器的调度使用处理器资源。这样,第一进程可以在处理器为其分配的时长内使用处理器资源。运行时间长度与休眠时间长度之和为休眠周期。
结合第一方面,在一种可能的实施方式中,第一进程在每个休眠周期内的休眠时间相等,休眠时间为预设值。
结合第一方面,在一种可能的实施方式中,根据处理器当前负载和预设的目标负载确定当前休眠周期内的休眠时间。
结合第一方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:降低第一进程的调度优先级,调度优先级用于指示进程被处理器分配处理器资源的顺序。这样就降低了第一进程被分配处理器资源的几率,降低了第一进程的处理器使用率。在一种实施方式中,降低第一进程的调度优先级包括:增大第一进程的调度优先级数值。
结合第一方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:降低第一进程的处理器使用率阈值。
结合第一方面,在一种可能的实施方式中,第一应用的运行不被用户感知包括:第一应用未进行音频输入或输出;并且,第一应用未通过移动通信或无线通信接收或发送数据。
结合第一方面,在一种可能的实施方式中,第一应用在电子设备后台运行包括:第一应用不存在人机交互界面;或,第一应用的人机交互界面停止在电子设备的屏幕上显示。
第二方面,提供了一种电子设备,该电子设备具有实现上述第一方面所述的方法的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的模块。
第三方面,提供了一种电子设备,包括:处理器和存储器;该存储器用于存储计算机执行指令,当该电子设备运行时,该处理器执行该存储器存储的该计算机执行指令,以使该电子设备执行如下步骤:
检测到第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值,表示第一进程为高负载进程。第一应用的运行不被用户感知,表示第一进程是异常地在后台占用处理器资源。当确定第一进程是异常高负载后台进程,则降低第一进程的处理器使用率;即降低了第一进程对处理器资源的占用,释放了处理器资源;处理器资源可以用于其他进程,降低处理器负载,这样就降低了处理器功耗,提高了处理器性能。
相比直接将第一进程杀掉,本申请实施例提供的降低第一进程的处理器使用率的方法可以降低误杀后台进程的几率,避免引起系统异常。
结合第三方面,在一种可能的实施方式中,降低第一进程的处理器使用率的条件还包括:确定电子设备满足预设的异常条件;其中,异常条件包括下列至少一项:电子设备的处理器温度大于预设温度阈值;电子设备的电池电量在预设时长内下降的值大于预设电量阈值;电子设备上运行的前台应用运行卡顿。
结合电子设备的异常,可以更准确地判断第一进程是异常高负载后台进程。
结合第三方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:控制第一进程周期性地休眠;在第一进程休眠时,第一进程未使用处理器资源,即降低了第一进程的处理器使用率。
在一种可能的实施方式中,每个休眠周期内包括第一进程的运行时间和休眠时间;在第一进程的运行时间内,第一进程根据处理器的调度使用处理器资源。这样,第一进程可以在处理器为其分配的时长内使用处理器资源。运行时间长度与休眠时间长度之和为休眠周期。
结合第三方面,在一种可能的实施方式中,第一进程在每个休眠周期内的休眠时间相等,休眠时间为预设值。
结合第三方面,在一种可能的实施方式中,根据处理器当前负载和预设的目标负载确定当前休眠周期内的休眠时间。
结合第三方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:降低第一进程的调度优先级,调度优先级用于指示进程被处理器分配处理器资源的顺序。这样就降低了第一进程被分配处理器资源的几率,降低了第一进程的处理器使用率。在一种实施方式中,降低第一进程的调度优先级包括:增大第一进程的调度优先级数值。
结合第三方面,在一种可能的实施方式中,降低第一进程的处理器使用率包括:降低第一进程的处理器使用率阈值。
结合第三方面,在一种可能的实施方式中,第一应用的运行不被用户感知包括:第一应用未进行音频输入或输出;并且,第一应用未通过移动通信或无线通信接收或发送数据。
结合第三方面,在一种可能的实施方式中,第一应用在电子设备后台运行包括:第一应用不存在人机交互界面;或,第一应用的人机交互界面停止在电子设备的屏幕上显示。
第四方面,提供了一种电子设备,包括:处理器;所述处理器用于与存储器耦合,并读取存储器中的指令之后,根据所述指令执行如上述第一方面中任一项所述的功耗控制方法。
第五方面,提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机可以执行上述第一方面中任一项所述的功耗控制方法。
第六方面,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机可以执行上述第一方面中任一项所述的功耗控制方法。
第七方面,提供了一种装置(例如,该装置可以是芯片系统),该装置包括处理器,用于支持电子设备实现上述第一方面中所涉及的功能。在一种可能的设计中,该装置还包括存储器,该存储器,用于保存电子设备必要的程序指令和数据。该装置是芯片系统时,可以由芯片构成,也可以包含芯片和其他分立器件。
其中,第二方面至第七方面中任一种实施方式所带来的技术效果可参见第一方面中不同实施方式所带来的技术效果,此处不再赘述。
附图说明
图1A为本申请实施例提供的功耗控制方法所适用的场景示意图;
图1B为本申请实施例提供的功耗控制方法所适用的场景示意图;
图2A为本申请实施例提供的一种电子设备的硬件结构示意图;
图2B为本申请实施例提供的一种电子设备的软件架构示意图;
图3为本申请实施例提供的功耗控制方法的流程图;
图4A为本申请实施例提供的功耗控制方法的场景实例示意图;
图4B为本申请实施例提供的功耗控制方法的场景实例示意图;
图5A为本申请实施例提供的功耗控制方法的场景实例示意图;
图5B为本申请实施例提供的功耗控制方法的场景实例示意图;
图5C为本申请实施例提供的功耗控制方法的场景实例示意图;
图5D为本申请实施例提供的功耗控制方法的场景实例示意图;
图6为本申请实施例提供的功耗控制方法的场景实例示意图;
图7为本申请实施例提供的功耗控制方法的场景实例示意图;
图8为本申请实施例提供的功耗控制方法的场景实例示意图;
图9为本申请实施例提供的功耗控制方法的场景实例示意图;
图10为本申请实施例提供的功耗控制方法的流程示意图;
图11为本申请实施例提供的功耗控制方法的场景实例示意图;
图12为本申请实施例提供的功耗控制方法的流程示意图;
图13A为本申请实施例提供的功耗控制方法的实现效果示意图;
图13B为本申请实施例提供的功耗控制方法的实现效果示意图;
图14为本申请实施例提供的功耗控制装置示意图。
具体实施方式
下面结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个或两个以上(包含两个)。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他 方式另外特别强调。术语“连接”包括直接连接和间接连接,除非另外说明。“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。
在本申请实施例中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性地”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。
电子设备使用过程中,存在一些在后台运行的应用程序(比如,第三方应用或系统应用)。应用程序在后台运行,即应用程序在电子设备上运行,但是不在电子设备屏幕上显示应用程序的人机交互界面。比如,用户在电子设备上打开聊天应用,显示聊天应用的人机交互界面。使用聊天应用过程中,用户又打开视频应用,电子设备显示视频应用的人机交互界面。聊天应用的人机交互界面被隐藏或者被关闭或者被视频应用的人机交互界面完全遮挡,电子设备屏幕上停止显示聊天应用的人机交互界面;即聊天应用在后台运行。比如,用户打开音乐应用,启动播放音乐后,关闭音乐应用的人机交互界面;音乐应用继续播放音乐,即音乐应用在后台运行。比如,操作系统在后台启动一些系统应用,这些系统应用没有人机交互界面。
在后台运行的应用程序(本申请中称为后台应用),通常不占用大量的处理器资源;或者基于用户需要(比如快速下载较大文件)占用较多处理器资源。其中,处理器资源即处理器的运算能力。但是在一些场景中,后台运行的应用程序会异常高负载。比如,应用程序执行的指令进入死循环,无法正常退出,就会异常高负载。应用程序负载就是在一段时间内处理器正在处理以及等待处理器处理的该应用程序的进程数之和的统计信息。后台应用异常高负载,可能会异常占用较多处理器资源,造成处理器负载较高甚至处理器满载。处理器负载就是在一段时间内处理器正在处理以及等待处理器处理的进程数之和的统计信息,即处理器使用队列的长度统计信息。可以理解的,处理器负载越低,进程等待被处理器调度的时间就越短;处理器负载越高,进程等待被处理器调度的时间就越长。如果存在应用程序在前台运行(本申请中称为前台应用),后台应用异常高负载会导致前台应用无法被及时调度,出现卡顿(比如,应用程序播放的动态画面不连续,播放的声音断断续续等),影响用户体验。并且,后台应用异常高负载还会带来高耗电、使电子设备发热等问题。
本申请实施例所述处理器可以包括中央处理器(central processing unit,CPU),图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),数字信号处理器(digital signal processor,DSP),或神经网络处理器(neural-network processing unit,NPU)等。下面以处理器是CPU为例进行介绍。可以理解的,本申请实施例提供的功耗控制方法同样适用于其他类型的处理器。
示例性的,图1A示出一种手机上存在后台应用异常高负载时CPU负载的监测情况示意图。如图1A所示,22:45-1:30之间,用户正常使用手机,手机上运行有前台应用,CPU负载随用户使用情况实时变化。由于后台应用异常高负载,占用大量CPU资源;用户使用手机时,前台应用出现卡顿,影响用户使用体验。1:30之后,用户未使用手机,手机上未运行前台应用,手机上仅存在后台应用,但是CPU负载仍然保持在 一个较高的值。通过监测手机电量,22:45时手机剩余80%电量,1:30时手机剩余40%电量,6:00时手机剩余电量接近0。可以看出,用户不使用手机时,1:30-6:00之间的4个半小时内,手机消耗40%电量;后台应用耗电量较高。通过监测发现,22:45-6:00之间,手机总功耗为1583.71毫安时(mAh),前台应用功耗为3.44mAh,后台应用功耗为1580.27mAh;可以看出,后台应用功耗远大于前台应用功耗。后台应用耗电量高,手机待机时间会大大缩短,还可能会发热,降低用户使用体验。
示例性的,图1B示出另一手机上存在后台应用异常高负载时CPU负载的监测情况示意图。如图1B所示,手机上应用1在前台运行(本申请中称为前台应用1),CPU负载随应用1负载变化。一段时间后,前台应用1停止运行。23:48之后,在后台运行的应用2(本申请中称为后台应用2)高负载98%,CPU负载仍然保持在一个较高的值。通过监测CPU温度,前台应用1运行期间,CPU温度从28.5℃上升至36.5℃,并维持在36.5℃;前台应用1停止运行后,后台应用2高负载98%,CPU温度持续升高,最高上升至47℃。可以看出,后台应用高负载会带来手机发热的问题。
现有技术中,如果检测到异常高负载的后台应用,一般会将该后台应用关联的进程杀掉,清理异常高负载后台应用的关联进程;消除异常高负载后台应用对CPU资源的占用。但是,如果被杀掉的是系统进程,该系统进程关联的其他系统进程可能存在状态错误,导致业务功能异常、无法恢复问题。更严重地,部分重要系统进程被杀掉后,会导致操作系统重启。还有部分异常进程被杀掉后,如果操作系统重启,还是会出现异常高负载问题。
本申请实施例提供一种功耗控制方法,如果检测到后台进程(后台进程即后台应用的进程)异常高负载,则降低该后台进程使用CPU的时长,解决后台进程高负载带来的电子设备使用卡顿、掉电快、易发热等问题。
本申请实施例提供的功耗控制方法可以应用于包括处理器的电子设备。上述电子设备可以包括手机、平板电脑、笔记本电脑、个人电脑(personal computer,PC)、超级移动个人计算机(ultra-mobile personal computer,UMPC)、手持计算机、上网本、智能家居设备(比如,智能电视、智慧屏、大屏、智能音箱、智能空调等)、个人数字助理(personal digital assistant,PDA)、可穿戴设备(比如,智能手表、智能手环等)、车载设备、虚拟现实设备等,本申请实施例对此不做任何限制。
请参考图2A,为本申请实施例提供的一种电子设备100的结构示意图。如图2A所示,该电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,传感器模块170,摄像头180,显示屏190等。其中传感器模块170可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括中央处理器(central processing unit,CPU),应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏190,摄像头180,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基 带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备输出声音信号,或通过显示屏190显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信(near field communication,NFC),红外(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
电子设备100通过GPU,显示屏190,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏190和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏190用于显示图像,视频等。显示屏190包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏190,N为大于1的正整数。
电子设备100可以通过ISP,摄像头180,视频编解码器,GPU,显示屏190以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头 被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头180用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头180,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构为例,示例性说明电子设备100的软件结构。
图2B是本发明实施例的电子设备100的软件结构框图。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。
应用程序层可以包括一系列应用程序包。
如图2B所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。
如图2B所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
下面结合附图,详细介绍本申请实施例提供的功耗控制方法。需要说明的是,执行本申请实施例提供的功耗控制方法的,可以是处理器(本申请实施例以CPU为例),或者电子设备中其他处理单元(比如芯片),或者能够与电子设备通信以控制电子设备中处理器的装置等,本申请实施例对该方法的执行主体并不进行限定。
示例性的,如图3所示,本申请实施例提供的功耗控制方法可以包括:
S301、监测CPU上后台应用对应的进程的负载和运行时长。
电子设备运行时,存在一些在后台运行的应用程序,即后台应用。本申请中,后台应用对应的进程称为后台进程。在一种实现方式中,如果确定应用程序不存在人机交互界面或应用程序的人机交互界面停止在电子设备的屏幕上显示,则确定该应用程序为后台应用。进程的负载就是在一段时间内处理器正在处理以及等待处理器处理的该进程的进程数之和的统计信息。
S302、检测到第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值。
如果确定后台进程满足预设条件,则确定该后台进程高负载。在一种示例中,预设条件包括:负载高于预设负载阈值、且运行时长大于或等于预设时长阈值。比如,负载高于30%且运行时长大于或等于5分钟;比如,负载高于20%且运行时长大于或等于8分钟;比如,负载高于10%且运行时长大于或等于15分钟;比如,负载高于5%且运行时长大于或等于60分钟。
检测到第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值,即检测到第一进程高负载。
如果确定第一进程高负载,执行S303;否则,执行S301。
S303、判断第一进程对应的第一应用的运行是否可被用户感知。
在一种示例中,应用程序的运行可被用户感知包括:应用程序进行音频输入或输出。比如,音乐播放应用在后台运行,并播放音乐,即存在音频输出。比如,用户拨打电话时,通话应用在后台运行,进行语音输入和输出。
在一种示例中,应用程序的运行可被用户感知包括:应用程序通过移动通信或无线通信接收或发送数据。比如,下载类应用(比如迅雷下载)、导航类应用(比如高德地图、百度地图)在后台运行时,进行数据上传或下载。比如,运动健康应用通过GPS获取用户位置信息。
在一种示例中,新闻阅读类应用、金融理财类应用在后台运行时,未进行音频输入输出,也未通过移动通信或无线通信收发数据,用户不可感知。
如果确定第一应用的运行可被用户感知,执行S301。在一种实现方式中,如果确定第一应用的运行不被用户感知,执行S304。
S304、判断电子设备是否满足异常条件。如果满足异常条件,执行S305;如果确定不满足异常条件,执行S301。
可选的,进一步判断电子设备是否满足异常条件;异常条件包括以下至少一项:CPU温度大于预设温度阈值;电池电量在预设时长内下降的值大于预设电量阈值;前 台应用运行卡顿。
在一些实施例中,判断电子设备是否满足异常条件包括S3041-S3043:
S3041、判断CPU温度是否大于预设温度阈值。如果确定CPU温度大于预设温度阈值,则确定电子设备满足异常条件;如果确定CPU温度小于或等于预设温度阈值,则执行S3042。
在一种实现方式中,电子设备通过温度传感器监测CPU温度。示例性的,预设的温度阈值为40℃。如果温度传感器检测到CPU温度大于40℃,则确定电子设备满足异常条件。
S3042、判断电池电量在预设时长内下降的值是否大于预设电量阈值。如果确定电池电量在预设时长内下降的值大于预设电量阈值,确定电子设备满足异常条件;如果确定电池电量在预设时长内下降的值小于或等于预设电量阈值,则执行S3043。
示例性的,预设时长为10分钟,预设电量阈值为20%。如果确定电池电量在预设时长内下降的值大于20%,则确定电子设备满足异常条件。
S3043、判断是否存在前台应用运行卡顿。如果确定存在前台应用运行卡顿,则确定电子设备满足异常条件。如果确定不存在前台应用运行卡顿,执行S301。
在一种实现方式中,如果确定应用程序播放的帧率小于预设的第一帧率阈值,则确定该应用程序运行卡顿。比如,预设的第一帧率阈值为20fps。
在另一种实现方式中,通过统计该电子设备上的历史数据,确定前台应用正常播放的平均帧率为第一帧率值(比如,50fps)。如果确定该应用程序播放的第二帧率值与第一帧率值的差值大于预设的第二帧率阈值,则确定该应用程序运行卡顿。其中,第二帧率值小于第一帧率值。比如,第一帧率值为80fps,第二帧率值为40fps,第二帧率阈值为30fps,则确定该应用程序运行卡顿。
需要说明的是,上述以先判断CPU温度,再判断电池电量,最后判断前台应用运行卡顿的顺序为例进行介绍。在实际应用中,可以有不同的判断顺序,其并不影响本申请实施例的实现效果。比如,可以先执行S3042,再执行S3041;再比如,可以先执行S3043,再执行S3042等。本申请实施例对S3041、S3042和S3043执行的先后顺序并不进行限定。
需要说明的是,本申请实施例对S302、S303和S304执行的先后顺序并不进行限定。在另一些实施方式中,可以先执行S303或S304。
S305、降低第一进程的CPU使用率。
进程使用CPU资源的时长可以通过进程的CPU使用率(即处理器使用率)体现,进程的CPU使用率即单位时长内进程使用CPU资源的时长。降低进程的CPU使用率即降低单位时长内该进程使用CPU资源的时长。其中,进程的CPU使用率=进程使用CPU资源的时长/CPU运行时长。对于单个CPU,示例性的,如图4A所示,进程1周期性地运行20ms,停止运行20ms。那么进程1的CPU使用率=20ms/40ms=50%。对于多个CPU或多核CPU,进程的CPU使用率=进程使用各个CPU资源的时长总和/各个CPU运行时长总和。示例性的,如图4B所示,进程1在CPU0上周期性地运行40ms,停止运行40ms;进程1在CPU1上周期性地运行20ms,停止运行60ms。那么进程1的CPU使用率=(40ms+20ms)/(80ms+80ms)=37.5%。
降低异常高负载后台进程在单位时间内使用CPU资源的时长,即降低了异常高负载的后台进程对CPU资源的占用,CPU资源可以用于其他进程(比如前台进程),这样可以避免异常高负载的后台进程导致的前台应用卡顿。并且,降低异常高负载的后台进程在单位时间内使用CPU资源的时长,即减少了异常高负载的后台进程对CPU资源的占用,CPU资源可以用于其他正常运行的进程,加快其他进程的处理速度,降低CPU负载;这样就可以降低电量消耗,也消除了其带来的发热问题。
方式一:通过降低异常高负载后台进程的调度优先级降低该进程的CPU使用率。
将一个时间段内的CPU资源分配给进程使用,即CPU调度进程。一般来说,多个进程不能同时使用同一个时间段的CPU资源。如果有多个进程等待CPU调度,在一种实现方式中,CPU按照进程的调度优先级从高到低的顺序对进程进行调度。调度优先级高的进程比调度优先级低的进程优先被CPU调度。可选的,调度优先级相同的进程按照进入调度队列的先后顺序进行调度。在一种实现方式中,用调度优先级数值表示调度优先级;调度优先级数值越大,调度优先级越低。示例性的,调度优先级用-20至19的整数表示,每个数字代表一个调度优先级;-20表示调度优先级最高,19表示调度优先级最低。
在一种示例中,CPU采用时间片轮转的方式调度各个进程;时间片的时长为预设值,比如,20ms。CPU将一个时间片内的CPU资源分给进程使用,即在一个时间片内调度该进程。当有多个进程等待使用CPU资源时,CPU可以轮流为各个进程分配时间片。在一种实现方式中,CPU按照进程的调度优先级从高到低的顺序为进程分配时间片。示例性的,CPU保存进程调度队列;等待CPU处理的进程按照进程的调度优先级从高到低的顺序在进程调度队列中排序;如果调度优先级相同,则按照进程到达进程调度队列的先后顺序进行排序。CPU在每个时间片开始时,查看进程调度队列,将该时间片分配给进程调度队列中位于队首的进程(进程1)。进程1在该时间片内使用CPU资源。该时间片结束后,进程1停止使用CPU资源。进程1再次进入进程调度队列。这样,调度优先级高的进程被调度的几率高,CPU使用率较高。
在一种实现方式中,通过降低异常高负载后台进程的调度优先级降低该进程被CPU调度的几率。比如,通过调整进程的调度优先级值来改变进程的调度优先级。在一种示例中,可以增大异常高负载的后台进程的调度优先级值,以降低异常高负载的后台进程的调度优先级。这样,其他进程(比如前台进程,非异常的后台进程)比异常高负载的后台进程更优先被CPU调度,降低了该进程被分配CPU资源的几率,从而降低该进程使用CPU的时长。
在一种示例中,进程1的调度优先级值为-20。示例性的,如图5A所示,在10个时间片(200ms)内,CPU为进程1分配了6个时间片;进程1的CPU使用率为60%。检测到进程1为异常高负载后台进程,则将进程1的调度优先级值修改为19,降低进程1的调度优先级。进程1位于进程调度队列中队首位置的几率降低,即被分配时间片的几率降低。示例性的,如图5B所示,在10个时间片(200ms)内,CPU为进程1分配了3个时间片;进程1的CPU使用率降为30%。
在另一示例中,如图5C所示,进程标识(PID)为6508的后台进程的调度优先级(NI)为-20(调度优先级最高),该进程被调用的几率较高,进程负载为247%。 检测到该进程为异常高负载后台进程后,通过nice指令将PID为6508的后台进程的调度优先级(NI)修改为19(调度优先级最低)。经过一段时间后,如图5D所示,进程标识(PID)为6508的后台进程的进程负载降至232%。可以看出,降低异常高负载的后台进程的调度优先级后,该进程的进程负载降低,即降低了该进程的运行频率,从而降低了该进程的CPU使用率。
方式二:通过设置异常高负载后台进程的CPU使用率阈值降低该进程的CPU使用率。
进程的CPU使用率阈值用于限制进程的CPU使用率(进程的CPU使用率小于或等于进程的CPU使用率阈值),即限制进程的CPU使用时长。
在一些实施例中,如果确定进程为异常高负载后台进程,则设置该进程的CPU使用率阈值为第一阈值。比如,如果确定进程1为异常高负载后台进程,设置进程1的CPU使用率阈值为第一阈值,这样,在每个调度周期内,CPU为进程1分配的CPU时长占调度周期的比例小于或等于第一阈值,则该进程1在一个调度周期内的CPU使用时长小于或等于(第一阈值*调度周期),即该进程1的CPU使用率小于或等于第一阈值。比如,可以将第一阈值的值设置得较小。这样,异常高负载后台进程在每个调度周期内的CPU使用时长都保持在较低的范围内,降低了异常高负载后台进程使用CPU的时长。
在另一些实施例中,进程1的CPU使用率阈值为第一阈值,确定该进程1为异常高负载后台进程,则设置进程1的CPU使用率阈值为第二阈值;其中,第二阈值小于第一阈值。这样,降低了异常高负载后台进程的CPU使用率,即异常高负载后台进程在每个调度周期内的CPU使用时长都降低了,即降低了异常高负载后台进程使用CPU的时长。
在一种示例中,可以通过第一指令设置每个进程占用CPU时长的相对权重,根据进程占用CPU时长的相对权重获取进程的CPU使用率阈值;其中,第一进程的CPU使用率阈值=第一进程占用CPU时长的相对权重/全部进程占用CPU时长的相对权重之和。以第一指令为cpu.shares为例。在一种实现方式中,可以采用cpu.shares设置每个进程占用CPU时长的相对权重。比如,采用cpu.shares将进程1占用CPU时长的相对权重(shares值)设置为1024,将进程2的shares值设置为512,将进程3的shares值设置为512。那么进程1的CPU使用率阈值为1024/(1204+512+512)=50%,进程2的CPU使用率阈值为512/(1204+512+512)=25%,进程3的CPU使用率阈值为512/(1204+512+512)=25%。示例性的,如图6的(a)所示,对于一个单核CPU,CPU调度各个进程时,进程1的CPU使用率不超过50%,即进程1占用的CPU时长不超过50%*单个CPU总运行时长;进程2的CPU使用率不超过25%,即进程2占用的CPU时长不超过25%*单个CPU总运行时长;进程3的CPU使用率不超过25%,即进程3占用的CPU时长不超过25%*单个CPU总运行时长。示例性的,如图6的(b)所示,对于双核CPU(包括CPU0和CPU1),CPU调度各个进程时,进程1的CPU使用率不超过50%,即进程1占用的CPU时长不超过50%*(CPU0总运行时长+CPU1总运行时长)=单个CPU总运行时长;进程2的CPU使用率不超过25%,即进程2占用的CPU时长不超过25%*(CPU0总运行时长+CPU1总运行时长)=50%*单个CPU 总运行时长;进程3的CPU使用率不超过25%,即进程3占用的CPU时长不超过25%*(CPU0总运行时长+CPU1总运行时长)=50%*单个CPU总运行时长。在另一种实现方式中,将CPU上的进程分为多个进程组,每个进程组包括一个或多个进程;比如,进程组1包括视频类应用的进程,进程组2包括导航类应用的进程。可以采用cpu.shares设置每个进程组占用CPU时长的相对权重,还可以采用cpu.shares设置进程组内每个进程占用CPU时长的相对权重。示例性的,如图7所示,采用cpu.shares设置进程组1的shares值为50,设置进程组2的shares值为100,设置进程组2内进程1的shares值为500,设置进程组2内进程2的shares值为1000;那么进程组1的CPU使用率阈值为50/(50+100)=33%,进程组2的CPU使用率阈值为100/(50+100)=67%,进程组2内进程1的CPU使用率阈值为(500/(500+1000))*67%=22%,进程组2内进程2的CPU使用率阈值为(1000/(500+1000))*67%=44%。对于一个单核CPU,CPU调度各个进程时,进程组1内各个进程的CPU使用率之和不超过33%,即进程组1内各个进程占用CPU的时长之和不超过33%*单个CPU总运行时长;进程组2内进程1的CPU使用率不超过22%,即进程组2内进程1占用CPU的时长不超过22%*单个CPU总运行时长;进程组2内进程2的CPU使用率不超过44%,即进程组2内进程2占用CPU的时长不超过44%*单个CPU总运行时长。可选的,在一些实施例中,如果CPU存在空闲资源,进程的CPU使用率可以大于对应的CPU使用率阈值。
通过第一指令降低异常高负载后台进程占用CPU时长的相对权重,即降低异常高负载后台进程的CPU使用率阈值,这样,CPU调度进程时,异常高负载后台进程的CPU使用率降低,即降低了该进程占用CPU的时长。示例性的,进程1、进程2和进程3的shares值如图6的(a)所示,进程1的CPU使用率阈值为50%,进程2的CPU使用率阈值为25%,进程3的CPU使用率阈值为25%。检测到进程1为异常高负载后台进程,则通过cpu.shares将进程1的shares值设置为2。这样,如图8所示,进程1的CPU使用率阈值变为2/(2+512+512)=0.19%,即CPU调度进程时,进程1的CPU使用率不超过0.19%,即降低了进程1使用CPU的时长。
在另一种示例中,可以通过第二指令设置每个进程的CPU使用率阈值。比如,通过第二指令设置CPU的调度周期以及在1个调度周期内进程使用CPU的时长。以cpu.cfs_period_us和cpu.cfs_quota_us为例。cpu.cfs_period_us用于设置CPU的调度周期,比如设为100000(单位:微秒);cpu.cfs_quota_us用于设置在每个调度周期内该进程占用CPU的时长(微秒),比如设为50000(单位:微秒)。对于一个单核CPU,该进程的CPU使用率阈值为50000/100000=50%;对于多个单核CPU或多核CPU,该进程的CPU使用率阈值为50000/(100000*N),N为CPU核的个数,N>1。比如,对于双核CPU,该进程的CPU使用率阈值为50000/(100000*2)=25%。再比如,设置cpu.cfs_period_us=1000,cpu.cfs_quota_us=2000,那么该进程的CPU使用率阈值为2000/(1000*N);当N=2时,该进程最多占用两个CPU核的全部资源。
通过第二指令降低异常高负载后台进程的CPU使用率阈值,这样,CPU调度进程时,异常高负载后台进程的CPU使用率降低,即降低了该进程占用CPU的时长。示例性的,进程1的CPU使用率阈值为50%,检测到进程1为异常高负载后台进程,则将该进程的CPU使用率阈值设置为1%(比如,设置cpu.cfs_period_us=1000, cpu.cfs_quota_us=10),这样,该进程的CPU使用率不会超过1%,降低了异常高负载后台进程的CPU使用率,即降低了异常高负载后台进程占用CPU的时长。
方式三:通过周期性地触发进程休眠降低该进程的CPU使用率。
CPU调度进程,即将一个时间段内的CPU资源分配给进程使用。本实施例提供的方法中,如果检测到异常高负载后台进程(第一进程),则控制该异常高负载后台进程周期性地休眠。在第一进程休眠时,第一进程不使用CPU资源。也就是说,CPU在进程休眠时,不为其分配CPU资源。比如,CPU采用时间片轮转的方式调度各个进程。确定第一进程在一段时长内休眠,则CPU在该时间段内不为第一进程分配时间片,即第一进程不参与时间片轮转。这样,异常高负载后台进程在休眠时未使用CPU资源,降低了单位时长内该进程使用CPU的时长,即降低了异常高负载后台进程的CPU使用率。
本申请实施例中,进程周期性地休眠的时间间隔称为时间槽,该时间间隔或时间槽也称为休眠周期。时间槽的时长为预设值,比如,一个时间槽=M个时间片,M为大于1的整数。示例性的,一个时间槽的时长为200ms。每个时间槽内包括第一进程的运行时间和第一进程的休眠时间。在第一进程的运行时间内,第一进程可以被CPU调度,使用CPU资源。在第一进程的休眠时间内,CPU不调度第一进程,第一进程不使用CPU资源。
在一种实施方式中,在每个时间槽内,第一进程的休眠时间长度(休眠时长)相等。示例性的,如图9所示,CPU采用时间片轮转的方式调度各个进程,时间片时长为20ms,时间槽时长为200ms,每个时间槽包括10个时间片。第一进程是异常高负载后台进程,在时间槽1内,第一进程的CPU使用率为60%。从时间槽2开始,第一进程周期性地休眠,在每个时间槽内的运行时长为第一运行时长(140ms),休眠时长为第一休眠时长(60ms)。第一运行时长和第一休眠时长为预设值。
在一种实现方式中,CPU确定第一运行时长和第一休眠时长后,在第一运行时长内按照CPU调度规则(比如时间片轮转)为第一进程分配CPU资源;在第一休眠时长内不为第一进程分配CPU资源。
在一种实现方式中,如图10所示,CPU周期性地向第一进程发送启动运行指令和暂停运行指令;启动运行指令用于指示第一进程开始运行,暂停运行指令用于指示第一进程开始休眠。CPU向第一进程发送启动运行指令后,第一进程根据启动运行指令开始运行,可以被CPU调度。第一运行时长后,CPU向第一进程发送暂停运行指令,第一进程根据暂停运行指令开始休眠。第一休眠时长后,CPU向第一进程发送启动运行指令,第一进程根据启动运行指令开始运行。这样,第一进程周期性地运行第一运行时长,休眠第一休眠时长。
需要说明的是,图9中运行时间为7个连续的时间片,休眠时间为3个连续的时间片。在另一些实现方式中,运行时间可以不是连续的时间片,休眠时间也可以不是连续的时间片。每个时间槽内的休眠时间可以不在该时间槽的最后,休眠时间可以在时间槽内的任意位置。并且,在各个不同的时间槽内,休眠时间的位置可以相同也可以不同。本申请实施例对此并不进行限定。
如图9所示,在第一进程的运行时间内,CPU采用时间片轮转的方式调度各个进 程。在时间槽2内,CPU为第一进程分配4个时间片,第一进程在时间槽2内的CPU使用率为40%。在时间槽3内,CPU为第一进程分配3个时间片,第一进程在时间槽3内的CPU使用率为30%。在时间槽4内,CPU为第一进程分配4个时间片,第一进程在时间槽2内的CPU使用率为40%。
可以理解的,在另一些实施方式中,CPU可以采用其他方式调度各个进程。比如,CPU按照调度优先级从高到低的顺序调度各个进程,一个进程退出使用CPU资源之后调度另一个进程。本申请实施例提供的功耗控制方法并不限定CPU的调度方式。
另一种实施方式中,在各个时间槽内,第一进程的休眠时间长度(休眠时长)可以不相等。示例性的,如图11所示,CPU采用时间片轮转的方式调度各个进程,时间片时长为20ms,时间槽时长为200ms,每个时间槽包括10个时间片。在时间槽1内,第一进程的CPU使用率为60%。检测到第一进程为异常高负载后台进程,从时间槽2开始,第一进程周期性地休眠。在一种实现方式中,在每个时间槽开始时,根据CPU当前负载和预设的目标CPU负载计算当前时间槽内第一进程的运行时长和休眠时长。比如,目标CPU负载可以是根据对CPU运行的历史数据统计得出的。例如,根据历史数据,CPU负载小于或等于20%时,电池温度小于预设温度阈值;则确定预设的目标CPU负载为20%。
示例性的,在时间槽2开始时,获取CPU当前负载为50%,CPU当前负载大于目标CPU负载,确定时间槽2内的运行时长为第一运行时长(例如100ms),休眠时长为第一休眠时长(例如100ms)。例如,CPU在第一运行时长内,采用时间片轮转的方式,为第一进程分配了4个时间片。第一进程在时间槽2内的CPU使用率为40%。由于在时间槽2内,降低了第一进程(异常高负载后台进程)的CPU使用率,CPU负载降低。在时间槽3开始时,获取CPU当前负载为40%,CPU当前负载大于目标CPU负载,确定增大时间槽3内的休眠时长。例如,确定时间槽3内的运行时长为第二运行时长(例如80ms),休眠时长为第二休眠时长(例如120ms);其中,第二运行时长<第一运行时长,第二休眠时长>第一休眠时长。例如,CPU在第二运行时长内,采用时间片轮转的方式,为第一进程分配了3个时间片。第一进程在时间槽3内的CPU使用率为30%。由于在时间槽3内,降低了第一进程(异常高负载后台进程)的CPU使用率,CPU负载降低。在时间槽4开始时,获取CPU当前负载为25%,CPU当前负载大于目标CPU负载,确定增大时间槽4内的休眠时长。例如,确定时间槽4内的运行时长为第三运行时长(60ms),休眠时长为第三休眠时长(140ms);其中,第三运行时长<第二运行时长,第三休眠时长>第二休眠时长。例如,CPU在第三运行时长内,采用时间片轮转的方式,为第一进程分配了2个时间片。第一进程在时间槽4内的CPU使用率为20%。由于在时间槽4内,降低了第一进程(异常高负载后台进程)的CPU使用率,CPU负载降低。在时间槽5开始时,获取CPU当前负载为18%,小于目标CPU负载;确定在时间槽5内休眠时长为第三休眠时长,等于时间槽4内的休眠时长。
在一种实现方式中,CPU确定每个时间槽内的运行时长和休眠时长后,在运行时长内按照CPU调度规则(比如时间片轮转)为第一进程分配CPU资源;在休眠时长内不为第一进程分配CPU资源。
在一种实现方式中,如图12所示,CPU向第一进程发送启动运行指令后,第一进程根据启动运行指令开始运行,可以被CPU调度。第一运行时长后,CPU向第一进程发送暂停运行指令,第一进程根据暂停运行指令开始休眠。第一休眠时长后,CPU向第一进程发送启动运行指令,第一进程根据启动运行指令开始运行,可以被CPU调度。第二运行时长后,CPU向第一进程发送暂停运行指令,第一进程根据暂停运行指令开始休眠。第二休眠时长后,CPU向第一进程发送启动运行指令,第一进程根据启动运行指令开始运行,可以被CPU调度。第三运行时长后,CPU向第一进程发送暂停运行指令,第一进程根据暂停运行指令开始休眠。第三休眠时长后,CPU向第一进程发送启动运行指令,第一进程根据启动运行指令开始运行,可以被CPU调度。这样,第一进程周期性地休眠。
本申请实施例提供的功耗控制方法,检测到后台进程异常高负载,则降低该后台进程的CPU使用率,从而降低CPU负载,解决后台进程高负载带来的电子设备使用卡顿、掉电快、易发热等问题。
在一示例中,如图13A所示,不采用本申请实施例提供的功耗控制方法时(优化前),后台进程异常高负载导致CPU负载保持在较高值(40%左右),CPU温度由31.5℃上升至36.5℃。采用本申请实施例提供的功耗控制方法后(优化后),后台进程占用CPU的时长降低,CPU负载降低至20%左右,CPU温度下降至33℃。
在另一示例中,如图13B所示,由于存在异常高负载的后台进程,17:45分之前,CPU整体负载较高。采用本申请实施例提供的功耗控制方法后,CPU整体负载由86%下降至56%,小核CPU频点和中核CPU频点都显著下降。由于存在前台应用,大核CPU频点基本保持不变。
可以理解的是,本申请实施例提供的电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请实施例的范围。
本申请实施例可以根据上述方法示例对上述电子设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在一种示例中,请参考图14,其示出了上述实施例中所涉及的电子设备的一种可能的结构示意图。该电子设备1400包括:处理单元1410和存储单元1420。
其中,处理单元1410,用于对电子设备1400的动作进行控制管理。存储单元1420用于保存电子设备1400的程序代码和数据,处理单元1410调用存储单元1420存储的程序代码,以执行以上方法实施例中的各个步骤。
当然,上述电子设备1400中的单元模块包括但不限于上述处理单元1410和存储 单元1420。例如,电子设备1400中还可以包括显示单元、电源单元等。显示单元用于显示电子设备1400的显示界面;电源单元用于对电子设备1400供电。
其中,处理单元1410可以是处理器或控制器,例如可以是中央处理器(central processing unit,CPU),数字信号处理器(digital signal processor,DSP),专用集成电路(application-specific integrated circuit,ASIC),现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。存储单元1420可以是存储器。显示单元可以是显示屏等。
例如,处理单元1410为处理器(如图2A所示的处理器110),存储单元1420可以为存储器(如图2A所示的内部存储器121),显示单元可以为显示屏(如图2A所示的显示屏190)。本申请实施例所提供的电子设备1400可以为图2A所示的电子设备100。其中,上述处理器、存储器、显示屏等可以连接在一起,例如通过总线连接。处理器调用存储器存储的程序代码,以执行以上方法实施例中的各个步骤。
本申请实施例还提供一种芯片系统,该芯片系统包括至少一个处理器和至少一个接口电路。处理器和接口电路可通过线路互联。例如,接口电路可用于从其它装置(例如电子设备的存储器)接收信号。又例如,接口电路可用于向其它装置(例如处理器)发送信号。示例性的,接口电路可读取存储器中存储的指令,并将该指令发送给处理器。当所述指令被处理器执行时,可使得电子设备执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令,当所述计算机指令在上述电子设备上运行时,使得该电子设备执行上述方法实施例中手机执行的各个功能或者步骤。
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行上述方法实施例中手机执行的各个功能或者步骤。
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成 的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (14)

  1. 一种功耗控制方法,应用于电子设备,其特征在于,所述电子设备包括处理器,所述处理器上运行有第一进程,所述第一进程对应的第一应用在所述电子设备后台运行,所述方法包括:
    检测到所述第一进程的负载高于预设负载阈值、且运行时长大于或等于预设时长阈值;
    确定所述第一应用的运行不被用户感知;
    降低所述第一进程的处理器使用率。
  2. 根据权利要求1所述的方法,其特征在于,降低所述第一进程的处理器使用率之前,所述方法还包括:
    确定所述电子设备满足预设的异常条件;
    其中,所述异常条件包括下列至少一项:
    电子设备的处理器温度大于预设温度阈值;
    电子设备的电池电量在预设时长内下降的值大于预设电量阈值;
    电子设备上运行的前台应用运行卡顿。
  3. 根据权利要求1或2所述的方法,其特征在于,所述降低所述第一进程的处理器使用率包括:
    控制所述第一进程周期性地休眠;在所述第一进程休眠时,所述第一进程未使用处理器资源。
  4. 根据权利要求3所述的方法,其特征在于,每个休眠周期内包括第一进程的运行时间和休眠时间;在第一进程的运行时间内,所述第一进程根据处理器的调度使用处理器资源。
  5. 根据权利要求3或4所述的方法,其特征在于,
    所述第一进程在每个休眠周期内的休眠时间相等,所述休眠时间为预设值。
  6. 根据权利要求3或4所述的方法,其特征在于,所述方法还包括:
    根据处理器当前负载和预设的目标负载确定当前休眠周期内的休眠时间。
  7. 根据权利要求1或2所述的方法,其特征在于,所述降低所述第一进程的处理器使用率包括:
    降低所述第一进程的调度优先级,所述调度优先级用于指示进程被处理器分配处理器资源的顺序。
  8. 根据权利要求7所述的方法,其特征在于,所述降低所述第一进程的调度优先级包括:
    增大所述第一进程的调度优先级数值。
  9. 根据权利要求1或2所述的方法,其特征在于,所述降低所述第一进程的处理器使用率包括:
    降低所述第一进程的处理器使用率阈值。
  10. 根据权利要求1-9任意一项所述的方法,其特征在于,所述第一应用的运行不被用户感知包括:
    所述第一应用未进行音频输入或输出;并且,所述第一应用未通过移动通信或无线通信接收或发送数据。
  11. 根据权利要求1-10任意一项所述的方法,其特征在于,所述第一应用在所述电子设备后台运行包括:
    所述第一应用不存在人机交互界面;或,
    所述第一应用的人机交互界面停止在所述电子设备的屏幕上显示。
  12. 一种电子设备,其特征在于,所述电子设备包括:处理器和存储器;所述存储器与所述处理器耦合;所述存储器用于存储计算机程序代码;所述计算机程序代码包括计算机指令,当所述处理器执行上述计算机指令时,使得所述电子设备执行如权利要求1-11任意一项所述的方法。
  13. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1-11任意一项所述的方法。
  14. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1-11任意一项所述的方法。
PCT/CN2023/070110 2022-01-28 2023-01-03 一种功耗控制方法及装置 WO2023142906A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP23745791.6A EP4280060A1 (en) 2022-01-28 2023-01-03 Power consumption control method and apparatus
US18/548,037 US20240236863A9 (en) 2022-01-28 2023-01-03 Power Consumption Control Method and Apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210108275.1A CN116567132A (zh) 2022-01-28 2022-01-28 一种功耗控制方法及装置
CN202210108275.1 2022-01-28

Publications (1)

Publication Number Publication Date
WO2023142906A1 true WO2023142906A1 (zh) 2023-08-03

Family

ID=87470529

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/070110 WO2023142906A1 (zh) 2022-01-28 2023-01-03 一种功耗控制方法及装置

Country Status (3)

Country Link
EP (1) EP4280060A1 (zh)
CN (1) CN116567132A (zh)
WO (1) WO2023142906A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632521A (zh) * 2024-01-26 2024-03-01 中电云计算技术有限公司 后台任务的cpu利用率控制方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943570A (zh) * 2017-11-14 2018-04-20 广东欧珀移动通信有限公司 应用管理方法、装置、存储介质及电子设备
CN109213539A (zh) * 2016-09-27 2019-01-15 华为技术有限公司 一种内存回收方法及装置
US20190324814A1 (en) * 2018-04-20 2019-10-24 EMC IP Holding Company LLC Resource release method, resource allocation method, devices, and computer program products
CN111104209A (zh) * 2019-11-25 2020-05-05 华为技术有限公司 一种处理任务的方法及相关设备
CN111522425A (zh) * 2019-02-02 2020-08-11 华为技术有限公司 一种电子设备的功耗控制方法及电子设备
CN111666140A (zh) * 2020-05-28 2020-09-15 北京百度网讯科技有限公司 资源调度方法、装置、设备和存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201241640A (en) * 2011-02-14 2012-10-16 Microsoft Corp Dormant background applications on mobile devices
CN104199669B (zh) * 2014-09-12 2017-12-15 北京奇虎科技有限公司 对应用程序的进程进行管理的方法及装置
AU2017435232B2 (en) * 2017-10-13 2021-11-04 Huawei Technologies Co., Ltd. Method for reducing power consumption of terminal, and terminal
CN109992370A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN110018903A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 资源管理方法、装置、移动终端及计算机可读存储介质
CN110806926A (zh) * 2019-09-05 2020-02-18 华为技术有限公司 一种资源管控方法及设备
CN111077979B (zh) * 2019-12-09 2021-04-02 Oppo广东移动通信有限公司 功耗控制方法、存储介质及电子设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109213539A (zh) * 2016-09-27 2019-01-15 华为技术有限公司 一种内存回收方法及装置
CN107943570A (zh) * 2017-11-14 2018-04-20 广东欧珀移动通信有限公司 应用管理方法、装置、存储介质及电子设备
US20190324814A1 (en) * 2018-04-20 2019-10-24 EMC IP Holding Company LLC Resource release method, resource allocation method, devices, and computer program products
CN111522425A (zh) * 2019-02-02 2020-08-11 华为技术有限公司 一种电子设备的功耗控制方法及电子设备
CN111104209A (zh) * 2019-11-25 2020-05-05 华为技术有限公司 一种处理任务的方法及相关设备
CN111666140A (zh) * 2020-05-28 2020-09-15 北京百度网讯科技有限公司 资源调度方法、装置、设备和存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632521A (zh) * 2024-01-26 2024-03-01 中电云计算技术有限公司 后台任务的cpu利用率控制方法、装置、设备及存储介质
CN117632521B (zh) * 2024-01-26 2024-05-03 中电云计算技术有限公司 后台任务的cpu利用率控制方法、装置、设备及存储介质

Also Published As

Publication number Publication date
EP4280060A1 (en) 2023-11-22
CN116567132A (zh) 2023-08-08
US20240137870A1 (en) 2024-04-25

Similar Documents

Publication Publication Date Title
WO2020191685A1 (zh) 一种应用于终端的频率调整方法、装置及电子设备
US11573829B2 (en) Task processing method and apparatus, terminal, and computer readable storage medium
WO2021208627A1 (zh) 一种任务调度方法、装置及电子设备
WO2022199509A1 (zh) 应用执行绘制操作的方法及电子设备
EP4130969B1 (en) Method and device for adjusting memory configuration parameter
WO2021052070A1 (zh) 一种帧率识别方法及电子设备
CN116680153B (zh) 应用帧率平滑方法、电子设备及存储介质
CN115292052B (zh) 内存回收方法、电子设备及计算机可读存储介质
US20230370972A1 (en) Always on Display Method, Terminal Device, and Chip
WO2022017474A1 (zh) 任务处理方法及相关装置
CN117130773B (zh) 资源分配方法、装置和设备
WO2023142906A1 (zh) 一种功耗控制方法及装置
WO2021057472A1 (zh) 一种显示控制方法与电子设备
CN115333941B (zh) 获取应用运行情况的方法及相关设备
WO2024046088A1 (zh) 任务调度方法及相关设备
CN111104209B (zh) 一种处理任务的方法及相关设备
US20240236863A9 (en) Power Consumption Control Method and Apparatus
CN116700913A (zh) 嵌入式文件系统的调度方法、设备及存储介质
WO2024007970A1 (zh) 线程调度方法及电子设备
CN116055443B (zh) 识别社交场景的方法、电子设备及计算机可读存储介质
WO2023051056A1 (zh) 内存管理方法、电子设备、计算机存储介质和程序产品
WO2024087840A1 (zh) 资源管控方法、装置、芯片、电子设备及介质
CN116703691B (zh) 图像处理方法、电子设备及计算机存储介质
WO2023051036A1 (zh) 加载着色器的方法和装置
CN116684521B (zh) 音频处理方法、设备及存储介质

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2023745791

Country of ref document: EP

Effective date: 20230816

WWE Wipo information: entry into national phase

Ref document number: 18548037

Country of ref document: US

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

Ref document number: 23745791

Country of ref document: EP

Kind code of ref document: A1