WO2024087840A1 - 资源管控方法、装置、芯片、电子设备及介质 - Google Patents

资源管控方法、装置、芯片、电子设备及介质 Download PDF

Info

Publication number
WO2024087840A1
WO2024087840A1 PCT/CN2023/114758 CN2023114758W WO2024087840A1 WO 2024087840 A1 WO2024087840 A1 WO 2024087840A1 CN 2023114758 W CN2023114758 W CN 2023114758W WO 2024087840 A1 WO2024087840 A1 WO 2024087840A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
electronic device
thread
resources
application
Prior art date
Application number
PCT/CN2023/114758
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 荣耀终端有限公司
Publication of WO2024087840A1 publication Critical patent/WO2024087840A1/zh

Links

Classifications

    • 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
    • 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
    • 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
    • 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]
    • 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 technical field of electronic equipment, and in particular to a resource management method, device, chip, electronic equipment and medium.
  • An electronic device can run one or more tasks. When multiple tasks are run, each task can compete for the resources of the electronic device.
  • the resources of the electronic device are limited, so it is necessary to provide a resource management method.
  • the embodiments of the present application provide a resource management method, device, chip, electronic device and medium, which can manage the device resources that can be occupied by a task.
  • an embodiment of the present application provides a resource management method, which is applied to an electronic device, the method comprising: in response to a first operation, running a first application, wherein a first thread and a second thread are running during the running of the first application, the first thread is a thread for responding to operations using the first application, and the second thread is a thread not for responding to operations using the first application; determining the occupation of device resources of the electronic device by the first thread as a first occupation, and determining the occupation of device resources of the electronic device by the second thread as a second occupation, wherein the first occupation is greater than the second occupation; allocating device resources of the electronic device to the first thread based on the first occupation, and allocating device resources of the electronic device to the second thread based on the second occupation.
  • the first thread may be a thread that responds to (or is capable of responding to) a use operation of the first application
  • the second thread may be a thread that does not respond to a use operation of the first application
  • the resource control method provided in this embodiment helps electronic devices respond to user operations in a timely manner by allocating more device resources to key threads, thereby helping to improve user experience.
  • the first application is any application installed on the electronic device; the first thread includes at least one of a user interface thread, a rendering thread, and an animation effect thread.
  • the first application is any small program loaded by the electronic device; the first thread includes a thread of the web page illustration class.
  • the second thread comprises a background thread.
  • an embodiment of the present application provides a resource management method, which is applied to an electronic device, the method comprising: in response to a first operation, loading a first applet, wherein a first thread and a second thread are running in the process of loading the first applet, the first thread is a thread used to load the first applet, and the second thread is a thread not used to load the first applet; determining the occupation of device resources of the electronic device by the first thread as a first occupation, and determining the occupation of device resources of the electronic device by the second thread as a second occupation, wherein the first occupation is greater than the second occupation; allocating device resources of the electronic device to the first thread based on the first occupation, and allocating device resources of the electronic device to the second thread based on the second occupation.
  • the second thread may be another thread in the first applet other than the thread used to load the first applet.
  • the resource management method provided in this embodiment helps electronic devices to quickly load mini-programs by allocating more device resources to key threads, thereby helping to improve user experience.
  • an embodiment of the present application provides a resource management method, which is applied to an electronic device, the method comprising: in response to a first operation, starting a first application installed on the electronic device, wherein a first thread and a second thread are running in the process of starting the first application, the first thread is a thread used to start the first application, and the second thread is a thread not used to start the first application; determining the occupation of device resources of the electronic device by the first thread as a first occupation, and determining the occupation of device resources of the electronic device by the second thread as a second occupation, wherein the first occupation is greater than the second occupation; allocating device resources of the electronic device to the first thread based on the first occupation, and allocating device resources of the electronic device to the second thread based on the second occupation.
  • the second thread may be another thread in the first application other than the thread used to start the first application.
  • the resource control method provided in this embodiment provides a resource control method for key tasks. Allocating more device resources helps electronic devices launch applications in a timely manner, thereby helping to improve user experience.
  • an embodiment of the present application provides a resource management method, the method comprising: obtaining first information of a first task in an electronic device, and obtaining second information of a second task in the electronic device, wherein the first information is used to describe the criticality of the first task, and the second information is used to describe the criticality of the second task, and the criticality of the first task is higher than the criticality of the second task; determining a first occupancy of device resources of the electronic device by the first task based on the first information, and determining a second occupancy of device resources of the electronic device by the second task based on the second information, wherein the first occupancy is greater than the second occupancy; allocating device resources of the electronic device to the first task based on the first occupancy, and allocating device resources of the electronic device to the second task based on the second occupancy.
  • resource management is performed to manage the device resources that can be occupied by different tasks, so as to control the use of device resources when different tasks are running. More device resources can be allocated to critical tasks, and fewer device resources can be allocated to non-critical tasks. This can avoid the situation where there are too many critical tasks in the waiting state, improve the response rate of critical tasks, and enhance the user experience of electronic devices.
  • the first task when a first application installed on the electronic device is in operation, the first task includes a task for responding to a first operation, the first operation is an operation of using the first application, and the second task includes a task not for responding to the first operation.
  • the resource management method provided in this embodiment helps electronic devices respond to user operations in a timely manner by allocating more device resources to key tasks, thereby helping to improve user experience.
  • the first task includes a task for loading the second application
  • the second task includes a task not for loading the second application
  • the resource management method provided in this embodiment helps electronic devices to quickly load mini-programs by allocating more device resources to key tasks, thereby helping to improve user experience.
  • the first task when a third application loaded by the electronic device is in operation, the first task includes a task for responding to a second operation, the second operation is an operation of using the third application, and the second task includes a task not for responding to the second operation.
  • the resource management method provided in this embodiment helps electronic devices respond to user operations in a timely manner by allocating more device resources to key tasks, thereby helping to improve user experience.
  • the first task includes a task for launching the fourth application
  • the second task includes a task not for launching the fourth application.
  • the resource management method provided in this embodiment helps the electronic device to start the application in a timely manner by allocating more device resources to key tasks, thereby helping to improve the user experience.
  • the resource management method also includes: controlling the total usage of device resources of the electronic device when the subtasks in the first task are running, so that the total usage of device resources of the electronic device when the subtasks in the first task are running does not exceed the amount of device resources allocated to the first task, and controlling the total usage of device resources of the electronic device when the subtasks in the second task are running, so that the total usage of device resources of the electronic device when the subtasks in the second task are running does not exceed the amount of device resources allocated to the second task.
  • the amount of equipment resources for tasks within the task group can be uniformly limited, making it easier to uniformly control resources for tasks of the same criticality.
  • equipment resources can be left for more critical task groups to use, thereby improving the response efficiency of more critical tasks.
  • the step of allocating the device resources of the electronic device to the first task according to the first occupancy, and allocating the device resources of the electronic device to the second task according to the second occupancy may include: allocating the running time within the unit scheduling window to the first task according to the first occupancy, and allocating the running time within the unit scheduling window to the second task according to the second occupancy, wherein the running time within the unit scheduling window allocated to the first task is greater than the running time within the unit scheduling window allocated to the second task;
  • the resource management method also includes: when the running time of the first task in the current unit scheduling window reaches the running time in the unit scheduling window allocated to the first task, releasing the device resources of the electronic device used when the first task is running in the current unit scheduling window; and when the running time of the second task in the current unit scheduling window reaches the running time in the unit scheduling window allocated to the second task, releasing the device resources of the electronic device used when the second task is running in the current unit scheduling window.
  • the response of each task in the electronic device can be made more balanced, and some tasks can be prevented from being in the waiting state for a long time.
  • the resource management method further includes: detecting a load of the electronic device; and executing a step of acquiring first information of a first task in the electronic device when it is detected that the load of the electronic device reaches a preset load threshold.
  • the first task is a task group including one or more subtasks
  • the second task is a task group including one or more subtasks
  • the resource management method also includes: performing task management operations according to a task management request; wherein the task management operations include: one or more of the operations of setting first information, setting second information, deleting the first task, deleting the second task, deleting any subtask in the first task, deleting any subtask in the second task, adding a subtask to the first task, adding a subtask to the second task, and adding a third task including one or more subtasks.
  • tasks can be grouped in accordance with actual application requirements, supporting on-demand resource management and control.
  • an embodiment of the present application provides an electronic device, comprising a memory for storing computer program instructions, a processor for executing the computer program instructions, and a communication device, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute a method as described in any one of the first aspects.
  • an embodiment of the present application provides a chip, comprising: a processor, which is used to execute computer program instructions stored in a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute any method as in the first aspect.
  • an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored.
  • the computer-readable storage medium is run on a computer, the computer executes any method in the first aspect.
  • an embodiment of the present application provides a computer program product, which includes a computer program.
  • the computer program When the computer program is run on a computer, the computer executes any method in the first aspect.
  • the embodiment of the present application can manage and control the device resources that can be occupied by the task.
  • FIG1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application.
  • FIG2 is a schematic diagram of the operation of a key task in a system when the system load is high and resource control is not performed according to an embodiment of the present application;
  • FIG3 is a schematic diagram of the operation of another key task in the system when the system load is high and resource control is not performed according to an embodiment of the present application;
  • FIG4 is a schematic diagram of a process flow of a resource management method provided by an embodiment of the present application.
  • FIG5 is a schematic diagram of an operation status of a non-critical task that is restricted from running according to an embodiment of the present application
  • FIG6 is a schematic diagram of a group load control system provided by an embodiment of the present application.
  • At least one of a, b and c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c can be single or multiple.
  • first, second, etc. may be used to describe the set thresholds in the embodiments of the present application, these set thresholds are not Should be limited to these terms. These terms are only used to distinguish the set thresholds from each other.
  • the first set threshold may also be referred to as the second set threshold, and similarly, the second set threshold may also be referred to as the first set threshold.
  • Fig. 1 shows a schematic diagram of the structure of the electronic device 100.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present application 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 some components, or split some components, or arrange the components differently.
  • the components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc.
  • AP application processor
  • GPU graphics processor
  • ISP image signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • Different processing units may be independent devices or integrated in one or more processors.
  • the controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
  • the processor 110 may also be provided with a memory for storing instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (SIM) interface, and/or a universal serial bus (USB) interface, etc.
  • I2C inter-integrated circuit
  • I2S inter-integrated circuit sound
  • PCM pulse code modulation
  • UART universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the USB interface 130 is an interface that complies with the USB standard specification, and can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the charging management module 140 is used to receive charging input from the charger.
  • the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
  • the wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
  • Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas.
  • antenna 1 can be reused as a diversity antenna for a wireless local area network.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 150 can provide solutions for wireless communications including 2G/3G/4G/5G, etc., applied to the electronic device 100.
  • the mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and transmit it to the antenna 1 for demodulation.
  • at least some functional modules of the mobile communication module 150 may be disposed in the processor 110.
  • at least some functional modules of the mobile communication module 150 may be disposed in the same device as at least some modules of the processor 110.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194.
  • the modem processor may be an independent device.
  • the modem processor may be independent of 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 communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) and the like applied to the electronic device 100.
  • WLAN wireless local area networks
  • BT wireless fidelity
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication
  • IR infrared
  • the wireless communication module 160 can be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering processing, and sends the processed signal to the processor 110.
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify the signal, and convert it into electromagnetic waves for radiation through the antenna 2.
  • 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 (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, and/or IR technology.
  • the GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and/or a satellite based augmentation system (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation system
  • the electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor.
  • the GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos, etc.
  • the display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diodes (QLED), etc.
  • the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
  • the electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
  • the ISP is used to process data fed back by the camera 193.
  • the camera 193 is used to capture static images or videos.
  • the object generates an optical image through the lens and projects it onto the photosensitive element.
  • the digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
  • Video codecs are used to compress or decompress digital videos.
  • the electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
  • MPEG Moving Picture Experts Group
  • MPEG2 MPEG2, MPEG3, MPEG4, etc.
  • NPU is a neural-network (NN) computing processor. It can quickly process input information by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, and can also continuously self-learn.
  • NN neural-network
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
  • the external memory card communicates with the processor 110 via the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
  • the internal memory 121 can be used to store computer executable program codes, which include instructions.
  • the internal memory 121 may include a program storage area and a data storage area.
  • the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.
  • the data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc.
  • 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 disk storage device, a flash memory device, a universal flash storage (UFS), etc.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
  • the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the pressure sensor 180A can be set on the display screen 194.
  • the capacitive pressure sensor can be a parallel plate including at least two conductive materials.
  • the electronic device 100 determines the intensity of the pressure according to the change in capacitance.
  • the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A.
  • the electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A.
  • touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
  • the gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100.
  • the air pressure sensor 180C is used to measure air pressure.
  • the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes).
  • the distance sensor 180F is used to measure the distance.
  • the electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focus.
  • the proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode.
  • the ambient light sensor 180L is used to sense the brightness of ambient light.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc.
  • the temperature sensor 180J is used to detect temperature.
  • the touch sensor 180K is also called a "touch control device”.
  • the touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen”.
  • the touch sensor 180K is used to detect touch operations acting on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to the touch operation can be provided through the display screen 194.
  • the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195.
  • the electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 can also be compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications.
  • the electronic device 100 uses an eSIM, i.e., an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
  • the software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture.
  • One or more tasks may be executed in an electronic device.
  • a task executed in an electronic device may be, for example, a process or a thread. Both a process and a thread may be used as the minimum execution unit of a task.
  • the electronic device when an electronic device runs an installed application, the electronic device can display the interface of the application. When the user performs operations such as clicking or sliding on the displayed content of the interface, the electronic device can execute a task to respond to the operation performed by the user, which is a task related to the user's response. While running the application, the electronic device can also execute tasks unrelated to the user's response. For example, background tasks of electronic devices.
  • each task can compete for the limited resources of the electronic device, and the probability of different tasks competing for device resources can be the same.
  • the device resources that different tasks compete for may be hardware resources of electronic devices, such as CPU (central processing unit), GPU (graphics processing unit), memory, etc.
  • each task in the system competes for the CPU resources of the electronic device, and relatively important (or critical) tasks in the system (such as tasks related to user response, etc.) will inevitably have more waiting to be run (such as recorded as runnable state), resulting in a longer response delay for relatively important tasks.
  • Relatively critical tasks can be recorded as critical tasks, and other tasks can be recorded as non-critical tasks. The criticality of critical tasks is higher than that of non-critical tasks.
  • Figure 2 shows the operation of a key task in the system when the system load is high and no resource control is performed
  • Figure 3 shows the operation of another key task in the system when the system load is high and no resource control is performed.
  • the horizontal axes of Figures 2 and 3 can represent changes in time.
  • a task may also exist in other possible states during the running process, such as the dormant state (eg, which can be recorded as the sleep state) of always waiting for device resources as shown in FIG. 3 .
  • the dormant state eg, which can be recorded as the sleep state
  • the system load or background load
  • the higher the power consumption of the electronic device the higher the power consumption of the electronic device, and the shorter the time that the electronic device can be used on a single charge. That is, it can be considered that the system load has a greater impact on the dynamic power consumption model.
  • Scenario 1 Application running scenario
  • the application can be pre-installed on the electronic device.
  • the mobile phone can display the interface of the running application.
  • the user can view the content displayed on the interface and perform operations such as clicking and sliding on the content displayed on the interface of the application as needed through the touch screen of the mobile phone.
  • the electronic device can perform tasks for responding to the operations performed by the user.
  • the mobile phone can also perform background tasks and other tasks that are not related to the user response. Each task running in the mobile phone can compete for the CPU resources of the mobile phone.
  • tasks related to user response can be regarded as critical tasks, and tasks unrelated to user response, such as background tasks, can be regarded as non-critical tasks.
  • the critical task may include a thread that responds to the use operation of the application
  • the non-critical task may include a thread that does not respond to the use operation of the application.
  • the key tasks performed by the electronic device may include: UI (User Interface) thread, Render thread, animation effect thread, etc. which are most directly related to user response.
  • a feasible resource management process may be: the electronic device runs the application in response to an operation performed by a user to request the running of an application installed on the electronic device.
  • the electronic device may run a critical thread for responding to the operation of using the application, and a non-critical thread that is not used to respond to the operation of using the application.
  • the electronic device may determine the occupation of the CPU resources of the electronic device by the critical thread and the occupation of the CPU resources of the electronic device by the non-critical thread, and the occupation of the CPU resources of the electronic device by the critical thread is greater than the occupation of the CPU resources of the electronic device by the non-critical thread, so as to allocate more CPU resources to the critical thread. Based on the determined occupation, the electronic device may allocate CPU resources to the critical thread and the non-critical thread.
  • the user's operation of using the application program may include click operation, slide operation, etc.
  • the key threads in scene 1 may include a user interface thread, a rendering thread, and an animation effect thread
  • the non-key threads in scene 1 may include background threads.
  • background threads may include a garbage collection thread.
  • allocating more device resources to key threads helps electronic devices respond to user operations in a timely manner, thereby helping to improve user experience.
  • the electronic device can load an application program, and the loaded application program can be a small application program (or mini program) that is not installed on the electronic device.
  • a mini program is an application program that can be used without downloading and installing.
  • the mobile phone in order to load the applet, can execute a task for loading and parsing the applet. In the process of loading the applet, the mobile phone can also execute other tasks unrelated to loading and parsing the applet. In one embodiment, the tasks unrelated to loading and parsing the applet can include background tasks. Each task running in the mobile phone can compete for the CPU resources of the mobile phone.
  • the task for loading and parsing the mini-program can be regarded as a critical task, and other tasks unrelated to loading the mini-program can be regarded as non-critical tasks.
  • the non-critical tasks may include other threads in the applet other than the thread used to load the applet.
  • the key tasks performed by the electronic device may include: a thread responsible for program loading and parsing.
  • a feasible resource management process may be: the electronic device may first load the applet in response to an operation performed by a user to request the running of the applet. In the process of loading the applet, the electronic device may run a critical thread for loading the first applet and a non-critical thread that is not used to load the first applet. The electronic device may determine the amount of device resources occupied by the critical thread and the amount of device resources occupied by the non-critical thread, and the amount of device resources occupied by the critical thread is greater than the amount of device resources occupied by the non-critical thread, so as to allocate more device resources to the critical thread. Based on the determined occupancy, the electronic device may allocate device resources to the critical thread and the non-critical thread.
  • the critical thread in scenario 2 may include a thread responsible for program loading and parsing, and the non-critical thread in scenario 2 may include a background thread.
  • allocating more device resources to key threads helps electronic devices load the mini program quickly, thereby helping to improve the user experience.
  • An electronic device can load a mini-program, and after loading the mini-program, it can run the mini-program.
  • a mobile phone can display the interface of the running mini-program. The user can view the content displayed on the interface and can use the touch screen of the mobile phone to perform operations such as clicking and sliding on the content displayed on the mini-program interface as needed.
  • An electronic device can perform tasks to respond to operations performed by the user. While running the mini-program, the mobile phone can also perform tasks unrelated to the user response. In one embodiment, tasks unrelated to the user response may include background tasks. Each task running in the mobile phone can compete for the CPU resources of the mobile phone.
  • tasks related to user response can be regarded as key tasks, and tasks unrelated to user response can be regarded as non-key tasks.
  • the critical tasks may include threads that respond to the use operations of the mini program
  • the non-critical tasks may include threads that do not respond to the use operations of the mini program.
  • the key tasks performed by the electronic device may include: threads of the webview (web page view) class that are most directly related to user responses, etc.
  • a feasible resource management process may be: in response to the operation performed by the user to request the running of the applet, the electronic device may first load the applet and then run the loaded applet. During the running of the applet, the electronic device may run a critical thread for responding to the use operation of the applet, and a non-critical thread that is not used to respond to the use operation of the applet. The electronic device may determine the occupancy of the CPU resources of the electronic device by the critical thread and the occupancy of the CPU resources of the electronic device by the non-critical thread, and the occupancy of the CPU resources of the electronic device by the critical thread is greater than the occupancy of the CPU resources of the electronic device by the non-critical thread, so as to allocate more CPU resources to the critical thread. Based on the determined occupancy, the electronic device may allocate CPU resources to the critical thread and the non-critical thread.
  • the critical thread in scene 3 can include threads of the webview class, and the non-critical thread in scene 3 can include background threads.
  • allocating more device resources to key threads helps electronic devices respond to user operations in a timely manner, thereby helping to improve the user experience.
  • the application program may be pre-installed on the electronic device.
  • the electronic device may start the application program.
  • the mobile phone can execute a task for launching the application while launching the installed application.
  • the mobile phone can execute a task for displaying the launch animation.
  • the mobile phone can also execute tasks unrelated to the launch of the application.
  • the tasks unrelated to the launch of the application can include background tasks.
  • Each task running in the mobile phone can compete for the CPU resources of the mobile phone.
  • the task used to start the application can be regarded as a critical task, and the task unrelated to starting the application can be regarded as a non-critical task.
  • non-critical tasks can include other threads in the application besides the thread used to start the application.
  • the key tasks performed by the electronic device may include: a launcher thread and a thread for displaying startup animation effects.
  • Launcher is a desktop launcher in the Android system.
  • a feasible resource management process may be: the electronic device may start the application in response to an operation performed by a user to request the running of an application installed on the electronic device.
  • the electronic device may run a critical thread for starting the application and a non-critical thread that is not used to start the application.
  • the electronic device may determine the amount of device resources occupied by the critical thread and the amount of device resources occupied by the non-critical thread, and the amount of device resources occupied by the critical thread is greater than the amount of device resources occupied by the non-critical thread, so as to allocate more device resources to the critical thread.
  • the electronic device may allocate device resources to the critical thread and the non-critical thread.
  • the key threads in scene 4 may include a launcher thread and a thread for displaying startup animation effects, and the non-key threads in scene 4 may include a background thread.
  • An embodiment of the present application provides a resource management method, which can be applied to an electronic device, and the method may include: in response to a first operation, running a first application, wherein a first thread and a second thread are running during the running of the first application, the first thread is a thread for responding to the use operation of the first application, and the second thread is a thread not for responding to the use operation of the first application; determining the occupation of the device resources of the electronic device by the first thread as a first occupation, and determining the occupation of the device resources of the electronic device by the second thread as a second occupation, wherein the first occupation is greater than the second occupation; allocating the device resources of the electronic device to the first thread based on the first occupation, and allocating the device resources of the electronic device to the second thread based on the second occupation.
  • This embodiment can be applied to the above-mentioned scenarios 1 and 3.
  • the first application is any application installed on the electronic device; the first thread includes at least one of a user interface thread, a rendering thread, and an animation effect thread.
  • the first application is any small program loaded by the electronic device; the first thread includes a thread of the web page illustration class.
  • the second thread comprises a background thread.
  • the resource control method provided in this embodiment helps electronic devices respond to user operations in a timely manner by allocating more device resources to key threads, thereby helping to improve user experience.
  • An embodiment of the present application provides a resource management method, which can be applied to an electronic device, and the method may include: in response to a first operation, loading a first applet, wherein a first thread and a second thread are running in the process of loading the first applet, the first thread is a thread for loading the first applet, and the second thread is a thread not used to load the first applet; determining that the occupation of the device resources of the electronic device by the first thread is a first occupation, and determining that the occupation of the device resources of the electronic device by the second thread is a second occupation, wherein the first occupation is greater than the second occupation; allocating the device resources of the electronic device to the first thread based on the first occupation, and allocating the device resources of the electronic device to the second thread based on the second occupation.
  • This embodiment can be applied to the above scenario 2.
  • the resource management method provided in this embodiment helps electronic devices to quickly load mini-programs by allocating more device resources to key threads, thereby helping to improve user experience.
  • An embodiment of the present application provides a resource management method, which can be applied to an electronic device, and the method may include: in response to a first operation, starting a first application installed on the electronic device, wherein a first thread and a second thread are running in the process of starting the first application, the first thread is a thread used to start the first application, and the second thread is a thread not used to start the first application; determining that the occupation of the device resources of the electronic device by the first thread is a first occupation, and determining that the occupation of the device resources of the electronic device by the second thread is a second occupation, wherein the first occupation is greater than the second occupation; allocating the device resources of the electronic device to the first thread based on the first occupation, and allocating the device resources of the electronic device to the second thread based on the second occupation.
  • This embodiment can be applied to the above scenario 4.
  • a resource control method may include the following steps 401 to 403.
  • Step 401 obtaining first information of a first task in the electronic device, and obtaining second information of a second task in the electronic device, wherein the first information is used to describe the criticality of the first task, and the second information is used to describe the criticality of the second task, and the criticality of the first task is higher than the criticality of the second task.
  • One or more tasks may be executed in the electronic device.
  • the first task and the second task may be any two tasks with different criticalities executed in the electronic device.
  • the first task and the second task may also be any two task combinations with different criticalities executed in the electronic device, and a task combination may include at least one task. Both the first task and the second task may have corresponding criticalities.
  • resource control may be performed on one or more tasks in the electronic device, and both the first task and the second task may be tasks subject to resource control.
  • the criticality of the task can be determined in combination with human definition. In another embodiment, the criticality of the task can be determined based on the attributes of the task (such as whether it is an existing background task in the system). Among them, it can be determined that the background task is not critical or has a low criticality.
  • the criticality of tasks can be classified into critical and non-critical. For example, a set larger amount of equipment resources can be allocated to critical tasks, and a set smaller amount of equipment resources can be allocated to non-critical tasks.
  • the information used to describe the criticality of a task may be 0 or 1. When the information is 0, it may indicate that the task is not critical, and when the information is 1, it may indicate that the task is critical.
  • the criticality of a task may be a critical value.
  • the higher the critical value the higher the criticality.
  • the criticality of the task may be a criticality level.
  • the higher the criticality level the higher the criticality.
  • the criticality of a task may be within a critical range. For example, if the critical values of two tasks are different, but the critical values of the two tasks fall within the same critical range, then the criticality of the two tasks may be considered to be consistent (or equal or the same). In one embodiment, if the critical value is not greater than the upper limit of the critical range and not less than the lower limit of the critical range, then the critical value may be considered to fall within the critical range.
  • the first task may be a critical task
  • the second task may be a non-critical task
  • the first information can be used as a basis for determining the amount of equipment resources occupied by the first task
  • the second information can be used as a basis for determining the amount of equipment resources occupied by the second task.
  • Step 402 determine a first occupation of device resources of the electronic device by a first task according to first information, and determine a second occupation of device resources of the electronic device by a second task according to second information, wherein the first occupation is greater than the second occupation.
  • the amount of device resources occupied by the task may be determined according to the criticality of the task, so that device resources may be subsequently allocated to the task according to the amount of device resources occupied by the task.
  • the amount of equipment resources occupied by a task may be positively correlated with the criticality of the task, so that the amount of equipment resources allocated to the task is positively correlated with the criticality of the task.
  • the criticality of the task is higher, the more critical the task is, the higher the amount of equipment resources occupied by the task is, and more equipment resources are allocated to the task; if the criticality of the task is lower, the less critical the task is, the lower the amount of equipment resources occupied by the task is, and fewer equipment resources are allocated to the task.
  • the amount of equipment resources occupied by the first task is greater than that of the second task, so that relatively more equipment resources are allocated to the critical task and relatively fewer equipment resources are allocated to the non-critical task.
  • critical tasks such as tasks that are not critical or have a low degree of criticality
  • non-critical tasks such as tasks that are not critical or have a low degree of criticality
  • the upper limit of device resource usage can be higher for critical or mission-critical applications.
  • the criticality of other tasks in the electronic device can also be used to determine the occupation of the first task and the second task on the device resources, so as to allocate the device resources to the first task and the second task. In this way, it can be avoided that some tasks can use more device resources, while other tasks can use less device resources or even cannot use device resources, so as to support the balanced operation of multiple tasks.
  • the determined occupation of device resources by a task may be the number of CPUs.
  • a critical task may use a larger number of CPUs, while a non-critical task may use a smaller number of CPUs.
  • the determined occupation of device resources by a task may also be the maximum CPU bandwidth available to the task.
  • quotas and time periods may be used to specify the maximum CPU bandwidth allowed to be used by a task.
  • the units of quotas and time periods may be time, such as s (seconds) and ms (milliseconds).
  • the running time of a task is limited to 1 CPU.
  • the task can use at most 1 CPU every 500ms; in another example, if the period is 250ms and the quota is 500ms, the task can use at most 2 CPUs every 250ms; in another example, if the period is 500ms and the quota is 50ms, the task can use at most 10% of 1 CPU every 500ms.
  • the determined amount of device resource occupation by the task may be the duration of use of the device resource by the task.
  • the determined amount of device resource usage by a task may be the duration of device resource usage by the task in a unit scheduling window. In another embodiment, the determined amount of device resource usage by a task may be the duration of device resource usage in a non-unit scheduling window (e.g., a window with a variable window size).
  • a unit scheduling window can be used as a time period.
  • the time length of the unit scheduling window can be set as needed, for example, it can be set to 1s, 500ms, 250ms, 50ms, etc.
  • the task can be controlled to pause and release the device resources used by the task for use by other tasks.
  • allocating device resources to a task may include: allocating a running time (or running length) within a unit scheduling window to the task. For example, if the time length of a unit scheduling window is 1 second, the running time allocated to a non-critical task may be 100 ms within the unit scheduling window.
  • Step 403 Allocate device resources of the electronic device to the first task according to the first occupancy, and allocate device resources of the electronic device to the second task according to the second occupancy.
  • step 403 device resources may be allocated to the task according to the determined occupancy.
  • the device resources used when the task is running shall not exceed the device resources allocated to the task.
  • device resources may be allocated to the task by setting corresponding configuration information.
  • the number of CPUs that the task can use can be configured, and in another embodiment, the identifiers of the corresponding number of CPUs that the task can use can also be configured.
  • the operation of the task can be controlled according to the amount of the device resources allocated to the task, so that the usage of the device resources during the operation of the task does not exceed the allocated amount of device resources.
  • the resource management method may also include: step A, controlling the usage of device resources of the electronic device when the first task is running, so that the usage of device resources of the electronic device when the first task is running does not exceed the amount of device resources allocated to the first task, and controlling the usage of device resources of the electronic device when the second task is running, so that the usage of device resources of the electronic device when the second task is running does not exceed the amount of device resources allocated to the second task.
  • the amount of device resources that can be used when the task is running can be controlled according to the amount of device resources allocated to the task.
  • the device resources that can be used when the task is running shall not exceed the device resources allocated to the task.
  • the electronic device may forcibly control the task to pause running, and release the device resources used by the task for use by other tasks.
  • the task information may be configured accordingly so that if the usage of the device resources during the execution of the task reaches the amount of the device resources allocated to the task, the task may be automatically suspended.
  • step 403 may include: allocating running time to the first task according to the first occupancy, and allocating running time to the second task according to the second occupancy.
  • the resource management method may also include: when the running time of the first task reaches the running time allocated to the first task, releasing the device resources of the electronic device used when the first task is running, and when the running time of the second task reaches the running time allocated to the second task, releasing the device resources of the electronic device used when the second task is running.
  • the runtime allocated to a task may be positively correlated with the amount of device resources used when the task is running. The longer the task runtime is, the longer the device resources are used, and the more device resources are used. When the task runtime reaches the allocated runtime, the task is controlled to be suspended, and the device resources used by the task are released.
  • step 403 may include: allocating running time within the unit scheduling window to the first task according to the first occupancy, and allocating running time within the unit scheduling window to the second task according to the second occupancy, wherein the running time within the unit scheduling window allocated to the first task is greater than the running time within the unit scheduling window allocated to the second task.
  • the running time allocated to the first task is the running time within a unit scheduling window that allows the first task to run.
  • the resource management method also includes: when the running time of the first task within the current unit scheduling window reaches the running time within the unit scheduling window allocated to the first task, releasing the device resources of the electronic device used when the first task is running within the current unit scheduling window; and when the running time of the second task within the current unit scheduling window reaches the running time within the unit scheduling window allocated to the second task, releasing the device resources of the electronic device used when the second task is running within the current unit scheduling window.
  • the first task for each unit scheduling window that is performed in sequence, taking the first task as an example, it can be determined whether the running time of the first task in the current unit scheduling window reaches the running time allocated to the first task. If it is determined to be yes, the first task can be controlled to suspend running to be in a waiting state, and the equipment resources used by the first task can be released for use by other tasks in the current unit scheduling window. If it is determined to be no, there is no need to control the first task to suspend running, and the first task continues to run in the current unit scheduling window. Alternatively, the running time of the first task in the current unit scheduling window can be monitored. When it is detected that the running time reaches the running time allocated to the first task, the first task can be controlled to suspend running and the equipment resources used by the first task can be released.
  • the response of each task in the electronic device can be made more balanced, and some tasks can be prevented from being in the waiting state for a long time.
  • a schematic diagram of the operation of a non-critical task e.g., CFS.sh 325
  • CFS Comppletely Fair Scheduler
  • FIG5 the horizontal axis of FIG5 can represent the change of time.
  • non-critical tasks are in a waiting state waiting for CPU resources most of the time, and in a running state after obtaining CPU resources for a short period of time.
  • the running time of the non-critical task exceeds the set time value (such as the length of time the device resources are allocated to the non-critical task)
  • the CPU resources obtained by the non-critical task can be forcibly released, and the released CPU resources can be used by other tasks.
  • critical tasks in electronic devices can obtain more device resources faster, reducing the response time of critical tasks and the overall running process time, so that users can have a better performance experience.
  • One or more tasks may be run in the electronic device.
  • device resources may be allocated in units of tasks, that is, device resources may be allocated to each task in the electronic device respectively.
  • tasks in the electronic device may be grouped according to their criticality to obtain task groups (or groups, task groups), and device resources may be allocated in groups, that is, device resources may be allocated to each task group in the electronic device.
  • the existing non-critical background tasks of the system may be regarded as a task group by default, such as a background group (or background group), and the criticality of the background group may be marked as non-critical.
  • a new task group can be customized as needed. For example, a new task group including multiple non-critical tasks can be created, such as a low priority group, and the criticality of the low priority group is marked as non-critical. And a new task group including multiple critical tasks can be created, and the criticality of the task group can be marked as critical.
  • the criticality of any two task groups constructed may be different.
  • the constructed task groups may include at least two task groups with the same criticality.
  • the first task is a task group including one or more subtasks
  • the second task is a task group including one or more subtasks
  • the resource management method also includes: controlling the total usage of device resources of the electronic device when the subtasks in the first task are running, so that the total usage of device resources of the electronic device when the subtasks in the first task are running does not exceed the amount of device resources allocated to the first task, and controlling the total usage of device resources of the electronic device when the subtasks in the second task are running, so that the total usage of device resources of the electronic device when the subtasks in the second task are running does not exceed the amount of device resources allocated to the second task.
  • Each task in a task group can be a subtask of the task group.
  • the criticality of each task in the same task group is consistent, for example, they are all critical tasks, or the critical values of the tasks are the same, or the critical levels of the tasks are the same, or the critical values of the tasks fall into the same critical range.
  • the criticality of the task group can be consistent with the criticality of the tasks in the task group.
  • equipment resources are allocated to the tasks in the task group, and the equipment resources that can be used by the tasks in the task group are restricted.
  • the total amount of device resources that can be used by the tasks in the task group should not exceed the amount of device resources allocated to the task group. There may be no restrictions on the use of device resources by different tasks in the task group, for example, each task in the task group can compete for the device resources allocated to the task group.
  • the amount of equipment resources for tasks within the task group can be uniformly limited, making it easier to uniformly control resources for tasks of the same criticality.
  • equipment resources can be left for more critical task groups to use, thereby improving the response efficiency of more critical tasks.
  • the system of the electronic device is not always in a high load state.
  • resource management operations performed on the tasks (such as limiting the running time of the task group) will not help much to improve the performance of the electronic device system. Therefore, resource management can be performed on the tasks only when the system is in a high-load state, and no resource management can be performed on the tasks when the system is in a low-load state.
  • the resource management method may further include: detecting the load of the electronic device; executing the above step A only when it is detected that the load of the electronic device reaches a preset load threshold, otherwise the above step A is not executed.
  • the usage of device resources by a task can be directly controlled according to the amount of device resources allocated to the task when the device load is high, the amount of device resources allocated to the task can be updated periodically or in real time.
  • the resource management method further includes: detecting the load of the electronic device; and when it is detected that the load of the electronic device reaches a preset load threshold, executing the step of acquiring the first information of the first task in the electronic device. That is, step 401 is executed only when it is detected that the load of the electronic device reaches a preset load threshold, otherwise step 401 is not executed.
  • device resources can be allocated to the task first, and then the usage of the device resources by the task is controlled according to the amount of device resources allocated to the task. Therefore, there is no need to update the amount of device resources allocated to the task periodically or in real time.
  • the load of the electronic device (or system load) can be detected in real time or periodically. In one embodiment, the load of the electronic device can be the power consumed by the operation of the electronic device.
  • resource control is performed to limit the resources used by the task. If the threshold is not reached, resource control is not performed and the resources used by the task are not limited.
  • the load threshold may be set as needed, for example, based on empirical values.
  • device resource management can be started only when the device load is heavy.
  • more running time or time slices
  • less running time is allocated to tasks with lower criticality.
  • no running time is allocated to tasks, so that all tasks can run.
  • the first task is a task group including one or more subtasks
  • the second task is a task group including one or more subtasks
  • the resource management method also includes: performing a task management operation according to a task management request; wherein the task management operation includes: one or more of the following operations: setting first information, setting second information, deleting the first task, deleting the second task, deleting any subtask in the first task, deleting any subtask in the second task, adding a subtask to the first task, adding a subtask to the second task, and adding a third task including one or more subtasks. indivual.
  • the operation of setting the first information may be an operation of setting the first information for the first time.
  • the operation of setting the first information may also be an operation of updating the first information after the first information is set for the first time.
  • the above steps 401 to 403 can be performed again to update the amount of equipment resources occupied by the first task.
  • corresponding task management operations can be performed based on changes in the criticality of the task. For example, when the criticality of a task changes from critical to non-critical, the task can be transferred from the original critical group to another non-critical group. For another example, when the criticality of a task group changes, the setting of the criticality description information of the task group can be updated.
  • operations such as deleting tasks, adding tasks, deleting task groups, and adding new task groups can be performed based on actual application needs.
  • the first task when a first application installed on an electronic device is in operation, the first task includes a task for responding to a first operation, which is an operation of using the first application, and the second task includes a task not for responding to the first operation.
  • the resource control method provided by this embodiment helps the electronic device to respond to user operations in a timely manner by allocating more device resources to key tasks, thereby helping to improve the user experience.
  • the first task includes a task for loading the second application
  • the second task includes a task not for loading the second application
  • This embodiment can be applied to the above scenario 2.
  • the resource control method provided by this embodiment helps electronic devices to quickly load mini-programs by allocating more device resources to key tasks, thereby helping to improve user experience.
  • the first task when a third application loaded by the electronic device is in running state, the first task includes a task for responding to a second operation, the second operation is an operation of using the third application, and the second task includes a task not used to respond to the second operation.
  • This embodiment can be applied to the above scenario 3.
  • the resource control method provided by this embodiment helps the electronic device to respond to user operations in a timely manner by allocating more device resources to key tasks, thereby helping to improve the user experience.
  • the first task in the process of the electronic device launching a fourth application installed on the electronic device, includes a task for launching the fourth application, and the second task includes a task not for launching the fourth application.
  • This embodiment can be applied to the above scenario 4.
  • scenario 4 application startup scenario, compared with no resource control, the resource control method provided by this embodiment helps the electronic device to start the application in time by allocating more device resources to key tasks, thereby helping to improve the user experience.
  • the group load management and control system may include a real-time load monitoring module 601 , a control module 602 , and a group management module 603 .
  • the real-time load monitoring module 601 can monitor the load of the electronic device in real time.
  • the control module 602 can perform resource control on each task group in the electronic device, such as limiting the running time of the task group in the unit scheduling window. Among them, a longer running time can be allocated to the critical task group, and a shorter running time can be allocated to the non-critical task group.
  • the task group in the electronic device can be obtained by grouping the tasks in the electronic device, and the criticality of the tasks in the same task group is consistent.
  • the electronic device may include background groups, low priority groups and other groups.
  • the background group may include existing non-critical background tasks in the electronic device, which is the system default group.
  • the low priority group may include other non-critical tasks in the electronic device that are different from the background tasks, which is a new group for the system.
  • Other groups may be, for example, a task group, which may include critical tasks in the electronic device, which is a new group for the system.
  • the running time of background groups and low-priority groups can be limited to a shorter running time, and the running time of other groups can be limited to a longer running time.
  • the embodiment shown in FIG6 can utilize the existing non-critical default groups of the current system and newly created low-priority task groups and other groups, and limit the running time of the corresponding groups according to the criticality of the groups, so as to achieve the purpose of improving the system performance experience.
  • running time can be allocated to tasks according to their criticality, with more running time allocated to critical tasks and less running time allocated to less critical tasks. In this way, different tasks can be allocated running time that matches their critical programs.
  • Running different tasks at different runtimes not only ensures timely response of key tasks when the CPU load is high, but also usually makes the value of CPUutil smaller, which helps reduce CPU power consumption.
  • CPUutil can represent CPU utilization.
  • TaskrunningTime represents the normalized running time of the task
  • delta represents the time change value
  • curfreq represents the current operating frequency of the CPU
  • maxfreq represents the maximum operating frequency of the CPU
  • capacity represents the capacity corresponding to the maximum frequency of the CPU
  • cpuload represents the CPU load
  • util i.e., CPUutil
  • schedwindow represents the unit scheduling window
  • Freq represents the frequency (the frequency point to be adjusted to)
  • max represents the maximum utilization.
  • Freq may reflect the frequency at which the CPU is used.
  • the task running time within the unit scheduling window can be controlled.
  • the frequency can be reduced (the frequency calculation formula is shown in the above formulas (1) to (4)).
  • CPU power consumption is mainly affected by frequency, so limiting the running time of tasks within the unit scheduling window helps to reduce CPU power consumption. The lower the CPU power consumption, the longer the electronic device can be used on a single charge, and the smaller the impact of the CPU load on the dynamic power consumption model.
  • An embodiment of the present application also provides a chip, which is installed in an electronic device (UE), and the chip includes: a processor, which is used to execute computer program instructions stored in a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute the method steps provided by any method embodiment of the present application.
  • UE electronic device
  • An embodiment of the present application also proposes a terminal device, which includes a communication module, a memory for storing computer program instructions, and a processor for executing program instructions, wherein when the computer program instructions are executed by the processor, the terminal device is triggered to execute the method steps provided by any method embodiment of the present application.
  • An embodiment of the present application also proposes a server device, which includes a communication module, a memory for storing computer program instructions, and a processor for executing program instructions, wherein when the computer program instructions are executed by the processor, the server device is triggered to execute the method steps provided by any method embodiment of the present application.
  • An embodiment of the present application also provides an electronic device, which includes multiple antennas, a memory for storing computer program instructions, a processor for executing computer program instructions, and a communication device (such as a communication module that can implement 5G communication based on the NR protocol), wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method steps provided by any method embodiment of the present application.
  • a communication device such as a communication module that can implement 5G communication based on the NR protocol
  • one or more computer programs are stored in the above-mentioned memory, and the one or more computer programs include instructions.
  • the instructions are executed by the above-mentioned device, the above-mentioned device executes the method steps described in the embodiment of the present application.
  • the processor of the electronic device may be a system on chip (SOC). Chip), the processor may include a central processing unit (CPU), and may further include other types of processors. Specifically, in one embodiment of the present application, the processor of the electronic device may be a PWM control chip.
  • SOC system on chip
  • CPU central processing unit
  • PWM control chip PWM control chip
  • the processor involved may include, for example, a CPU, a DSP (digital signal processor) or a microcontroller, and may also include a GPU (graphics processing unit), an embedded neural network processor (Neural-network Process Units, NPU) and an image signal processor (Image Signal Processing, ISP).
  • the processor may also include necessary hardware accelerators or logic processing hardware circuits, such as ASIC, or one or more integrated circuits for controlling the execution of the program of the technical solution of the present application.
  • the processor may have the function of operating one or more software programs, and the software programs may be stored in a storage medium.
  • the memory of the electronic device can be a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or it can be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or it can also be any computer-readable medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.
  • ROM read-only memory
  • RAM random access memory
  • EEPROM electrically erasable programmable read-only memory
  • CD-ROM compact disc read-only memory
  • optical disc storage including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.
  • magnetic disk storage medium or other magnetic storage device
  • the processor and the memory can be combined into a processing device, more commonly, they are independent components, and the processor is used to execute the program code stored in the memory to implement the method described in the embodiment of the present application.
  • the memory can also be integrated into the processor, or independent of the processor.
  • the devices, apparatuses, and modules described in the embodiments of the present application may be implemented by computer chips or entities, or by products having certain functions.
  • the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
  • any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of the present application or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
  • a computer-readable storage medium is further provided, in which a computer program is stored.
  • the computer program When the computer program is run on a computer, the computer executes the method steps provided in the embodiment of the present application.
  • An embodiment of the present application further provides a computer program product, which includes a computer program.
  • a computer program product which includes a computer program.
  • the computer program When the computer program is run on a computer, the computer executes the method steps provided in the embodiment of the present application.
  • each flow process and/or box in the flow chart and/or block diagram and the combination of the flow chart and/or box in the flow chart and/or block diagram can be realized by computer program instructions.
  • These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart or multiple flows and/or one box or multiple boxes of the block diagram.
  • These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • the disclosed systems, devices and methods can be implemented in other ways.
  • the device embodiments described above are only illustrative, for example, the division of the units is only a logical function. In actual implementation, there may be other ways of division, for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not performed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, which may be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may 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, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
  • An integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium.
  • the above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
  • the terms “include”, “comprises” or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device.
  • an element defined by the sentence “includes a " does not exclude the presence of other identical elements in the process, method, commodity or device including the element.
  • the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • the present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network.
  • program modules may be located in local and remote computer storage media, including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例提供了一种资源管控方法、装置、芯片、电子设备及介质,该方法包括:获取电子设备中的第一任务的第一信息,以及获取电子设备中的第二任务的第二信息,第一信息用于描述第一任务的关键程度,第二信息用于描述第二任务的关键程度,第一任务的关键程度高于第二任务的关键程度;根据第一信息确定第一任务对电子设备的设备资源的第一占用量,以及根据第二信息确定第二任务对电子设备的设备资源的第二占用量,第一占用量大于第二占用量;根据第一占用量向第一任务分配电子设备的设备资源,以及根据第二占用量向第二任务分配电子设备的设备资源。本申请实施例能够对任务所能占用的设备资源进行管控。

Description

资源管控方法、装置、芯片、电子设备及介质
本发明要求于2022年10月26日提交中国国家知识产权局、申请号为202211320767.3、申请名称为“资源管控方法、装置、芯片、电子设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及电子设备技术领域,特别涉及一种资源管控方法、装置、芯片、电子设备及介质。
背景技术
电子设备中可以运行一个或者多个任务,运行多个任务时,各个任务均可以竞争电子设备的资源。电子设备的资源有限,有必要提供一种资源管控方法。
发明内容
本申请实施例提供了一种资源管控方法、装置、芯片、电子设备及介质,能够对任务所能占用的设备资源进行管控。
第一方面,本申请实施例提供一种资源管控方法,应用于电子设备,该方法包括:响应于第一操作,运行第一应用,其中,在第一应用的运行过程中运行有第一线程和第二线程,第一线程为用于响应对第一应用的使用操作的线程,第二线程为不用于响应对第一应用的使用操作的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。
第一线程可以是响应(或称能够响应)第一应用的使用操作的线程。第二线程可以是不响应第一应用的使用操作的线程。
在应用程序、小程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键线程分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
可选地,第一应用为电子设备上安装的任一应用;第一线程包括用户界面线程、渲染线程、动画效果线程中的至少一种。
可选地,第一应用为电子设备所加载的任一小程序;第一线程包括网页示图类的线程。
可选地,第二线程包括后台线程。
第二方面,本申请实施例提供一种资源管控方法,应用于电子设备,该方法包括:响应于第一操作,加载第一小程序,其中,在加载第一小程序的过程中运行有第一线程和第二线程,第一线程为用于加载第一小程序的线程,第二线程为不用于加载第一小程序的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。
第二线程可以是第一小程序中用于加载该第一小程序的线程之外的其他线程。
在小程序的加载场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键线程分配更多的设备资源,有助于电子设备快速加载小程序,从而有助于提升用户体验。
第三方面,本申请实施例提供一种资源管控方法,应用于电子设备,该方法包括:响应于第一操作,启动电子设备上安装的第一应用,其中,在启动第一应用的过程中运行有第一线程和第二线程,第一线程为用于启动第一应用的线程,第二线程为不用于启动第一应用的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。
第二线程可以是第一应用中用于启动第一应用的线程之外的其他线程。
在应用程序的启动场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务 分配更多的设备资源,有助于电子设备及时启动应用程序,从而有助于提升用户体验。
第四方面,本申请实施例提供一种资源管控方法,该方法包括:获取电子设备中的第一任务的第一信息,以及获取电子设备中的第二任务的第二信息,其中,第一信息用于描述第一任务的关键程度,第二信息用于描述第二任务的关键程度,第一任务的关键程度高于第二任务的关键程度;根据第一信息确定第一任务对电子设备的设备资源的第一占用量,以及根据第二信息确定第二任务对电子设备的设备资源的第二占用量,其中,第一占用量大于第二占用量;根据第一占用量向第一任务分配电子设备的设备资源,以及根据第二占用量向第二任务分配电子设备的设备资源。
基于电子设备的有限资源,通过进行资源管控,以对不同任务所能占用的设备资源进行管控,来控制不同任务运行时对设备资源的使用。可以为关键任务分配更多的设备资源,为不关键任务分配更少的设备资源。如此可以避免出现关键任务存在较多的待运行状态的情况,可以提升关键任务的响应速率,提升用户对电子设备的使用体验。
可选地,在电子设备上安装的第一应用程序处于运行状态的情况下,第一任务包括用于响应第一操作的任务,第一操作为对第一应用程序的使用操作,第二任务包括不用于响应第一操作的任务。
在应用程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
可选地,在电子设备加载第二应用程序的过程中,第一任务包括用于加载第二应用程序的任务,第二任务包括不用于加载第二应用程序的任务。
在小程序的加载场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备快速加载小程序,从而有助于提升用户体验。
可选地,在电子设备所加载的第三应用程序处于运行状态的情况下,第一任务包括用于响应第二操作的任务,第二操作为对第三应用程序的使用操作,第二任务包括不用于响应第二操作的任务。
在小程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
可选地,在电子设备启动电子设备上安装的第四应用程序的过程中,第一任务包括用于启动第四应用程序的任务,第二任务包括不用于启动第四应用程序的任务。
在应用程序的启动场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时启动应用程序,从而有助于提升用户体验。
可选地,第一任务为包括一个或者多个子任务的任务组,第二任务为包括一个或者多个子任务的任务组;资源管控方法还包括:控制第一任务中的子任务运行时对电子设备的设备资源的总使用量,使得第一任务中的子任务运行时对电子设备的设备资源的总使用量不超过向第一任务分配的设备资源的量,以及控制第二任务中的子任务运行时对电子设备的设备资源的总使用量,使得第二任务中的子任务运行时对电子设备的设备资源的总使用量不超过向第二任务分配的设备资源的量。
通过以任务组为单位进行资源管控,可以对任务组内的任务的设备资源量进行统一限制,便于对相同关键程度任务进行统一的资源管控。通过控制非关键任务组对设备资源的消耗,可以将设备资源留给更关键的任务组来使用,提高更关键的任务的响应效率。
可选地,根据第一占用量向第一任务分配电子设备的设备资源,以及根据第二占用量向第二任务分配电子设备的设备资源这一步骤可以包括:根据第一占用量向第一任务分配在单位调度窗口内的运行时间,以及根据第二占用量向第二任务分配在单位调度窗口内的运行时间,其中,向第一任务分配的在单位调度窗口内的运行时间大于向第二任务分配的在单位调度窗口内的运行时间;
资源管控方法还包括:在第一任务在当前的单位调度窗口内的运行时间达到向第一任务分配的在单位调度窗口内的运行时间的情况下,释放第一任务在当前的单位调度窗口内运行时使用的电子设备的设备资源,以及在第二任务在当前的单位调度窗口内的运行时间达到向第二任务分配的在单位调度窗口内的运行时间的情况下,释放第二任务在当前的单位调度窗口内运行时使用的电子设备的设备资源。
通过向任务分配在单位调度窗口内的运行时间,基于各个单位调度窗口的依次进行,可以使得电子设备中各个任务的响应更均衡,避免有些任务长时间处于待运行状态。
可选地,资源管控方法还包括:检测电子设备的负载;在检测到电子设备的负载达到预先设定的负载阈值的情况下,执行获取电子设备中的第一任务的第一信息的步骤。
通过限定执行资源管控的生效时机,不仅可以保证任务的响应效率,保证电子设备的良好系统性能,还可简化管控流程。
可选地,第一任务为包括一个或者多个子任务的任务组,第二任务为包括一个或者多个子任务的任务组;资源管控方法还包括:根据任务管理请求,执行任务管理操作;其中,任务管理操作包括:设置第一信息的操作、设置第二信息的操作、删除第一任务的操作、删除第二任务的操作、删除第一任务中任一子任务的操作、删除第二任务中任一子任务的操作、向第一任务中新增子任务的操作、向第二任务中新增子任务的操作、新增包括一个或者多个子任务的第三任务的操作中的一个或者多个。
通过执行任务管理操作,可使得对任务的分组符合实际应用需求,支持资源管控的按需进行。
第五方面,本申请实施例提供一种电子设备,电子设备包括用于存储计算机程序指令的存储器、用于执行计算机程序指令的处理器和通信装置,其中,当计算机程序指令被该处理器执行时,触发电子设备执行如第一方面中任一项的方法。
第六方面,本申请实施例提供一种芯片,包括:处理器,其用于执行存储在存储器上的计算机程序指令,其中,当计算机程序指令被处理器执行时,触发芯片执行如第一方面中任一项的方法。
第七方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第一方面中任一项的方法。
第八方面,本申请实施例提供一种计算机程序产品,计算机程序产品包括计算机程序,当计算机程序在计算机上运行时,使得计算机执行如第一方面中任一项的方法。
本申请实施例能够对任务所能占用的设备资源进行管控。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。
图1为本申请一个实施例提供的一种电子设备的结构示意图;
图2为本申请一个实施例提供的系统负载较高且不进行资源管控时系统中的一个关键任务的运行情况的示意图;
图3为本申请一个实施例提供的系统负载较高且不进行资源管控时系统中的另一关键任务的运行情况的示意图;
图4为本申请一个实施例提供的一种资源管控方法的流程示意图;
图5为本申请一个实施例提供的一个被限制运行的非关键任务的运行情况的示意图;
图6为本申请一个实施例提供的一种分组负载管控系统的示意图。
具体实施方式
为了更好的理解本申请的技术方案,下面结合附图对本申请实施例进行详细描述。
应当明确,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
在本申请实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。
应当理解,本文中使用的术语“至少一个”是指一个或者多个,“多个”是指两个或两个以上。本文中使用的术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。其中A,B可以是单数或者复数。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
应当理解,尽管在本申请实施例中可能采用术语第一、第二等来描述设定阈值,但这些设定阈值不 应限于这些术语。这些术语仅用来将设定阈值彼此区分开。例如,在不脱离本申请实施例范围的情况下,第一设定阈值也可以被称为第二设定阈值,类似地,第二设定阈值也可以被称为第一设定阈值。
本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。
本申请任一实施例提供的资源管控方法可以应用于图1所示的电子设备100中。图1示出了电子设备100的结构示意图。
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器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)接口等。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。电源管理模块141用于连接电池142,充电管理模块140与处理器110。电子设备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的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器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,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(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个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储 能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。磁传感器180D包括霍尔传感器。加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。环境光传感器180L用于感知环境光亮度。指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。温度传感器180J用于检测温度。
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。
电子设备中可以运行一个或者多个任务。一个实施例中,电子设备中运行的一个任务比如可以为一个进程或者一个线程。进程和线程均可作为任务的最小执行单元。
一个实施例中,电子设备运行已安装的某一应用程序时,电子设备可以显示该应用程序的界面。在用户对界面的展示内容进行如点击、滑动等操作时,电子设备可以执行用于响应用户所执行操作的任务,该任务为与用户响应相关的任务。电子设备在运行应用程序的同时,还可执行与用户响应无关的任务, 比如电子设备的后台任务。
电子设备运行多个任务且不执行资源管控操作(不对任务所能使用的设备资源进行管控)时,各个任务均可竞争电子设备的有限资源,且不同任务竞争到设备资源的概率可以相同。
不同任务所竞争的设备资源可以为电子设备的硬件资源。电子设备的硬件资源可以有CPU(central processing unit,中央处理器)、GPU(graphics processing unit,图形处理器)、内存等。
以任务竞争电子设备的CPU资源为例,一种实现方式中,当电子设备的系统负载较重(或称较高)时,电子设备的各个CPU上的任务较满。
当电子设备的系统负载较高、且不对任务所能使用的设备资源进行管控时,系统中各个任务均竞争电子设备的CPU资源,则系统中相对重要(或称关键)的任务(比如与用户响应相关的任务等)也难免会出现较多的待运行状态(比如记作runnable状态),从而导致相对重要任务的响应时延变长。相对关键的任务可以记作关键任务,其他任务可以记作非关键任务,关键任务的关键程度高于非关键任务的关键程度。
请参考图2和图3,图2示出了系统负载较高且不进行资源管控时,系统中的一个关键任务的运行情况,图3示出了系统负载较高且不进行资源管控时,系统中的另一关键任务的运行情况。其中,图2和图3的横轴可以表示时间的变化。
如图2所示,当系统负载较高时,系统中的一个关键任务在运行过程中存在较多的待运行状态,存在较少的运行状态。
如图3所示,当系统负载较高时,系统中的另一关键任务在运行过程中存在较多的待运行状态,存在较少的运行状态。
除了待运行状态和运行状态,任务在运行过程中还可以存在其他可能的状态,比如图3中所示的始终等待设备资源的休眠状态(比如可以记作sleep状态)等。
由于系统负载较高时,系统中关键任务的待运行状态的时长较长,关键任务的响应时延较长,则用户对电子设备的使用体验不佳。
一种实现方式中,通过对一种移动端操作系统的电子设备的动态功耗模块的测试数据进行分析,可以发现电子设备的系统负载(或称后台负载)越高,电子设备的功耗越高,电子设备充电一次所能使用的时长越短,即可以认为系统负载对动态功耗模型有较大影响。
基于电子设备的有限资源,为了提升关键任务的响应速率,提升用户对电子设备的使用体验,有必要提供一种资源管控流程,以对任务所能占用的设备资源进行管控,控制任务运行时对设备资源的使用。
场景1:应用程序的运行场景
应用程序可以预先安装在电子设备上。一个实施例中,手机可以显示所运行的应用程序的界面。用户通过查看界面显示内容,可以通过手机的触摸屏,对应用程序的界面展示内容按需执行点击、滑动等操作。电子设备可以执行用于响应用户所执行操作的任务。手机在运行应用程序的同时,还可执行后台任务等与用户响应无关的任务。手机中运行的各个任务均可竞争手机的CPU资源。
在应用程序的运行场景中,与用户响应相关的任务可以作为关键任务,与用户响应无关的任务比如后台任务可以作为非关键任务。
在应用程序的运行场景中,关键任务可以包括响应应用程序的使用操作的线程,非关键任务可以包括不响应应用程序的使用操作的线程。
一个实施例中,在应用程序的运行场景中,电子设备执行的关键任务可以包括:与用户响应最直接关联的UI(User Interface,用户界面)线程、Render(渲染)线程、动效(动画效果)线程等。
在场景1中,一种可行的资源管控流程可以为:电子设备响应于用户执行的用于请求运行电子设备上安装的应用程序的操作,运行该应用程序。电子设备在该应用程序的运行过程中,可以运行有用于响应对应用程序的使用操作的关键线程、和不用于响应对应用程序的使用操作的非关键线程。电子设备可以确定关键线程对电子设备的CPU资源的占用量和非关键线程对电子设备的CPU资源的占用量,且关键线程对电子设备的CPU资源的占用量大于非关键线程对电子设备的CPU资源的占用量,以为关键线程分配更多的CPU资源。基于确定出的占用量,电子设备可以向关键线程和非关键线程分配CPU资源。
其中,用户对应用程序的使用操作可以有点击操作、滑动操作等。
其中,场景1中的关键线程可以有用户界面线程、渲染线程、动画效果线程,场景1中的非关键线程可以有后台线程。后台线程比如可以有垃圾回收线程。
在应用程序的运行场景中,通过为关键线程分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
场景2:小程序的加载场景
电子设备可以加载应用程序,所加载的应用程序可以为未安装在电子设备上的小应用程序(或称小程序)。小程序是一种不需要下载安装即可使用的应用程序。
一个实施例中,手机为了加载小程序,可以执行用于加载解析小程序的任务。手机在加载小程序的过程中,还可执行其他无关于加载解析小程序的任务。一个实施例中,无关于加载解析小程序的任务比如可以有后台任务。手机中运行的各个任务均可竞争手机的CPU资源。
在小程序的加载场景中,用于加载解析小程序的任务可以作为关键任务,其他无关于加载小程序的任务可以作为非关键任务。
在小程序的加载场景中,非关键任务可以包括小程序中用于加载该小程序的线程之外的其他线程。
一个实施例中,在小程序的加载场景中,电子设备执行的关键任务可以包括:负责程序加载解析的线程。
在场景2中,一种可行的资源管控流程可以为:电子设备响应于用户执行的用于请求运行小程序的操作,可以先加载该小程序。电子设备在加载该小程序的过程中,可以运行有用于加载第一小程序的关键线程、和不用于加载第一小程序的非关键线程。电子设备可以确定关键线程对电子设备的设备资源的占用量和非关键线程对电子设备的设备资源的占用量,且关键线程对电子设备的设备资源的占用量大于非关键线程对电子设备的设备资源的占用量,以为关键线程分配更多的设备资源。基于确定出的占用量,电子设备可以向关键线程和非关键线程分配设备资源。
其中,场景2中的关键线程可以有负责程序加载解析的线程,场景2中的非关键线程可以有后台线程。
在小程序的加载场景中,通过为关键线程分配更多的设备资源,有助于电子设备快速加载小程序,从而有助于提升用户体验。
场景3:小程序的运行场景
电子设备可以加载小程序,在加载好小程序后,可以运行小程序。一个实施例中,手机可以显示所运行的小程序的界面。用户通过查看界面显示内容,可以通过手机的触摸屏,对小程序的界面展示内容按需执行点击、滑动等操作。电子设备可以执行用于响应用户所执行操作的任务。手机在运行小程序的同时,还可执行与用户响应无关的任务。一个实施例中,与用户响应无关的任务比如可以有后台任务。手机中运行的各个任务均可竞争手机的CPU资源。
在小程序的运行场景中,与用户响应相关的任务可以作为关键任务,与用户响应无关的任务可以作为非关键任务。
在小程序的运行场景中,关键任务可以包括响应小程序的使用操作的线程,非关键任务可以包括不响应小程序的使用操作的线程。
一个实施例中,在小程序的运行场景中,电子设备执行的关键任务可以包括:与用户响应最直接关联的webview(网页示图)类的线程等。
在场景3中,一种可行的资源管控流程可以为:电子设备响应于用户执行的用于请求运行小程序的操作,可以先加载该小程序,之后运行加载好的小程序。电子设备在该小程序的运行过程中,可以运行有用于响应对小程序的使用操作的关键线程、和不用于响应对小程序的使用操作的非关键线程。电子设备可以确定关键线程对电子设备的CPU资源的占用量和非关键线程对电子设备的CPU资源的占用量,且关键线程对电子设备的CPU资源的占用量大于非关键线程对电子设备的CPU资源的占用量,以为关键线程分配更多的CPU资源。基于确定出的占用量,电子设备可以向关键线程和非关键线程分配CPU资源。
其中,用户对小程序的使用操作可以有点击操作、滑动操作等。
其中,场景3中的关键线程可以有webview类的线程,场景3中的非关键线程可以有后台线程。
在小程序的运行场景中,通过为关键线程分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
场景4:应用程序的启动场景
应用程序可以预先安装在电子设备上。用户需要使用电子设备上安装的任一应用程序时,电子设备可以启动该应用程序。
一个实施例中,手机在启动所安装的应用程序的过程中,可以执行用于启动应用程序的任务。比如在存在应用程序启动动效的情况下,手机可以执行用于显示启动动效的任务。手机在启动应用程序的同时,还可执行与应用程序启动无关的任务。一个实施例中,与应用程序启动无关的任务比如可以有后台任务。手机中运行的各个任务均可竞争手机的CPU资源。
在应用程序的启动场景中,用于启动应用程序的任务可以作为关键任务,与启动应用程序无关的任务可以作为非关键任务。
在应用程序的启动场景中,非关键任务可以包括应用程序中用于启动应用程序的线程之外的其他线程。
一个实施例中,在应用程序的启动场景中,电子设备执行的关键任务可以包括:launcher线程、用于显示启动动效的线程。Launcher为安卓系统中的桌面启动器。
在场景4中,一种可行的资源管控流程可以为:电子设备响应于用户执行的用于请求运行电子设备上安装的应用程序的操作,可以启动该应用程序。电子设备在启动该应用程序的过程中,可以运行有用于启动应用程序的关键线程、和不用于启动应用程序的非关键线程。电子设备可以确定关键线程对电子设备的设备资源的占用量和非关键线程对电子设备的设备资源的占用量,且关键线程对电子设备的设备资源的占用量大于非关键线程对电子设备的设备资源的占用量,以为关键线程分配更多的设备资源。基于确定出的占用量,电子设备可以向关键线程和非关键线程分配设备资源。
其中,场景4中的关键线程可以有launcher线程、用于显示启动动效的线程,场景4中的非关键线程可以有后台线程。
在应用程序的启动场景中,通过为关键任务分配更多的设备资源,有助于电子设备及时启动应用程序,从而有助于提升用户体验。
本申请一个实施例提供了一种资源管控方法,该方法可以应用于电子设备,该方法可以包括:响应于第一操作,运行第一应用,其中,在第一应用的运行过程中运行有第一线程和第二线程,第一线程为用于响应对第一应用的使用操作的线程,第二线程为不用于响应对第一应用的使用操作的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。该实施例可以适用于上述场景1、场景3。
一个实施例中,第一应用为电子设备上安装的任一应用;第一线程包括用户界面线程、渲染线程、动画效果线程中的至少一种。
一个实施例中,第一应用为电子设备所加载的任一小程序;第一线程包括网页示图类的线程。
一个实施例中,第二线程包括后台线程。
在应用程序、小程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键线程分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
本申请一个实施例提供了一种资源管控方法,该方法可以应用于电子设备,该方法可以包括:响应于第一操作,加载第一小程序,其中,在加载第一小程序的过程中运行有第一线程和第二线程,第一线程为用于加载第一小程序的线程,第二线程为不用于加载第一小程序的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。该实施例可以适用于上述场景2。
在小程序的加载场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键线程分配更多的设备资源,有助于电子设备快速加载小程序,从而有助于提升用户体验。
本申请一个实施例提供了一种资源管控方法,该方法可以应用于电子设备,该方法可以包括:响应于第一操作,启动电子设备上安装的第一应用,其中,在启动第一应用的过程中运行有第一线程和第二线程,第一线程为用于启动第一应用的线程,第二线程为不用于启动第一应用的线程;确定第一线程对电子设备的设备资源的占用量为第一占用量,以及确定第二线程对电子设备的设备资源的占用量为第二占用量,其中,第一占用量大于第二占用量;基于第一占用量向第一线程分配电子设备的设备资源,以及基于第二占用量向第二线程分配电子设备的设备资源。该实施例可以适用于上述场景4。
在应用程序的启动场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时启动应用程序,从而有助于提升用户体验。在本申请一个实施例中,请参考图4,一种资源管控方法可以包括以下步骤401~步骤403。
步骤401,获取电子设备中的第一任务的第一信息,以及获取电子设备中的第二任务的第二信息,其中,第一信息用于描述第一任务的关键程度,第二信息用于描述第二任务的关键程度,第一任务的关键程度高于第二任务的关键程度。
电子设备中可以运行一个或者多个任务。一个实施例中,第一任务、第二任务可以为电子设备中运行的、具有不同关键程度的任意两个任务。另一实施例中,第一任务、第二任务还可以为电子设备中运行的、具有不同关键程度的任意两个任务组合,一个任务组合可以包括至少一个任务。第一任务、第二任务均可以具有相应的关键程度。
一个实施例中,可以对电子设备中的一个或者多个任务进行资源管控,第一任务、第二任务均可以为被进行资源管控的任务。
一个实施例中,可以结合人为定义,确定任务的关键程度。另一实施例中,可以根据任务的属性(比如是否为系统中现有的后台任务),确定任务的关键程度。其中,可以确定后台任务不关键,或者具有较低的关键程度。
一个实施例中,任务的关键程度可以有关键、不关键的区别。比如,可以对关键任务分配设定好的较大量的设备资源,对非关键任务分配设定好的较少量的设备资源。
比如用于描述任务的关键程度的信息可以为0或者1,该信息为0时可以表示任务不关键,该信息为1时可以表示任务关键。
另一实施例中,任务的关键程度可以为关键值。比如,关键值越高,关键程度越高。
又一实施例中,任务的关键程度可以为关键等级。比如,关键等级越高,关键程度越高。
再一实施例中,任务的关键程度可以为关键范围。比如,两个任务的关键值可以不同,但两个任务的关键值均落入同一关键范围内,则可以认为两个任务的关键程度相一致(或称相等、相同)。一个实施例中,若关键值不大于关键范围的上限值,且不小于关键范围的下限值,可以认为关键值落入关键范围。
一个实施例中,第一任务可以为关键任务,第二任务可以为非关键任务。
第一信息可作为用于确定第一任务对设备资源的占用量的依据,第二信息可作为用于确定第二任务对设备资源的占用量的依据。关键程度越强,相应任务对设备资源的占用量越大,反之越小。
步骤402,根据第一信息确定第一任务对电子设备的设备资源的第一占用量,以及根据第二信息确定第二任务对电子设备的设备资源的第二占用量,其中,第一占用量大于第二占用量。
步骤402中,可以根据任务的关键程度,确定任务对设备资源的占用量,以便后续可以根据任务对设备资源的占用量,向任务分配设备资源。
任务对设备资源的占用量与任务的关键程度可以呈正相关,使得分配至任务的设备资源的量与任务的关键程度呈正相关。其中,若任务的关键程度越高,任务越关键,任务对设备资源的占用量越高,向任务分配的设备资源越多,若任务的关键程度越低,任务越不关键,任务对设备资源的占用量越低,向任务分配的设备资源越少。
第一任务的关键程度高于第二任务的关键程度,则第一任务对设备资源的占用量大于第二任务对设备资源的占用量,以为关键任务分配相对更多的设备资源、为非关键任务分配相对更少的设备资源。
一个实施例中,与非关键任务(比如任务不关键或任务的关键程度低)相比,关键任务(比如任务 关键或任务的关键程度高)对设备资源的占用量的上限可以更高。
另一实施例中,与非关键任务不同,关键任务对设备资源的占用量可以没有上限,即可以对关键任务所能使用的设备资源量(或称设备资源的量)不设上限,使得关键任务最高可使用电子设备的全部有限资源(比如全部CPU资源)。
一个实施例中,除了根据第一任务、第二任务的关键程度,还可以根据电子设备中其他任务的关键程度,确定第一任务、第二任务对设备资源的占用量,以向第一任务、第二任务分配设备资源。如此,可以避免一些任务所能使用的设备资源较多,而另一些任务所能使用的设备资源较少甚至无法使用到设备资源,以支持多个任务的均衡运行。
一个实施例中,以CPU资源为例,确定出的任务对设备资源的占用量可以为CPU的数量。比如关键任务可以使用较多数量的CPU,非关键任务可以使用较少数量的CPU。
另一实施例中,以CPU资源为例,确定出的任务对设备资源的占用量也可以为任务可用的最大CPU带宽。其中,可以使用配额和时段(或称周期)来指定任务允许使用的最大CPU带宽。配额和时段的单位均可以时间,比如s(秒)、ms(毫秒)。
举例来说,假设将任务的运行时间限制为1个CPU。一个例子中,若时段为500ms、配额为500ms,则任务每500ms最多可以使用1个CPU;另一例子中,若时段为250ms、配额为500ms,则任务每250ms最多可以使用2个CPU;再一例子中,若时段为500ms、配额为50ms,则任务每500ms最多可以使用1个CPU的10%。
一个实施例中,确定出的任务对设备资源的占用量可以为任务对设备资源的使用时长。
一个实施例中,确定出的任务对设备资源的占用量可以为任务在单位调度窗口内对设备资源的使用时长。另一实施例中,确定出的任务对设备资源的占用量可以为在非单位调度窗口(比如窗口大小可变的窗口)内对设备资源的使用时长。
一个单位调度窗口可以作为一个时间周期。单位调度窗口的时间长度可以按需设定,比如可以设定为1s、500ms、250ms、50ms等。
以确定出的任务对设备资源的占用量为任务对设备资源的使用时长为例,若任务使用设备资源的时长达到分配至任务的对设备资源的使用时长,可以控制任务暂停运行,释放任务使用的设备资源以供其他任务使用。
一个实施例中,为任务分配设备资源可以包括:向任务分配在单位调度窗口内的运行时间(或称运行时长)。比如一个单位调度窗口的时间长度为1s,分配至一个非关键任务的运行时间可以为一个单位调度窗口中的100ms。
步骤403,根据第一占用量向第一任务分配电子设备的设备资源,以及根据第二占用量向第二任务分配电子设备的设备资源。
步骤403中,可以根据确定出的占用量,向任务分配设备资源。任务运行时使用的设备资源不超过向任务分配的设备资源。一个实施例中,可以通过设置相应配置信息,来向任务分配设备资源。
以占用量为CPU数量为例,向任务分配设备资源时,一个实施例中,可以配置任务所能使用的CPU数量,另一实施例中,也可以配置任务所能使用的相应数量的各个CPU的标识。
对任务分配设备资源后,可以根据向任务分配的设备资源量,对任务的运行进行控制,以使得任务运行时对设备资源的使用量不超过分配的设备资源量。
在本申请一个实施例中,资源管控方法还可以包括:步骤A,控制第一任务运行时对电子设备的设备资源的使用量,使得第一任务运行时对电子设备的设备资源的使用量不超过向第一任务分配的设备资源的量,以及控制第二任务运行时对电子设备的设备资源的使用量,使得第二任务运行时对电子设备的设备资源的使用量不超过向第二任务分配的设备资源的量。
在向任务分配设备资源之后,可以根据分配至任务的设备资源的量,控制任务运行时所能使用的设备资源的量。任务运行时所能使用的设备资源不超过分配至任务的设备资源。
一个实施例中,若任务使用的设备资源量达到分配至任务的设备资源量,电子设备可以强制控制任务暂停运行,释放任务使用的设备资源以供其他任务使用。
另一实施例中,可以对任务的信息进行相应配置,使得若任务运行时对设备资源的使用量达到分配至任务的设备资源的量,任务可以自动暂停运行。
在本申请一个实施例中,步骤403可以包括:根据第一占用量向第一任务分配运行时间,根据第二占用量向第二任务分配运行时间。基于此,资源管控方法还可以包括:在第一任务的运行时间达到向第一任务分配的运行时间的情况下,释放第一任务运行时使用的电子设备的设备资源,以及在第二任务的运行时间达到向第二任务分配的运行时间的情况下,释放第二任务运行时使用的电子设备的设备资源。
一个实施例中,向任务分配的运行时间可以与任务运行时使用的设备资源的量呈正相关。任务的运行时间越长,对设备资源的使用时长越长,使用的设备资源的量越多。在任务的运行时间达到分配的运行时间时,控制任务暂停运行,释放任务使用的设备资源。
在本申请一个实施例中,步骤403可以包括:根据第一占用量向第一任务分配在单位调度窗口内的运行时间,以及根据第二占用量向第二任务分配在单位调度窗口内的运行时间,其中,向第一任务分配的在单位调度窗口内的运行时间大于向第二任务分配的在单位调度窗口内的运行时间。
以第一任务为例,分配至第一任务的运行时间为在一个单位调度窗口内的、允许第一任务运行的运行时间。
基于此,资源管控方法还包括:在第一任务在当前的单位调度窗口内的运行时间达到向第一任务分配的在单位调度窗口内的运行时间的情况下,释放第一任务在当前的单位调度窗口内运行时使用的电子设备的设备资源,以及在第二任务在当前的单位调度窗口内的运行时间达到向第二任务分配的在单位调度窗口内的运行时间的情况下,释放第二任务在当前的单位调度窗口内运行时使用的电子设备的设备资源。
一个实施例中,对于依次进行的每一个单位调度窗口,以第一任务为例,可以断第一任务在当前单位调度窗口内的运行时间是否达到分配至第一任务的运行时间,若判断为是,则可以控制第一任务暂停运行以处于待运行状态,并释放第一任务使用的设备资源,以供其他任务在当前单位调度窗口内使用。若判断为否,则无需控制第一任务暂停运行,第一任务在当前单位调度窗口内保持继续运行。或者也可以监测第一任务在当前单位调度窗口内的运行时间,在监测到该运行时间达到分配至第一任务的运行时间时,可以控制第一任务暂停运行并释放第一任务使用的设备资源。
通过向任务分配在单位调度窗口内的运行时间,基于各个单位调度窗口的依次进行,可以使得电子设备中各个任务的响应更均衡,避免有些任务长时间处于待运行状态。
一个实施例中,以任务使用CPU资源为例,基于时钟快照度量(clock snapshots metric)技术,可以得到如图5所示的一个被限制运行(限制任务运行时对设备的CPU资源的使用)的非关键任务(比如记作CFS.sh 325)的运行情况的示意图。CFS(Completely Fair Scheduler)的中文释义为完全公平调度器。其中,图5的横轴可以表示时间的变化。
请参考图5,非关键任务在每一单位调度窗口内,大多时间处于等待CPU资源的待运行状态,少量时间处于获取到CPU资源的运行状态,当该非关键任务的运行时间超过设定的时间值(比如分配至该非关键任务的对设备资源的使用时长)时,可以强制释放该非关键任务获取到的CPU资源,所释放的CPU资源供其他任务使用。
在设备资源有限的情况下,通过根据任务的关键程度为任务分配相应量的设备资源,可以避免出现关键任务存在较多的待运行状态的情况,如此可以提升关键任务的响应速率,从而提升用户对电子设备的使用体验。
可以通过降低电子设备中非关键任务的设备资源消耗,从而使得电子设备中的关键任务可以更快的获取更多的设备资源,降低关键任务的响应时间和整体运行过程耗时,便于用户有更好的性能使用体验。
电子设备中可以运行一个或者多个任务,一个实施例中,可以任务为单位来分配设备资源,即可以对电子设备中的各个任务分别分配设备资源。
另一实施例中,还可根据任务的关键程度,对电子设备中的任务进行分组以得到任务组(或称分组、任务分组),并以组为单位来分配设备资源,即可以对电子设备中的各个任务组分别分配设备资源。
一个实施例中,可以默认将系统现有的非关键的后台任务作为一个任务组,比如记作后台分组(或称background分组),并标记后台分组的关键程度为非关键。
除了现有后台任务组成的系统默认任务组,一个实施例中,还可以按需自定义新建任务组。比如可以新建一个包括多个非关键任务的任务组,比如记作低优先级分组,并标记低优先级分组的关键程度为非关键。以及可以新建一个包括多个关键任务的任务组,并标记该任务组的关键程度为关键。
一个实施例中,构建出的任意两个任务组的关键程度可以不同。另一实施例中,构建的任务组中,可以包括相同关键程度的至少两个任务组。
在本申请一个实施例中,第一任务为包括一个或者多个子任务的任务组,第二任务为包括一个或者多个子任务的任务组;资源管控方法还包括:控制第一任务中的子任务运行时对电子设备的设备资源的总使用量,使得第一任务中的子任务运行时对电子设备的设备资源的总使用量不超过向第一任务分配的设备资源的量,以及控制第二任务中的子任务运行时对电子设备的设备资源的总使用量,使得第二任务中的子任务运行时对电子设备的设备资源的总使用量不超过向第二任务分配的设备资源的量。
任务组中的各个任务可以作为任务组的子任务。同一任务组中的各个任务的关键程度相一致,比如均为关键任务,或者任务的关键值相同,或者任务的关键等级相同,或者任务的关键值落入同一关键范围。
任务组的关键程度可以与任务组中的任务的关键程度相一致。通过根据任务组的关键程度为任务组分配设备资源,以对任务组中的任务分配设备资源,对任务组中的任务所能使用的设备资源进行限制。
一个实施例中,为任务组分配设备资源后,任务组中的任务运行所能使用的设备资源总量,应不超过分配至任务组的设备资源量。其中,对任务组中不同任务对设备资源的使用情况可以不做限定,比如任务组中的各个任务均可竞争分配至任务组的设备资源。
通过以任务组为单位进行资源管控,可以对任务组内的任务的设备资源量进行统一限制,便于对相同关键程度任务进行统一的资源管控。通过控制非关键任务组对设备资源的消耗,可以将设备资源留给更关键的任务组来使用,提高更关键的任务的响应效率。
一个实施例中,电子设备的系统并不会一直处于高负载状态。
考虑到系统低负载状态下,有限的设备资源通常可以支持各个任务的及时响应,各个任务可以不存在较长时间的待运行状态,在该情况下对任务执行的资源管控操作(比如对任务组的运行时间进行限制的操作)对电子设备系统性能的提升帮助不大,则可以仅在系统高负载状态下对任务进行资源管控,在系统低负载状态下不对任务进行资源管控。
一个实施例中,资源管控方法还可以包括:检测电子设备的负载;在检测到电子设备的负载达到预先设定的负载阈值的情况下,才执行上述步骤A,否则不执行上述步骤A。
由于在设备负载较高时,可以直接根据分配至任务的设备资源量控制任务对设备资源的使用量,则可以对分配至任务的设备资源量进行周期性更新或者实时更新。
在本申请一个实施例中,资源管控方法还包括:检测电子设备的负载;在检测到电子设备的负载达到预先设定的负载阈值的情况下,执行获取电子设备中的第一任务的第一信息的步骤。即在检测到电子设备的负载达到预先设定的负载阈值的情况下,才执行步骤401,否则不执行步骤401。
由于在设备负载较高时,可以先向任务分配设备资源,再根据分配至任务的设备资源量控制任务对设备资源的使用量,则可以无需对分配至任务的设备资源量进行周期性更新或者实时更新。
一个实施例中,可以实时或者周期性检测电子设备的负载(或称系统负载)。一个实施例中,电子设备的负载可以为电子设备运行所消耗的功率。
若检测到的负载达到一定阈值时,才执行资源管控,以对任务使用的资源进行限制,若未达到阈值则不执行资源管控,不对任务使用的资源进行限制。
一个实施例中,负载阈值可以按需设定,比如可以根据经验值得到。
通过考虑为任务分配设备资源的适用场景,可以在设备负载较重的情况下才开始进行设备资源管控。其中,在设备负载比较重的时候,给关键性较高的任务多分配运行时间(或称分配时间片),给关键性较低的任务少分配运行时间,而在设备负载比较轻的时候不为任务分配运行时间,使得各个任务都去运行。通过限定执行资源管控的生效时机,不仅可以保证任务的响应效率,保证电子设备的良好系统性能,还可简化管控流程。
在本申请一个实施例中,第一任务为包括一个或者多个子任务的任务组,第二任务为包括一个或者多个子任务的任务组;资源管控方法还包括:根据任务管理请求,执行任务管理操作;其中,任务管理操作包括:设置第一信息的操作、设置第二信息的操作、删除第一任务的操作、删除第二任务的操作、删除第一任务中任一子任务的操作、删除第二任务中任一子任务的操作、向第一任务中新增子任务的操作、向第二任务中新增子任务的操作、新增包括一个或者多个子任务的第三任务的操作中的一个或者多 个。
以第一信息为例,一个实施例中,设置第一信息的操作可以为初次设置第一信息的操作。另一实施例中,设置第一信息的操作也可以为在初次设置第一信息后,对第一信息进行更新设置的操作。
一个实施例中,在对第一信息进行更新设置的情况下,可以再次执行上述步骤401~步骤403,以更新分配至第一任务对设备资源的占用量。一个实施例中,可以基于任务关键程度的变化,执行相应的任务管理操作。比如,在某一任务的关键程度从关键变化为非关键时,可以将该任务从原有的关键分组转移至另一非关键分组。再比如,在某一任务组的关键程度发生变化时,可以更新对该任务组的关键程度描述信息的设置。
一个实施例中,可以基于实际应用需求,执行删除任务、增加任务、删除任务组、新增任务组等操作。
在本申请一个实施例中,在电子设备上安装的第一应用程序处于运行状态的情况下,第一任务包括用于响应第一操作的任务,第一操作为对第一应用程序的使用操作,第二任务包括不用于响应第一操作的任务。
这一实施例可以适用于上述场景1。在上述场景1:应用程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
在本申请一个实施例中,在电子设备加载第二应用程序的过程中,第一任务包括用于加载第二应用程序的任务,第二任务包括不用于加载第二应用程序的任务。
这一实施例可以适用于上述场景2。在上述场景2:小程序的加载场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备快速加载小程序,从而有助于提升用户体验。
在本申请一个实施例中,在电子设备所加载的第三应用程序处于运行状态的情况下,第一任务包括用于响应第二操作的任务,第二操作为对第三应用程序的使用操作,第二任务包括不用于响应第二操作的任务。
这一实施例可以适用于上述场景3。在上述场景3:小程序的运行场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时响应用户操作,从而有助于提升用户体验。
在本申请一个实施例中,在电子设备启动电子设备上安装的第四应用程序的过程中,第一任务包括用于启动第四应用程序的任务,第二任务包括不用于启动第四应用程序的任务。
这一实施例可以适用于上述场景4。在上述场景4:应用程序的启动场景中,与不进行资源管控相比,该实施例提供的资源管控方法通过为关键任务分配更多的设备资源,有助于电子设备及时启动应用程序,从而有助于提升用户体验。
一个实施例中,请参考图6,图6示出了一种分组负载管控系统,该分组负载管控系统可以包括实时负载监控模块601、控制模块602、分组管理模块603。
实时负载监控模块601可以实时监控电子设备的负载。
在监测到的负载达到预设的负载阈值时,即达到执行资源管控的生效时机时,控制模块602可以对电子设备中的各个任务组进行资源管控,比如可以限制任务组在单位调度窗口中的运行时间。其中,可以为关键任务组分配较长的运行时间,为非关键任务组分配较短的运行时间。
电子设备中的任务组可以通过对电子设备中的任务进行分组得到,同一任务组中的任务的关键程度相一致。
请参考图6,电子设备中可以包括后台分组、低优先级分组和其他分组。其中,后台分组可以包括电子设备中现有的非关键后台任务,为系统默认分组。低优先级分组可以包括电子设备中的区别于后台任务的其他非关键任务,为系统新建分组。其他分组比如可以为一个任务组,可以包括电子设备中的关键任务,为系统新建分组。
经资源管控,可以限制后台分组、低优先级分组的运行时间均为较短的运行时间,限制其他分组的运行时间为较长的运行时间。
图6所示实施例可以利用当前系统现有的非关键默认分组、以及新建的低优先级任务分组等分组,并根据分组的关键程度限制对应分组的运行时间,来达到提升系统性能体验的目的。
以任务使用CPU资源为例,基于本申请任一实施例提供的资源管控实现方式,可以根据任务的关键程度为任务分配运行时间,为关键的任务多分配运行时间,为不太关键的任务少分配运行时间,如此可以为不同的任务分配与其关键程序相匹配的运行时间。
不同的运行时间运行相应不同的任务,如此不仅可以在CPU负载较高时保证关键任务的及时响应,通常还可使得CPUutil的值较小,有助于降低CPU功耗。其中,CPUutil可以表示CPU利用率。
请参考以下公式(1)~(4),这四个公式示出了单位调度窗口内任务运行时间和频率关系的推导过程。基于这四个公式的所示内容,可以认为通过对单位调度窗口内的任务运行时间进行控制,可具体降低频率的效果,而CPU功耗主要受频率影响,如此可具有降低CPU功耗的效果。



式中,TaskrunningTime表示任务归一化运行时间,delta表示时间变化值,curfreq表示CPU当前运行频率,maxfreq表示CPU最大运行频率,capacity表示CPU最大频率对应的能力,cpuload表示CPU负载,util即CPUutil表示CPU利用率,schedwindow表示单位调度窗口,Freq表示频率(准备调频到的频点),max表示最大利用率。
一个实施例中,Freq可以反映CPU被使用的频率。
基于本申请任一实施例提供的资源管控实现方式,可以对单位调度窗口内的任务运行时间进行控制,通过限制单位调度窗口内任务的运行时间可以降低频率(频率计算公式见上述公式(1)~(4)),而CPU功耗主要受频率影响,则通过限制单位调度窗口内任务的运行时间有助于降低CPU功耗。CPU功耗越低,电子设备充电一次所能使用的时长越长,CPU负载对动态功耗模型的影响越小。
本申请一个实施例还提供一种芯片,该任务处理芯片安装在电子设备(UE)中,芯片包括:处理器,其用于执行存储在存储器上的计算机程序指令,其中,当计算机程序指令被处理器执行时,触发芯片执行本申请任意方法实施例提供的方法步骤。
本申请一实施例还提出了一种终端设备,终端设备包括通信模块、用于存储计算机程序指令的存储器和用于执行程序指令的处理器,其中,当该计算机程序指令被该处理器执行时,触发终端设备执行本申请任意方法实施例提供的方法步骤。
本申请一实施例还提出了一种服务器设备,服务器设备包括通信模块、用于存储计算机程序指令的存储器和用于执行程序指令的处理器,其中,当该计算机程序指令被该处理器执行时,触发服务器设备执行本申请任意方法实施例提供的方法步骤。
本申请一个实施例还提供一种电子设备,电子设备包括多根天线、用于存储计算机程序指令的存储器、用于执行计算机程序指令的处理器和通信装置(比如可以基于NR协议实现5G通信的通信模块),其中,当计算机程序指令被该处理器执行时,触发电子设备执行本申请任意方法实施例提供的方法步骤。
具体的,在本申请一实施例中,一个或多个计算机程序被存储在上述存储器中,该一个或多个计算机程序包括指令,当该指令被上述设备执行时,使得上述设备执行本申请实施例所述的方法步骤。
具体的,在本申请一实施例中,电子设备的处理器可以是片上装置SOC(System on Chip,系统级 芯片),该处理器中可以包括中央处理器(Central Processing Unit,CPU),还可以进一步包括其他类型的处理器。具体的,在本申请一实施例中,电子设备的处理器可以是PWM控制芯片。
具体的,在本申请一实施例中,涉及的处理器可以例如包括CPU、DSP(digital signal processor,数字信号处理器)或微控制器,还可包括GPU(graphics processing unit,图形处理器)、嵌入式神经网络处理器(Neural-network Process Units,NPU)和图像信号处理器(Image Signal Processing,ISP),该处理器还可包括必要的硬件加速器或逻辑处理硬件电路,如ASIC,或一个或多个用于控制本申请技术方案程序执行的集成电路等。此外,处理器可以具有操作一个或多个软件程序的功能,软件程序可以存储在存储介质中。
具体的,在本申请一实施例中,电子设备的存储器可以是只读存储器(read-only memory,ROM)、可存储静态信息和指令的其它类型的静态存储设备、随机存取存储器(random access memory,RAM)或可存储信息和指令的其它类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其它磁存储设备,或者还可以是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何计算机可读介质。
具体的,在本申请一实施例中,处理器可以和存储器可以合成一个处理装置,更常见的是彼此独立的部件,处理器用于执行存储器中存储的程序代码来实现本申请实施例所述方法。具体实现时,该存储器也可以集成在处理器中,或者,独立于处理器。
进一步的,本申请实施例阐明的设备、装置、模块,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。
本领域内的技术人员应明白,本申请实施例可提供为方法、装置、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质上实施的计算机程序产品的形式。
在本申请所提供的几个实施例中,任一功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。
具体的,本申请一实施例中还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行本申请实施例提供的方法步骤。
本申请一实施例还提供一种计算机程序产品,该计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行本申请实施例提供的方法步骤。
本申请中的实施例描述是参照根据本申请实施例的方法、设备(装置)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能 划分,实际实现时可以有另外的划分方式,例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口、装置或单元的间接耦合或通信连接,可以是电性、机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机,服务器,或者网络装置等)或处理器(Processor)执行本申请各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
本申请实施例中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本申请中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
本领域普通技术人员可以意识到,本申请实施例中描述的各单元及算法步骤,能够以电子硬件、计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。

Claims (18)

  1. 一种资源管控方法,其特征在于,应用于电子设备,所述方法包括:
    响应于第一操作,运行第一应用,其中,在所述第一应用的运行过程中运行有第一线程和第二线程,所述第一线程为用于响应对所述第一应用的使用操作的线程,所述第二线程为不用于响应对所述第一应用的使用操作的线程;
    确定所述第一线程对所述电子设备的设备资源的占用量为第一占用量,以及确定所述第二线程对所述电子设备的设备资源的占用量为第二占用量,其中,所述第一占用量大于所述第二占用量;
    基于所述第一占用量向所述第一线程分配所述电子设备的设备资源,以及基于所述第二占用量向所述第二线程分配所述电子设备的设备资源。
  2. 根据权利要求1所述的方法,其特征在于,所述第一应用为所述电子设备上安装的任一应用;
    所述第一线程包括用户界面线程、渲染线程、动画效果线程中的至少一种。
  3. 根据权利要求1所述的方法,其特征在于,所述第一应用为所述电子设备所加载的任一小程序;
    所述第一线程包括网页示图类的线程。
  4. 根据权利要求1-3中任一所述的方法,其特征在于,所述第二线程包括后台线程。
  5. 一种资源管控方法,其特征在于,应用于电子设备,所述方法包括:
    响应于第一操作,加载第一小程序,其中,在加载所述第一小程序的过程中运行有第一线程和第二线程,所述第一线程为用于加载所述第一小程序的线程,所述第二线程为不用于加载所述第一小程序的线程;
    确定所述第一线程对所述电子设备的设备资源的占用量为第一占用量,以及确定所述第二线程对所述电子设备的设备资源的占用量为第二占用量,其中,所述第一占用量大于所述第二占用量;
    基于所述第一占用量向所述第一线程分配所述电子设备的设备资源,以及基于所述第二占用量向所述第二线程分配所述电子设备的设备资源。
  6. 一种资源管控方法,其特征在于,应用于电子设备,所述方法包括:
    响应于第一操作,启动所述电子设备上安装的第一应用,其中,在启动所述第一应用的过程中运行有第一线程和第二线程,所述第一线程为用于启动所述第一应用的线程,所述第二线程为不用于启动所述第一应用的线程;
    确定所述第一线程对所述电子设备的设备资源的占用量为第一占用量,以及确定所述第二线程对所述电子设备的设备资源的占用量为第二占用量,其中,所述第一占用量大于所述第二占用量;
    基于所述第一占用量向所述第一线程分配所述电子设备的设备资源,以及基于所述第二占用量向所述第二线程分配所述电子设备的设备资源。
  7. 一种资源管控方法,其特征在于,包括:
    获取电子设备中的第一任务的第一信息,以及获取所述电子设备中的第二任务的第二信息,其中,所述第一信息用于描述所述第一任务的关键程度,所述第二信息用于描述所述第二任务的关键程度,所述第一任务的关键程度高于所述第二任务的关键程度;
    根据所述第一信息确定所述第一任务对所述电子设备的设备资源的第一占用量,以及根据所述第二信息确定所述第二任务对所述电子设备的设备资源的第二占用量,其中,所述第一占用量大于所述第二占用量;
    根据所述第一占用量向所述第一任务分配所述电子设备的设备资源,以及根据所述第二占用量向所述第二任务分配所述电子设备的设备资源。
  8. 根据权利要求7所述的方法,其特征在于,在所述电子设备上安装的第一应用程序处于运行状态的情况下,所述第一任务包括用于响应第一操作的任务,所述第一操作为对所述第一应用程序的使用操作,所述第二任务包括不用于响应所述第一操作的任务。
  9. 根据权利要求7所述的方法,其特征在于,在所述电子设备加载第二应用程序的过程中,所述第一任务包括用于加载所述第二应用程序的任务,所述第二任务包括不用于加载所述第二应用程序的任务。
  10. 根据权利要求7所述的方法,其特征在于,在所述电子设备所加载的第三应用程序处于运行状态的情况下,所述第一任务包括用于响应第二操作的任务,所述第二操作为对所述第三应用程序的使用操 作,所述第二任务包括不用于响应所述第二操作的任务。
  11. 根据权利要求7所述的方法,其特征在于,在所述电子设备启动所述电子设备上安装的第四应用程序的过程中,所述第一任务包括用于启动所述第四应用程序的任务,所述第二任务包括不用于启动所述第四应用程序的任务。
  12. 根据权利要求7所述的方法,其特征在于,所述第一任务为包括一个或者多个子任务的任务组,所述第二任务为包括一个或者多个子任务的任务组;
    所述方法还包括:控制所述第一任务中的子任务运行时对所述电子设备的设备资源的总使用量,使得所述第一任务中的子任务运行时对所述电子设备的设备资源的总使用量不超过向所述第一任务分配的设备资源的量,以及控制所述第二任务中的子任务运行时对所述电子设备的设备资源的总使用量,使得所述第二任务中的子任务运行时对所述电子设备的设备资源的总使用量不超过向所述第二任务分配的设备资源的量。
  13. 根据权利要求7所述的方法,其特征在于,所述根据所述第一占用量向所述第一任务分配所述电子设备的设备资源,以及根据所述第二占用量向所述第二任务分配所述电子设备的设备资源,包括:
    根据所述第一占用量向所述第一任务分配在单位调度窗口内的运行时间,以及根据所述第二占用量向所述第二任务分配在单位调度窗口内的运行时间,其中,向所述第一任务分配的在单位调度窗口内的运行时间大于向所述第二任务分配的在单位调度窗口内的运行时间;
    所述方法还包括:在所述第一任务在当前的单位调度窗口内的运行时间达到向所述第一任务分配的在单位调度窗口内的运行时间的情况下,释放所述第一任务在当前的单位调度窗口内运行时使用的所述电子设备的设备资源,以及在所述第二任务在当前的单位调度窗口内的运行时间达到向所述第二任务分配的在单位调度窗口内的运行时间的情况下,释放所述第二任务在当前的单位调度窗口内运行时使用的所述电子设备的设备资源。
  14. 根据权利要求7所述的方法,其特征在于,所述方法还包括:
    检测所述电子设备的负载;
    在检测到所述电子设备的负载达到预先设定的负载阈值的情况下,执行所述获取电子设备中的第一任务的第一信息的步骤。
  15. 根据权利要求7所述的方法,其特征在于,所述第一任务为包括一个或者多个子任务的任务组,所述第二任务为包括一个或者多个子任务的任务组;
    所述方法还包括:根据任务管理请求,执行任务管理操作;
    其中,所述任务管理操作包括:设置所述第一信息的操作、设置所述第二信息的操作、删除所述第一任务的操作、删除所述第二任务的操作、删除所述第一任务中任一子任务的操作、删除所述第二任务中任一子任务的操作、向所述第一任务中新增子任务的操作、向所述第二任务中新增子任务的操作、新增包括一个或者多个子任务的第三任务的操作中的一个或者多个。
  16. 一种电子设备,其特征在于,所述电子设备包括用于存储计算机程序指令的存储器、用于执行计算机程序指令的处理器和通信装置,其中,当所述计算机程序指令被该处理器执行时,触发所述电子设备执行如权利要求1-15中任一项所述的方法。
  17. 一种芯片,其特征在于,包括:
    处理器,其用于执行存储在存储器上的计算机程序指令,其中,当所述计算机程序指令被所述处理器执行时,触发所述芯片执行权利要求1-15中任一项所述的方法。
  18. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如权利要求1-15中任一项所述的方法。
PCT/CN2023/114758 2022-10-26 2023-08-24 资源管控方法、装置、芯片、电子设备及介质 WO2024087840A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211320767.3 2022-10-26
CN202211320767.3A CN117931418A (zh) 2022-10-26 2022-10-26 资源管控方法、装置、芯片、电子设备及介质

Publications (1)

Publication Number Publication Date
WO2024087840A1 true WO2024087840A1 (zh) 2024-05-02

Family

ID=90761583

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/114758 WO2024087840A1 (zh) 2022-10-26 2023-08-24 资源管控方法、装置、芯片、电子设备及介质

Country Status (2)

Country Link
CN (1) CN117931418A (zh)
WO (1) WO2024087840A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109388491A (zh) * 2018-08-23 2019-02-26 深圳点猫科技有限公司 一种提高教育操作系统的画面流畅度的方法及系统
CN110633137A (zh) * 2019-08-28 2019-12-31 北京安云世纪科技有限公司 一种应用程序的安装包启动方法、装置及电子设备
US20200341815A1 (en) * 2019-04-26 2020-10-29 Salesforce.Com, Inc. Assignment of resources to database connection processes based on application information
WO2021208627A1 (zh) * 2020-04-13 2021-10-21 荣耀终端有限公司 一种任务调度方法、装置及电子设备

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2097815B1 (en) * 2006-12-27 2019-04-17 Pivotal Software, Inc. Method and system for transaction resource control
CN105320561B (zh) * 2015-11-09 2019-03-08 深圳市万普拉斯科技有限公司 任务管理方法和系统
CN106484537B (zh) * 2016-09-30 2019-07-19 网易(杭州)网络有限公司 一种cpu核资源的分配方法和设备
CN107526640B (zh) * 2017-08-17 2020-03-27 Oppo广东移动通信有限公司 资源管理方法、装置、移动终端及计算机可读存储介质
CN110806926A (zh) * 2019-09-05 2020-02-18 华为技术有限公司 一种资源管控方法及设备
CN113495787A (zh) * 2020-04-03 2021-10-12 Oppo广东移动通信有限公司 资源分配方法、装置、存储介质及电子设备
CN113495780A (zh) * 2020-04-07 2021-10-12 Oppo广东移动通信有限公司 任务调度方法、装置、存储介质及电子设备
CN111831433A (zh) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 资源分配方法、装置、存储介质及电子设备
CN114461360A (zh) * 2022-01-11 2022-05-10 北京小米移动软件有限公司 线程管控方法、线程管控装置、终端及存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109388491A (zh) * 2018-08-23 2019-02-26 深圳点猫科技有限公司 一种提高教育操作系统的画面流畅度的方法及系统
US20200341815A1 (en) * 2019-04-26 2020-10-29 Salesforce.Com, Inc. Assignment of resources to database connection processes based on application information
CN110633137A (zh) * 2019-08-28 2019-12-31 北京安云世纪科技有限公司 一种应用程序的安装包启动方法、装置及电子设备
WO2021208627A1 (zh) * 2020-04-13 2021-10-21 荣耀终端有限公司 一种任务调度方法、装置及电子设备

Also Published As

Publication number Publication date
CN117931418A (zh) 2024-04-26

Similar Documents

Publication Publication Date Title
US11430358B2 (en) Frequency adjustment method and apparatus applied to terminal, and electronic device
WO2020108356A1 (zh) 一种应用显示方法及电子设备
EP3789875A1 (en) Task processing method, apparatus, terminal, and computer readable storage medium
WO2021052415A1 (zh) 资源调度方法及电子设备
CN112947947B (zh) 安装包的下载方法、分发方法、终端设备、服务器及系统
EP4130969B1 (en) Method and device for adjusting memory configuration parameter
WO2021052070A1 (zh) 一种帧率识别方法及电子设备
WO2021052139A1 (zh) 手势输入方法及电子设备
WO2020042112A1 (zh) 一种终端对ai任务支持能力的评测方法及终端
CN115292052B (zh) 内存回收方法、电子设备及计算机可读存储介质
WO2021223539A1 (zh) 射频资源分配方法及装置
WO2022100141A1 (zh) 插件管理方法、系统及装置
WO2022078105A1 (zh) 内存管理方法、电子设备以及计算机可读存储介质
CN113535340A (zh) 一种任务调度方法、装置及电子设备
CN116680153B (zh) 应用帧率平滑方法、电子设备及存储介质
WO2021155709A1 (zh) 一种充电控制方法及电子设备
CN114968540A (zh) 一种核间迁移的频率调整方法
CN117130773B (zh) 资源分配方法、装置和设备
EP4280060A1 (en) Power consumption control method and apparatus
CN111104209B (zh) 一种处理任务的方法及相关设备
WO2024087840A1 (zh) 资源管控方法、装置、芯片、电子设备及介质
WO2021238376A1 (zh) 功能包的加载方法、装置、服务器和电子设备
CN114828098B (zh) 数据传输方法和电子设备
WO2024002189A1 (zh) 处理器资源隔离方法、装置、电子设备及介质
WO2024169332A1 (zh) 处理器频率的调整方法、电子设备及芯片系统

Legal Events

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

Ref document number: 23881423

Country of ref document: EP

Kind code of ref document: A1