CPU resource management method and related device

By identifying application scenarios, reserving CPU resources in advance and executing killing strategies, it solves the problem of application lag in electronic devices, achieves efficient management of CPU resources and improves user experience.

CN117349006BActive Publication Date: 2024-10-18HONOR DEVICE CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202311194767.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-14
Publication Date
2024-10-18
Estimated Expiration
2043-09-14

AI Technical Summary

Technical Problem

Users may experience application lags when using electronic devices, mainly due to high load problems caused by insufficient CPU resources. It is difficult to effectively reserve and manage CPU resources with existing technology to avoid lags.

Method used

By identifying the application scenarios triggered by the user, the electronic device reserves the required CPU resources in advance, uses the CPU resource utilization and recovery rate in the preset file to calculate the actual required CPU resource proportion, and executes the corresponding response based on the idle rate difference. The CPU scanning and killing strategy cleans up unnecessary processes and services to increase the CPU idle rate.

Benefits of technology

It effectively reduces the lag of electronic devices, ensures sufficient CPU resources when applications are running, improves user experience, and avoids the impact of excessive scanning and killing on users through reasonable management of processes and services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117349006B_ABST
    Figure CN117349006B_ABST
Patent Text Reader

Abstract

The CPU resource management method and related device provided in the embodiment of the present application relate to the field of terminal technology. The method includes: in response to the user's triggering operation, the electronic device can identify the application scenario triggered by the user and reserve the required CPU resources for the application scenario in advance, so that the CPU resources required for the scenario triggered by the user are relatively sufficient, thereby reducing the lag of the electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a CPU resource management method and related devices. Background Art

[0002] Electronic devices can support the installation of various types of applications, such as game applications, short video applications, etc. Users can use applications to play games, watch short videos, or browse the web.

[0003] However, when users are using the app, they may experience app freezes. Summary of the invention

[0004] The CPU resource management method and related devices provided in the embodiments of the present application can, in response to a user's triggering operation, enable the electronic device to identify the application scenario triggered by the user and reserve the required CPU resources for the application scenario in advance. This can ensure that the CPU resources required for the scenario triggered by the user are relatively sufficient, thereby reducing the lag of the electronic device.

[0005] In a first aspect, the CPU resource management method provided by the embodiment of the present application includes:

[0006] The electronic device displays the interface of the first application; in response to the user's operation of entering the interface of the second application from the interface of the first application, the electronic device queries the first preset file to obtain a first value and a second value, wherein the first value is the CPU resource utilization rate required for the electronic device to display the interface of the second application, and the second value is the CPU resource recovery rate when the first application retreats to the background; the electronic device obtains a third value based on the first value and the second value, and the third value is the CPU resource utilization rate required when the electronic device enters the interface of the second application from the interface of the first application; if the third value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate. In this way, the CPU resources required by the electronic device can be more sufficient, thereby reducing the jamming of the electronic device.

[0007] In a possible implementation, the CPU of the electronic device includes n cores, where n is an integer greater than or equal to 1, and the first value is proportional to the following values: the time that the electronic device occupies n cores when displaying the interface of the second application, and the weight of the n cores; the second value is proportional to the time that the interface of the first application occupies n cores when displayed in the foreground, and inversely proportional to the time that the first application occupies n cores when running in the background. In this way, the CPU state reservation mechanism can calculate the corresponding reserved resource ratio and fallback resource ratio for different scenarios of each application, and then obtain the CPU resource ratio required when the application is running.

[0008] In one possible implementation, the first value satisfies the following formula:

[0009]

[0010] Among them, source rate is the first value, m is the preset time period, n is the number of CPU cores, coreN i,j,time The time that the electronic device occupies the jth core when displaying the interface of the second application, coreN i,j,weight is the weight of the jth kernel; the second value satisfies the following formula:

[0011]

[0012] Among them, subside rate is the second value, coreN i,j,fg is the time that the first application interface occupies the jth core when it is displayed in the foreground, coreN i,j,bg The time that the first application occupies the jth core when running in the background. In this way, CPU resources can be reserved in advance, thereby reducing the high CPU load.

[0013] In a possible implementation, the third value is the difference between the first value and the second value. In this way, when calculating the third value, the reserved resource ratio and the fallback resource ratio are considered at the same time, and the actual required CPU resource ratio can be calculated more accurately and reasonably, so that the corresponding CPU killing can be performed.

[0014] In a possible implementation, the electronic device improves the CPU resource idle rate, including: the electronic device obtains a fourth value based on the difference between the third value and the CPU resource idle rate, the electronic device searches the second preset file for a strategy for improving the CPU resource idle rate corresponding to the fourth value; and the electronic device executes the strategy for improving the CPU resource idle rate corresponding to the fourth value. In this way, the execution module performs CPU killing according to the killing level, which can reasonably manage the processes or services in the electronic device, so that too many processes or services will not be killed, thereby improving the user experience.

[0015] In one possible implementation, the second preset file includes multiple intervals. If the fourth value is in the first interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: processes of foreground applications, processes of user-visible applications, processes of user-perceivable background applications, processes of backup tasks, background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and are not used for part of the third preset time period, processes of cached background applications, and empty processes; if the fourth value is in the second interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds If the fourth value is in the third interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: the service whose running time exceeds the third preset time period and is not used in part of the third preset time period, the process of cached background application, and the empty process; if the fourth value is in the fourth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: the process of cached background application, the empty process; if the fourth value is in the fifth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes: the electronic device cleaning up the empty process; wherein the value in the first interval is greater than the value in the second interval, the value in the second interval is greater than the value in the third interval, the value in the third interval is greater than the value in the fourth interval, and the value in the fourth interval is greater than the value in the fifth interval. In this way, the execution module performs CPU killing according to the killing level, which can reasonably manage the processes or services in the electronic device, so that the processes or services with lower priority can be killed first, reducing the impact on the user experience.

[0016] In a possible implementation, when the electronic device executes the policy corresponding to the fourth value to increase the idle rate of CPU resources, if the policy includes applications or services that are not allowed to be cleaned, then the applications or services that are not allowed to be cleaned will not be cleaned; wherein, the applications or services that are not allowed to be cleaned include: applications or services in the preset application list, and / or applications or services whose user usage frequency is higher than a threshold among applications loaded by the electronic device, and / or applications or services ranked in the top Q in user usage frequency among applications loaded by the electronic device. In this way, the policy includes applications or services that are not allowed to be cleaned, so that some of the more important applications in the system can be added to the application whitelist, so that the applications will not be killed, and thus will not affect the user experience.

[0017] In a possible implementation, the method further includes: if the electronic device needs to increase the idle rate of the CPU resource when increasing the idle rate of the memory, the electronic device first increases the idle rate of the memory. In this way, the priority of memory killing and CPU killing can prevent the same process or system resource from being killed multiple times, avoid the killing process from becoming redundant, and reduce the probability of abnormalities in the electronic device during operation.

[0018] In a possible implementation, after the electronic device increases the memory idle rate, the electronic device further includes: updating the CPU resource idle rate; if the third value is greater than the updated CPU resource idle rate, the electronic device continues to increase the CPU resource idle rate. In this way, the killing module can be flexibly controlled to kill processes or services, so that the electronic device will not kill processes or services excessively, thereby reducing the impact on users.

[0019] In a possible implementation, after the electronic device increases the CPU resource idle rate, it further includes: if the difference between the increased CPU resource idle rate and the third value is greater than or equal to the first preset threshold, then reducing the first value and / or increasing the second value; if the difference between the increased CPU resource idle rate and the third value is less than the second preset threshold, then increasing the first value and / or decreasing the second value. In this way, the CPU state reservation mechanism can more accurately calculate the required CPU resources based on the CPU resources recovered after the CPU is checked and killed.

[0020] In a possible implementation, the method further includes: in response to the user sliding operation in the first interface of the second application, the electronic device queries the first preset file to obtain a fifth value and a sixth value, wherein the fifth value is the CPU resource utilization rate required by the electronic device to display the interface after the first interface slides, and the sixth value is the CPU resource recovery rate when the electronic device exits the interface before the first interface slides; the electronic device obtains a seventh value based on the fifth value and the sixth value, and the seventh value is the CPU resource utilization rate required when the electronic device slides in the first interface; if the seventh value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate. In this way, the CPU resources required when the application interface slides can be relatively sufficient, thereby reducing the jamming of the electronic device.

[0021] In a possible implementation, the method further includes: in response to the user's operation of entering the second interface of the second application from the first interface, the electronic device queries the first preset file to obtain an eighth value and a ninth value, wherein the eighth value is the CPU resource utilization rate required for the electronic device to display the second interface, and the ninth value is the CPU resource recovery rate when the electronic device exits the display of the first interface; the electronic device obtains a tenth value based on the eighth value and the ninth value, and the tenth value is the CPU resource utilization rate required when the electronic device enters the second interface from the first interface; if the tenth value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate. In this way, in response to the user's triggering operation, the electronic device can reserve the required CPU resources in advance before the application interface jumps, thereby reducing the jamming of the electronic device.

[0022] In a second aspect, an embodiment of the present application provides a device for CPU resource management, which may be an electronic device, or a chip or chip system in an electronic device. The device may include a processing unit and a display unit. The processing unit is used to implement any method related to processing performed by the electronic device in the first aspect or any possible implementation of the first aspect. The display unit is used to implement any method related to display performed by the electronic device in the first aspect or any possible implementation of the first aspect. When the device is an electronic device, the processing unit may be a processor. The device may also include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit so that the electronic device implements the method described in the first aspect or any possible implementation of the first aspect. When the device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements the method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit in the chip (for example, a register, a cache, etc.), or a storage unit in the electronic device located outside the chip (for example, a read-only memory, a random access memory, etc.).

[0023] Exemplarily, the display unit is used to display the interface of the first application. The processing unit is used for the electronic device to query the first preset file to obtain the first value and the second value, and also to obtain the third value based on the first value and the second value, and specifically to improve the CPU resource idle rate.

[0024] In one possible implementation, the CPU of the electronic device includes n cores, where n is an integer greater than or equal to 1, and the first value is proportional to the following values: the time the electronic device occupies the n cores when displaying the interface of the second application, and the weight of the n cores; the second value is proportional to the time the interface of the first application occupies the n cores when displayed in the foreground, and inversely proportional to the time the first application occupies the n cores when running in the background.

[0025] In a possible implementation, the first value satisfies the following formula:

[0026]

[0027] Among them, source rate is the first value, m is the preset time period, n is the number of CPU cores, coreN i,j,time The time that the electronic device occupies the jth core when displaying the interface of the second application, coreN i,j,weight is the weight of the jth kernel;

[0028] The second value satisfies the following formula:

[0029]

[0030] Among them, subside rate is the second value, coreN i,j,fg is the time that the first application interface occupies the jth core when it is displayed in the foreground, coreN i,j,bg The time that the first application occupies the jth core when running in the background.

[0031] In a possible implementation, the third value is a difference between the first value and the second value.

[0032] In one possible implementation, the processing unit is used to obtain a fourth value based on the difference between the third value and the CPU resource idle rate, and is also used to query the strategy for increasing the CPU resource idle rate corresponding to the fourth value in the second preset file, and is specifically used to execute the strategy for increasing the CPU resource idle rate corresponding to the fourth value.

[0033] In one possible implementation, the second preset file includes multiple intervals. If the fourth value is in the first interval, the strategy for improving the CPU resource idle rate corresponding to the fourth value includes the electronic device cleaning up one or more of the following: processes of foreground applications, processes of user-visible applications, processes of user-perceivable background applications, processes of backup tasks, background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and are not used for part of the third preset time period, processes of cached background applications, and empty processes; if the fourth value is in the second interval, the strategy for improving the CPU resource idle rate corresponding to the fourth value includes the electronic device cleaning up one or more of the following: background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and is not used for part of the time period within the third preset time period, processes of cached background applications, and empty processes. services, cached background application processes, and empty processes that exceed the third preset time period and are not used for a portion of the third preset time period; if the fourth value is in the third interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: services, cached background application processes, and empty processes that have been running for a period of time exceeding the third preset time period and are not used for a portion of the third preset time period; if the fourth value is in the fourth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: cached background application processes and empty processes; if the fourth value is in the fifth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes: the electronic device cleaning up empty processes; wherein, the value in the first interval is greater than the value in the second interval, the value in the second interval is greater than the value in the third interval, the value in the third interval is greater than the value in the fourth interval, and the value in the fourth interval is greater than the value in the fifth interval.

[0034] In a possible implementation, the processing unit is configured to not clean up the applications or services that are not allowed to be cleaned up if the policy includes the applications or services that are not allowed to be cleaned up.

[0035] In a possible implementation, the processing unit is used to increase the memory idle rate first if the electronic device needs to increase the CPU resource idle rate and also needs to increase the memory idle rate.

[0036] In a possible implementation, the processing unit is used to update the CPU resource idle rate and further to continue to improve the CPU resource idle rate.

[0037] In one possible implementation, the processing unit is used to reduce the first value and / or increase the second value if the difference between the increased CPU resource idle rate and the third value is greater than or equal to the first preset threshold, and is also used to increase the first value and / or reduce the second value if the difference between the increased CPU resource idle rate and the third value is less than the second preset threshold.

[0038] In one possible implementation, the processing unit is used to query the first preset file to obtain the fifth value and the sixth value, and is also used to obtain the seventh value based on the fifth value and the sixth value, and is specifically used to increase the CPU resource idle rate if the seventh value is greater than the CPU resource idle rate.

[0039] In one possible implementation, the processing unit is used to query the first preset file to obtain the eighth value and the ninth value, and is also used to obtain the tenth value based on the eighth value and the ninth value, and is specifically used to increase the CPU resource idle rate if the tenth value is greater than the CPU resource idle rate.

[0040] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, the memory being used to store code instructions, and the processor being used to run the code instructions to execute the method described in the first aspect or any possible implementation of the first aspect.

[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.

[0042] In a fifth aspect, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect or any possible implementation manner of the first aspect.

[0043] In a sixth aspect, the present application provides a chip or a chip system, the chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.

[0044] In a possible implementation, the chip or chip system described above in the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).

[0045] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0047] Figure 2 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;

[0048] Figure 3 A framework diagram of a CPU resource management method provided in an embodiment of the present application;

[0049] Figure 4 A flowchart of a CPU resource management method provided in an embodiment of the present application;

[0050] Figure 5 A schematic diagram of an implementation flow of a CPU state reservation mechanism provided in an embodiment of the present application;

[0051] Figure 6 A flowchart of coupling implementation of CPU killing and memory killing provided in an embodiment of the present application;

[0052] Figure 7 A schematic diagram of a CPU resource management method provided in an embodiment of the present application;

[0053] Figure 8 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:

[0055] 1. Terminology

[0056] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0057] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0058] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.

[0059] 2. Electronic equipment

[0060] The electronic device of the embodiment of the present application may also be a terminal device in any form. For example, the electronic device may include: a mobile phone, a tablet computer, a PDA, a laptop computer, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, a cellular phone, a cordless phone, a session initiation protocol (SIP) phone, a wireless local loop (WLL) station, a personal digital assistant (PDA), a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a wearable device, an electronic device in a 5G network or a public land mobile communication network (public land mobile communication network) to be evolved in the future. Mobile network, PLMN) and the like, the embodiments of the present application are not limited to this.

[0061] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

[0062] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.

[0063] The electronic devices in the embodiments of the present application may also be referred to as: user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.

[0064] In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0065] For example, Figure 1 A schematic structural diagram of an electronic device is shown.

[0066] The electronic device 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. 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.

[0067] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented by hardware, software, or a combination of software and hardware.

[0068] 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. Different processing units may be independent devices or integrated into one or more processors.

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

[0070] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, 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.

[0071] In some embodiments, 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 SIM card interface, and / or a USB interface, etc.

[0072] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0073] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, 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 (such as audio data, a phone book, etc.), etc. In addition, 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 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.

[0074] Figure 2It is a software structure block diagram of the electronic device of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, the hardware abstraction layer (hardware adaptation layer, HAL), and the kernel layer.

[0075] The application layer can also be called the application layer, which can include a series of application packages. Figure 2 As shown, the application package may include applications such as phone, music, calendar, camera, game, memo, video, etc. Applications may include system applications and third-party applications.

[0076] The application framework layer can also be called the Framework layer. The Framework layer can provide an application programming interface (API) and a programming framework for the application layer's applications. The Framework layer can include some predefined functions.

[0077] like Figure 2 As shown, the Framework layer may include an input event detection module InputReader, a desktop launcher Launcher, a system service SystemServer, a resource manager, and a content provider, etc.

[0078] The input event detection module InputReader can be used to detect user input events received by the electronic device. For example, the input event may include user single-click, double-click, long-press, slide and other operation events.

[0079] The desktop launcher Launcher can be used to launch applications.

[0080] The system service SystemServer may include a decision module and a configuration module. The decision module may include a status warning module, which may include a CPU status threshold strategy and a CPU status reservation mechanism. The configuration module may include a CPU killing configuration center and a system application management and control interface.

[0081] Among them, the CPU state threshold policy can be used to monitor whether the CPU state reaches a threshold that requires control and killing of applications. The threshold can also be called a threshold or a threshold of the CPU high load state.

[0082] The CPU state reservation mechanism can be used to generate the CPU reserved resource table cpu_pre.xml. When the electronic device is performing application detection and killing, the CPU state reservation mechanism can determine whether it is necessary to reserve some CPU resources for a certain application based on the CPU reserved resource table cpu_pre.xml, and determine the reserved resource ratio and fallback resource ratio of a certain process. In addition, after the electronic device detects and kills the application, the CPU state reservation mechanism can also count the situation of the fallen CPU resources, so that the CPU resource occupation of each process can be accurately understood, which is convenient for calculating the resources that need to be reserved for each process next time.

[0083] The CPU killing configuration center can be used to generate a CPU killing configuration table cpu_adj. When the electronic device performs application killing, it can perform application killing according to the killing level in the CPU killing configuration table cpu_adj.

[0084] The system application control interface can provide some application control interfaces for the CPU killing configuration center. Through the application control interface, the CPU killing configuration center can obtain the application blacklist, application whitelist, and other application control mechanisms, so as to determine which applications can be killed or which applications cannot be killed.

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

[0086] Content providers are used to implement data sharing between different applications, allowing one program to access data in another program while ensuring the security of the accessed data.

[0087] Android runtime includes core libraries and virtual machines. Android runtime is responsible for the control and management of the Android system.

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

[0089] The application layer and the framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection. For example, in the embodiment of the present application, the virtual machine can be used to perform CPU status collection, calculation of reserved resource ratio and fallback resource ratio, and application killing and cleaning functions.

[0090] The system library may also be referred to as the Native layer, and the Native layer may include multiple functional modules, such as function libraries, graphics processing libraries (eg, OpenGL ES), etc. In the embodiment of the present application, the Native layer may also include a performance radar identification module.

[0091] The function library provides developers with API interfaces for multiple services, making it easy for developers to quickly integrate and implement various functions.

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

[0093] The performance radar identification module can be used to identify the current application scenario. Among them, the application scenario can include the application startup scenario, sliding scenario, transition scenario, etc. The startup scenario can be understood as the scenario when the application is started, and the startup scenario can also be called the cold start scenario; the sliding scenario can be understood as the scenario where the user slides up, slides down, slides left, and slides right; the transition scenario can be understood as the scenario of jumping from the application interface 1 to the application interface 2.

[0094] The hardware abstraction layer is an abstract structure between the kernel layer and the Android runtime. The hardware abstraction layer can be a package of hardware drivers, providing a unified interface for upper-layer applications to call.

[0095] The kernel layer is a layer between hardware and software. The kernel layer may include display driver, camera driver, audio driver, CPU driver, etc. In the embodiment of the present application, the kernel layer may also include a state acquisition module and an execution module.

[0096] The status acquisition module can be used to obtain information such as CPU resource usage, average utilization of each core in the system, CPU occupancy ranking table, CPU load distribution, etc. Among them, the CPU occupancy ranking table can be understood as a ranking table of CPU resources occupied by each application when running.

[0097] The execution module may include a killing module, which may execute processes such as CPU killing and memory killing. For example, when the threshold of the CPU high load state is reached, the killing module may kill and clean up the application according to the CPU killing configuration table cpu_adj, and this process may also be called CPU killing. In addition, after the CPU killing, the killing module may also allocate the remaining CPU resources and coordinate between the CPU multi-cores.

[0098] It should be noted that the embodiments of the present application are only illustrated using the Android system as an example. In other operating systems (such as Windows system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of the present application, the solutions of the present application can also be implemented.

[0099] Electronic devices can support the installation of various types of applications, such as game applications, short video applications, etc. Users can use applications to play games, watch short videos, or browse web pages, etc. However, when users use applications, the application may freeze.

[0100] In some scenarios, even if the electronic device has sufficient memory, the application may still freeze. This is because the CPU load is high. When the CPU is highly loaded, the operation of each CPU core may reach full load, making it difficult for the CPU cores to schedule, causing the electronic device to freeze and reducing the user experience.

[0101] In view of this, the CPU resource management method provided in the embodiment of the present application can, in response to the user's triggering operation, enable the electronic device to identify the application scenario triggered by the user and reserve the required CPU resources for the application scenario in advance. This can ensure that the CPU resources required for the scenario triggered by the user are relatively sufficient, thereby reducing the lag of the electronic device.

[0102] Figure 3 A framework diagram of a CPU resource management method is shown.

[0103] The framework diagram of the CPU resource management method may include the following modules: state acquisition module, configuration module, decision module and execution module. The specific functions of each module can be referred to above. Figure 2 The relevant descriptions in the corresponding embodiments are not repeated here.

[0104] In a possible implementation, after acquiring the CPU load and CPU usage status, the status acquisition module may send the acquired information to the status warning module in the decision module.

[0105] The CPU state reservation mechanism in the status warning module can query the CPU state user usage habits from the CPU killing configuration center of the configuration module. The CPU state reservation mechanism can calculate the CPU resources required for application runtime based on the user usage habits, and pass the required CPU resources to the CPU state threshold policy in the status warning module. The specific implementation of the CPU state reservation mechanism to calculate the required CPU resources can be referred to Figure 5 Related description in the corresponding embodiment.

[0106] The CPU state threshold policy can be combined with the required CPU resources delivered by the CPU state reservation mechanism to determine whether the threshold of the CPU high load state is reached.

[0107] If the CPU state threshold policy determines that the CPU high load state threshold is reached, the state warning module can trigger the killing module of the execution module to perform CPU killing. For example, the killing module can kill and clean up the application according to the CPU killing configuration table cpu_adj generated by the CPU killing configuration center.

[0108] After the killing module completes the CPU killing, some CPU resources can be recovered. The killing module can also allocate the remaining CPU resources and coordinate CPU resources among multiple cores, thereby reducing the CPU load and reducing the lag of electronic devices.

[0109] In addition, the killing module can also feed back the CPU resource situation recovered after the CPU is killed to the CPU state reservation mechanism in the status warning module. In a possible implementation, if the difference between the proportion of recovered CPU resources and the proportion of required CPU resources after the CPU is killed is greater than or equal to the first threshold, it means that the recovered CPU resources are more, and the proportion of reserved resources can be appropriately reduced, and / or the proportion of fallback resources can be appropriately increased; if the difference between the proportion of recovered CPU resources and the proportion of required CPU resources after the CPU is killed is less than the second threshold, it means that the recovered CPU resources are less, and the proportion of reserved resources can be appropriately increased, and / or the proportion of fallback resources can be appropriately reduced. Among them, the first threshold and the second threshold can be pre-set by the electronic device, and the specific first threshold and the second threshold are not limited in the embodiments of the present application. In this way, the CPU state reservation mechanism can more accurately calculate the required CPU resources based on the situation of the CPU resources recovered after the CPU is killed.

[0110] It is understandable that when the CPU killing configuration center generates the CPU killing configuration table cpu_adj, on the one hand, the CPU killing configuration center can generate the table in combination with the CPU status user usage habits. The CPU killing configuration center can determine the CPU resource occupancy value between different applications based on the user's high-frequency usage scenarios, as well as the usage habits of opening and operating applications. For example, when a user uses an application more frequently, the CPU killing configuration center can assign a higher killing level to the application. In this way, when the killing module is killing applications, it can make it less likely that the user's frequently used applications will be killed, thereby improving the user experience.

[0111] On the other hand, the CPU killing configuration center can also query the application blacklist, application whitelist, and other application control mechanisms provided by the system application control interface to generate the table. For example, if some applications in the system are more important, or some applications will affect the user experience after being killed, the system can add these applications to the application whitelist, so that when the killing module is killing applications, these applications will not be killed.

[0112] In addition, the application control mechanism may also include: not cleaning up applications or services whose user usage frequency is higher than a threshold among applications loaded by the electronic device, and / or not cleaning up applications or services whose user usage frequency is ranked higher among applications loaded by the electronic device. The specific number of applications or services ranked higher can be preset by the electronic device, and the embodiments of the present application are not limited thereto.

[0113] Figure 4 A flow chart of a CPU resource management method is shown.

[0114] S401, the application obtains CPU resources.

[0115] When an application is started, the application needs to obtain CPU resources. For example, the application can obtain CPU resources to start a process, allocate application memory, and process application data. It is understandable that the application also needs to obtain CPU resources during operation. For example, the application needs CPU resources to execute various instructions and process application data.

[0116] S402: The status acquisition module obtains the current CPU usage and load.

[0117] In a possible implementation, the state acquisition module can obtain information such as CPU usage and CPU load when the electronic device receives a user operation, and the user operation may include a single-click operation, a double-click operation, a sliding operation, etc. The state acquisition module can also obtain information such as CPU usage and CPU load when the application obtains CPU resources. The state acquisition module can also periodically obtain information such as CPU usage and CPU load, wherein the acquisition period can be pre-set by the electronic device, and the specific period value is not limited in the embodiment of the present application.

[0118] S403: The user clicks an application icon.

[0119] When a user clicks an application icon in the application layer, the input event detection module InputReader in the Framework layer can detect the event of the user clicking the application and pass the event to the desktop launcher Launcher in the Framework layer.

[0120] S404, the desktop launcher Launcher starts the application.

[0121] After the desktop launcher receives the event that the user clicks on an application, it can start the application.

[0122] S405. The performance radar identification module identifies the current application scenario.

[0123] The performance radar recognition module of the Native layer can identify the current application scenario, which may include the application startup scenario, sliding scenario, transition scenario, etc.

[0124] In a possible implementation, when the input event detection module InputReader detects an event of a user operating an electronic device, the performance radar recognition module can be triggered to detect the current application scenario. For example, in the above step S403, when the input event detection module InputReader detects an event of a user clicking on an application, the event can be reported to the performance radar recognition module, and the performance radar recognition module can recognize that the current application scenario is the startup scenario of the application.

[0125] After identifying the current application scenario, the performance radar identification module may execute step S406 to obtain the reserved resource ratio and the fallback resource ratio required by the current application scenario.

[0126] S406. The performance radar identification module obtains the reserved resources and fallback resources required for the current application scenario.

[0127] The performance radar identification module can obtain the reserved resource ratio and fallback resource ratio required by the current application scenario through the system service SystemServer of the Framework layer. Among them, the reserved resource ratio can also be referred to as reserved resources, and the fallback resource ratio can also be referred to as fallback resources.

[0128] In a possible implementation, the system service SystemServer may include a status warning module, and the CPU status reservation mechanism in the status warning module may generate a CPU reserved resource table cpu_pre.xml. The performance radar identification module may obtain the reserved resource ratio and fallback resource ratio required by the current application scenario through the CPU reserved resource table cpu_pre.xml.

[0129] Among them, different application scenarios of each application may have corresponding different reserved resource ratios and fallback resource ratios. For example, the startup scenario of application 1 has corresponding reserved resource ratios and fallback resource ratios, the sliding scenario of application 1 may have corresponding reserved resource ratios and fallback resource ratios, and the transition scenario of application 1 may also have corresponding reserved resource ratios and fallback resource ratios. In addition, the reserved resource ratios of different applications may be different, and the fallback resource ratios of different applications may also be different.

[0130] Taking application 1 as an example, when application 1 is started, the electronic device needs some CPU resources to start application 1. The reserved resource ratio of application 1 in the startup scenario in the CPU reserved resource table cpu_pre.xml can represent the CPU resources required when application 1 is started. When the electronic device jumps from the interface of application 1 to the interface of application 2, since application 1 will exit the foreground of the electronic device, at this time, the CPU resources required by application 1 are reduced, and there is a situation of CPU resource fallback. The fallback resource ratio of application 1 in the CPU reserved resource table cpu_pre.xml can represent the CPU fallback resources when application 1 exits the foreground of the electronic device.

[0131] The CPU status threshold policy in the status warning module can determine whether the threshold of the CPU high load state is reached based on the reserved resource ratio and the fallback resource ratio of the current application scenario in the table.

[0132] It can be understood that the CPU state reservation mechanism of the decision module obtains the reserved resource ratio and the fallback resource ratio required for the current application scenario, and the CPU state threshold strategy of the decision module determines whether the threshold of the CPU high load state is reached. The process can also be implemented in the kernel layer and can also be implemented in other software architecture layers of the electronic device, which is not limited to the embodiments of the present application.

[0133] S407: The decision module determines whether a threshold is reached.

[0134] The CPU state reservation mechanism of the decision module can calculate the currently required CPU resource ratio according to the reserved resource ratio and the fallback resource ratio of the current application scenario in the CPU reserved resource table cpu_pre.xml, and pass the required CPU resource ratio to the CPU state threshold policy.

[0135] For example, taking the case where an electronic device jumps from the interface of application 1 to the interface of application 2 as an example, the CPU state reservation mechanism can determine the CPU resource ratio currently required to jump from the interface of application 1 to the interface of application 2 by calculating the difference between the reserved resource ratio when application 2 is started and the fallback resource ratio when application 1 exits the foreground. For example, if the reserved resource ratio when application 2 is started is 30%, and the fallback resource ratio when application 1 exits the foreground is 10%, then the CPU resource ratio required to jump from the interface of application 1 to the interface of application 2 may be 20%.

[0136] The CPU status threshold policy of the decision module can determine whether the current CPU remaining resource ratio can meet the currently required CPU resource ratio. When the CPU remaining resource ratio is greater than or equal to the currently required CPU resource ratio, it means that the threshold of the CPU high load state has not been reached, and the CPU killing can be performed. When the CPU remaining resource ratio is less than the currently required CPU resource ratio, it means that the threshold of the CPU high load state has been reached, and the CPU killing can be performed.

[0137] For example, assuming that the current CPU resource occupancy rate is 80%, that is, the current CPU remaining resource ratio is 20%. If the currently required CPU resource ratio is 10%, then the CPU remaining resource ratio is greater than the currently required CPU resource ratio, indicating that the CPU resources are sufficient and CPU killing can be performed; if the currently required CPU resource ratio is 30%, then the CPU remaining resource ratio is less than the currently required CPU resource ratio, indicating that the CPU resources are not sufficient and CPU killing can be performed. Among them, the CPU resource occupancy rate can also be understood as the CPU resource utilization rate, and the CPU remaining resource ratio can also be understood as the CPU idle resource ratio.

[0138] S408: The execution module searches for applications that need to be checked and killed.

[0139] The execution module can determine the applications that need to be killed through the configuration module of the system service SystemServer. Among them, the CPU killing configuration center in the configuration module can include a CPU killing configuration table cpu_adj, which can be sorted according to CPU usage and set different thresholds for different CPU usages. When the threshold of the CPU high load state is reached, the execution module can kill and clean up the application based on the CPU killing configuration table cpu_adj.

[0140] For example, assuming that the current CPU usage is 80%, the CPU idle resource ratio is 20%. If the CPU state reservation mechanism calculates that 30% of the CPU resources are currently required, since the current CPU idle resource ratio of 20% is less than the currently required CPU resource ratio of 30%, the CPU state threshold policy can determine that the current threshold of the CPU high load state has been reached, and the decision module can trigger the execution module to perform CPU killing.

[0141] When the execution module performs CPU killing according to the CPU killing configuration table cpu_adj, since the current CPU idle resource accounts for 20% and the current required CPU resource accounts for 30%, that is, 10% of the CPU resources need to be recovered to meet the current required 30% of the CPU resources, the current killing level can correspond to 10%. Accordingly, it can be determined from the following Table 1 that the execution module can kill some empty processes to recycle some CPU resources.

[0142] It is understandable that processes or services in electronic devices can be divided into multiple types. For example, they include foreground applications, user-visible applications, user-perceivable background applications, backup tasks, background applications without recovery capabilities, Class A application services, Class B application services, etc. In a possible implementation, the application management service (AMS) in the electronic device can determine the type of each process or service in the electronic device. For example, the electronic device can pass the package name of the application to the relevant interface of the AMS by calling the relevant interface of the AMS, and then the relevant interface of the AMS can return the type of the application process.

[0143] For example, Table 1 shows the corresponding relationship between the killing level and the process / service in the CPU killing configuration table cpu_adj. Among them, the processes that can be killed can include one or more of the following: the process of the foreground application, the process of the user-visible application, the process of the user-perceivable background application, the process of the backup task, the background process without recovery capability, the process of the previous application APP, the process of the cached background application, the empty process, etc. The services that can be killed can include one or more of the following: type A application service, type B application service, etc.

[0144] It is understandable that when the killing level is less than or equal to 10%, the execution module can kill empty processes; when the killing level is between 10% and 20%, the execution module can not only kill the processes of cached background applications, but also kill empty processes with lower killing levels. In other words, the execution module can kill processes or services corresponding to a certain killing level, and can also kill processes or services below the killing level. Therefore, the higher the killing level, the more types of processes or services can be killed, so that more CPU resources can be recovered and the jamming of electronic devices can be reduced.

[0145] Table 1

[0146]

[0147] S409, the execution module checks and kills applications, and CPU resources are reduced.

[0148] Killing an application can be understood as killing the application process or stopping the application from running. The specific implementation of killing an application is not limited in the present application embodiment. After killing the application, the execution module can recycle some CPU resources, which can relieve CPU load pressure, reduce the jamming of electronic devices, and improve user experience.

[0149] Figure 5 A schematic diagram of the implementation flow of the CPU state reservation mechanism is shown.

[0150] The CPU state reservation mechanism can calculate the proportion of CPU resources required by the application when it is running in combination with the user's usage habit scenario. The user's usage habit scenario may include (1) the application dimension and (2) the user's usage dimension.

[0151] (1) Application dimension

[0152] Since different applications may occupy different CPU resources when running, and the same application may occupy different CPU resources in different application scenarios, the CPU state reservation mechanism can calculate the corresponding reserved resource ratio and fallback resource ratio for different scenarios of each application, and then obtain the CPU resource ratio required for the application to run. Among them, the application scenario can include the application startup scenario, sliding scenario, transition scenario, etc., which can be specifically referred to above. Figure 2 The relevant descriptions in the corresponding embodiments are not repeated here.

[0153] (2) User usage dimension.

[0154] The CPU state reservation mechanism can also consider the proportion of CPU resources required when the application is running based on user usage habits. For example, when user A is using application 1, user A performs more editing operations, or needs to jump to other application processes in application 1, then application 1 occupies more CPU resources during operation. When user B is using application 1, user B performs more browsing operations, then application 1 occupies less CPU resources during operation. In this way, the CPU state reservation mechanism can reserve different proportions of CPU resources for the same application based on user usage habits.

[0155] Possible implementations, such as Figure 5 As shown in b, the CPU state reservation mechanism can obtain the CPU resources occupied by each application in the foreground of the electronic device for a preset time based on big data statistics. Figure 5 b in the table may also be referred to as an initial table or a CPU resource usage table. The preset time may also be referred to as a duration, which may be preset by the electronic device, for example, the duration may be 5 seconds (s), and the specific value of the duration is not limited in the embodiments of the present application.

[0156] For ease of description, the following description will take the application startup scenario with a preset time of 5 seconds as an example.

[0157] In the CPU resource proportion table, each application may have its own corresponding CPU time slice duration value and CPU resource proportion.

[0158] The CPU time slice duration value can be understood as the time value that an application occupies when running on each CPU core within 5 seconds, or the time value that the application uses the CPU. The CPU time slice duration value can be calculated based on the duration of each CPU core and the proportion of the CPU large core, medium core, and small core based on big data statistics. The proportion of the CPU large core, medium core, and small core can also be understood as the weight of the CPU large core, medium core, and small core.

[0159] Among them, when the occupancy time of each CPU core is counted based on big data, the statistics can be performed in the form of average value, interval value or extreme value, and the extreme value can also be understood as the maximum value. The embodiment of the present application does not limit the statistical method of big data. For example, taking the average value method to count the duration of application 1 on each CPU core as an example, for example, the big data can be counted to obtain within 5 seconds that the running time of application 1 on the large core is 1 second, the running time of application 1 on the medium core is 700 milliseconds (ms), and the running time of application 1 on the small core is 500ms.

[0160] Since applications occupy more CPU resources when running on large cores, and occupy less CPU resources when running on small cores, it is possible to set the corresponding weight of applications to be larger when running on large cores, and smaller when running on small cores. In a possible implementation, the weights of large cores, medium cores, and small cores of the CPU may include: large core: medium core: small core = 3:2:1. The weights of large cores, medium cores, and small cores of the CPU may also be set to other proportions, which are not limited in the embodiments of the present application.

[0161] In possible implementations, the proportion of CPU resources required to be reserved for each application scenariosource rate The following formula can be satisfied:

[0162]

[0163] Among them, m is the duration, n is the number of CPU cores, coreN i,j,time is the duration of the application occupying the jth core in a certain scenario, coreN i,j,weight is the weight of the jth kernel.

[0164] Similarly, the CPU fallback resource ratio when the application exits the foreground of the electronic device is subside rate The following formula can be satisfied:

[0165]

[0166] Among them, coreN i,j,fg is the time that the application occupies the jth core before exiting the foreground of the electronic device, coreN i,j,bg It is the time that the application occupies the jth core after exiting the foreground of the electronic device.

[0167] The CPU state reservation mechanism can calculate the CPU resource ratio required by the application at runtime based on the CPU resource ratio table, thereby generating the CPU reserved resource table cpu_pre.xml. Among them, the CPU resource ratio cpu_App_source_pre required by the application can satisfy the following formula:

[0168] cpu_App_source_pre=source rate -subside rcte .

[0169] Since the CPU resources occupied by applications in different application scenarios are different, the CPU state reservation mechanism can be considered from the application dimension. In different application scenarios, a corresponding CPU resource usage table is set for each application. Figure 5 As shown in c, the CPU resource usage table may include a CPU resource usage table of each application during cold start, a CPU resource usage table of each application during sliding within an application, and a CPU resource usage table of each application during transition within an application.

[0170] The CPU state reservation mechanism can be considered from the user usage dimension, and the CPU time slice duration value of each application is periodically sampled and counted, and then the CPU resource share table of each application is adjusted. In other words, the CPU state reservation mechanism can regularly update the reserved resource share and fallback resource share in the CPU resource share table. For example, if an application that is not counted by big data is used in a user's electronic device, the CPU state reservation mechanism can set the corresponding reserved resource share and fallback resource share for the application. Among them, the electronic device can pre-set the sampling period, for example, the sampling period can be one day or one week, and the specific sampling period is not limited in the embodiments of the present application.

[0171] It is understandable that during the operation of the electronic device, the killing module may receive a memory killing command and a CPU killing command at the same time. If the killing module executes memory killing and CPU killing at the same time, the same process or system resource may be killed multiple times, making the killing process redundant and may cause abnormal operation of the electronic device. Therefore, an embodiment of the present application provides a coupling implementation method of CPU killing and memory killing.

[0172] Figure 6 The flowchart of coupling implementation of CPU killing and memory killing is shown.

[0173] S601, the detection and killing module receives an external detection and killing command.

[0174] The killing module can receive an external killing command, such as a memory killing command, a CPU killing command, etc. For ease of description, the memory killing command and / or the CPU killing command will be used as an example for description.

[0175] When the killing module receives the memory killing command and / or the CPU killing command, step S602 may be executed.

[0176] S602: If it is a memory check command.

[0177] When receiving a kill command, the kill module can determine whether the kill command is a memory kill command.

[0178] If the killing module receives both the memory killing command and the CPU killing command at the same time, step S603 may be executed first, that is, the relevant process of executing the memory killing may be executed.

[0179] If the killing module only receives the memory killing command, step S603 can be executed to execute the relevant process of memory killing. If the killing module only receives the CPU killing command, step S609 can be executed to execute the relevant process of CPU killing.

[0180] S603: Query the status of the electronic device.

[0181] The electronic device status may include the memory status of the electronic device and the CPU status of the electronic device. When executing the memory check and kill process, the memory status of the electronic device may be queried. The memory status of the electronic device may include the total memory, available memory, memory usage, memory used by an application, and the memory limit size of an application.

[0182] After the antivirus module obtains the memory status, step S604 may be executed to determine whether memory antivirus is required.

[0183] S604: The memory scan module determines whether a memory scan is required according to the state of the electronic device.

[0184] If the killing module determines that the memory killing condition has been met, step S605 can be executed to perform memory killing. The specific memory killing condition can be set by the killing module, and the embodiment of the present application does not limit it.

[0185] If the killing module determines that the memory killing condition is not met, step S608 may be executed to determine whether a CPU killing command is received.

[0186] S605, memory check and kill.

[0187] Memory checking and killing may include processes such as killing some background processes and reclaiming memory. For example, the checking and killing module may reclaim some unused memory resources or processes in the background. The specific memory checking and killing process may be set by the checking and killing module, and is not limited in the embodiments of the present application.

[0188] S606: Process pool update.

[0189] After executing memory check or CPU check, some processes in the process pool may be killed. Therefore, the process pool will change and be updated to the latest status after memory check or CPU check.

[0190] S607: Update the status of the electronic device.

[0191] After the memory check or CPU check, since the memory resources or CPU resources can be recovered, the state of the electronic device will also change and be updated to the latest state of the electronic device.

[0192] S608: Whether a CPU kill command is received.

[0193] After executing the memory killing, if the killing module also receives a CPU killing command, step S609 can be executed, that is, the relevant process of executing the CPU killing can be executed.

[0194] S609: Query the status of the electronic device.

[0195] It is understandable that if a memory check has been executed before a CPU check is executed, querying the electronic device status can be understood as querying the updated electronic device status.

[0196] When executing the CPU killing process, the killing module can query the CPU status of the electronic device from the status acquisition module. The CPU status may include the use of CPU resources, the average utilization of each core of the system, the CPU occupancy ranking table, the CPU load distribution, etc.

[0197] After the CPU status is acquired by the anti-virus module, step S610 may be executed to determine whether CPU anti-virus is required.

[0198] S610: The killing module determines whether CPU killing is required according to the state of the electronic device.

[0199] If the killing module determines that the threshold of the CPU high load state has been reached, step S611 can be executed to perform CPU killing. The specific determination of whether the threshold of the CPU high load state has been reached can refer to the above Figure 4 The relevant description in step S407 of the corresponding embodiment is not repeated here.

[0200] If the killing module determines that the threshold of the CPU high load state has not been reached, the CPU killing may not be performed.

[0201] In this way, the detection and killing module can flexibly control the detection and killing of processes or services based on the updated CPU status, so that the electronic device will not excessively detect and kill processes or services, thereby reducing the impact on users.

[0202] S611, CPU check and kill.

[0203] In the embodiment of the present application, CPU killing can be understood as Figure 4 In the corresponding embodiment, the killing level in the CPU killing configuration table cpu_adj is used to kill the application or service. For specific CPU killing, please refer to the above Figure 4 The relevant descriptions in step S408 and step S409 of the corresponding embodiment are not repeated here.

[0204] It is understandable that after executing the CPU check, step S606 and step S607 can also be executed. That is, after executing the CPU check, the process pool will be updated to the latest state after the CPU check, and the electronic device state will also be updated to the latest electronic device state, which will not be repeated.

[0205] In an embodiment of the present application, if the CPU is not in a high-load state after the memory check, the CPU check may not be performed; if the CPU is in a high-load state after the memory check, the CPU check may be performed; in this way, the electronic device's check of processes or services can be flexibly controlled so that the electronic device does not excessively check processes or services, thereby improving the user experience.

[0206] The following specific embodiments are used to describe the method of the present application in detail. The following embodiments may be combined with each other or implemented independently, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0207] Figure 7 The CPU resource management method of the embodiment of the present application is shown. The method includes:

[0208] S701. The electronic device displays an interface of a first application.

[0209] In the embodiment of the present application, the first application may be any application in the electronic device, and the embodiment of the present application is not limited thereto.

[0210] S702. In response to the user's operation of entering the interface of the second application from the interface of the first application, the electronic device queries the first preset file to obtain a first value and a second value, wherein the first value is the CPU resource utilization rate required for the electronic device to display the interface of the second application, and the second value is the CPU resource recovery rate when the first application retreats to the background.

[0211] In the embodiment of the present application, the second application may be any application in the electronic device, and the embodiment of the present application is not limited thereto. Among them, the second application and the first application may be different applications. The scene of entering the interface of the second application from the interface of the first application can also be understood as the startup scene of the application in the above embodiment.

[0212] The first preset file can be understood as the CPU reserved resource table cpu_pre.xml in the above embodiment.

[0213] The first value can be understood as the proportion of reserved resources in the CPU reserved resource table cpu_pre.xml, the first value can be understood as, and the second value can be understood as the proportion of fallback resources in the CPU reserved resource table cpu_pre.xml. The CPU resource utilization rate can be understood as the percentage of the used CPU resources to the total CPU resources, and can also be understood as the CPU resource utilization rate in the above embodiment. The CPU resource recovery rate can be understood as the percentage of the CPU resources that can be recovered when the electronic device releases the CPU resources to the total CPU resources.

[0214] S703: The electronic device obtains a third value based on the first value and the second value, where the third value is a CPU resource utilization rate required when the electronic device enters an interface of the second application from an interface of the first application.

[0215] In the embodiment of the present application, the third value may be the difference between the first value and the second value, or may be a multiple of the difference between the first value and the second value, or may be other calculation methods of the difference between the first value and the second value, which is not limited in the embodiment of the present application.

[0216] S704: If the third value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate.

[0217] In the embodiment of the present application, the CPU resource idle rate can be understood as the percentage of CPU idle resources to total CPU resources, and can also be understood as the CPU remaining resource ratio or CPU idle resource ratio in the above embodiment. Among them, the CPU resource idle rate and the CPU resource utilization rate can be inversely proportional, for example, the CPU resource idle rate = 1-CPU resource utilization rate.

[0218] The third value being greater than the CPU resource idle rate can be understood as the current remaining CPU resources of the electronic device are insufficient; the electronic device improving the CPU resource idle rate may include the electronic device executing a CPU check and kill.

[0219] In response to the user's triggering operation, the electronic device can reserve the required CPU resources in advance, so that the CPU resources required by the electronic device are relatively sufficient, thereby reducing the lag of the electronic device.

[0220] Optional, in Figure 7 On the basis of the corresponding embodiment, the CPU of the electronic device includes n cores, n is an integer greater than or equal to 1, and the first value is proportional to the following values: the time the electronic device occupies the n cores when displaying the interface of the second application, and the weight of the n cores; the second value is proportional to the time the interface of the first application occupies the n cores when displayed in the foreground, and inversely proportional to the time the first application occupies the n cores when running in the background.

[0221] In the embodiment of the present application, the time of occupying n cores can be understood as the above Figure 5 The CPU time slice duration value in the corresponding embodiment; the weight of the n cores can refer to the above Figure 5 The relevant description of the weights of the CPU large core, medium core, and small core in the corresponding embodiment will not be repeated.

[0222] The first value can be understood as the proportion of reserved resources. The specific calculation method of the first value can refer to the above Figure 5 The description of the CPU state reservation mechanism calculating the reserved CPU resource ratio in the corresponding embodiment is not repeated here. The second value can be understood as the fallback resource ratio. The specific calculation method of the second value can refer to the above Figure 5 The relevant description of the CPU state reservation mechanism calculating the CPU fallback resource ratio in the corresponding embodiment is not repeated here.

[0223] Since different applications may occupy different CPU resources during operation, the CPU state reservation mechanism can calculate the corresponding reserved resource ratio and fallback resource ratio for different scenarios of each application, and then obtain the CPU resource ratio required for the application to run.

[0224] Optional, in Figure 7 Based on the corresponding embodiment, the first value satisfies the following formula:

[0225]

[0226] Among them, source rate is the first value, m is the preset time period, n is the number of CPU cores, coreN i,j,time The time that the electronic device occupies the jth core when displaying the interface of the second application, coreN i,j,weight is the weight of the jth kernel;

[0227] The second value satisfies the following formula:

[0228]

[0229] Among them, subside rate is the second value, coreN i,j,fg is the time that the first application interface occupies the jth core when it is displayed in the foreground, coreN i,j,bg The time that the first application occupies the jth core when running in the background.

[0230] In the embodiment of the present application, the preset time period can be understood as the time period for calculating the first value or the second value, and can also be understood as the above Figure 5 The duration or preset time in the corresponding embodiment, for example, the preset time may be 5s. The embodiment of the present application does not limit the specific value of the preset time.

[0231] The specific calculation method of the first value can refer to the above Figure 5 The relevant description of the CPU state reservation mechanism calculating the reserved CPU resource ratio in the corresponding embodiment is not repeated here. The specific calculation method of the second value can refer to the above Figure 5 The relevant description of the CPU state reservation mechanism calculating the CPU fallback resource ratio in the corresponding embodiment is not repeated here.

[0232] The CPU state reservation mechanism can calculate the corresponding reserved resource ratio and fallback resource ratio for different scenarios of each application, and then obtain the CPU resource ratio required when the application is running. In this way, CPU resources can be reserved in advance, thereby reducing the high CPU load.

[0233] Optional, in Figure 7 On the basis of the corresponding embodiment, the third value is the difference between the first value and the second value.

[0234] In the embodiment of the present application, the third value can be understood as the above Figure 5 The proportion of CPU resources required by the corresponding embodiment application is not repeated here.

[0235] When calculating the third value, by considering both the reserved resource ratio and the fallback resource ratio, the actual required CPU resource ratio can be calculated more accurately and reasonably, so that the corresponding CPU killing can be performed. In this way, the demand for CPU resources can be met, and the process or service can be killed reasonably.

[0236] Optional, in Figure 7On the basis of the corresponding embodiment, the electronic device improves the CPU resource idle rate, which may include: the electronic device obtains a fourth value based on the difference between the third value and the CPU resource idle rate, the electronic device queries the second preset file for a strategy for improving the CPU resource idle rate corresponding to the fourth value; the electronic device executes the strategy for improving the CPU resource idle rate corresponding to the fourth value.

[0237] In the embodiment of the present application, the fourth value can be understood as the CPU resources that are currently lacking, or can be understood as the proportion of CPU resources that still need to be recovered; the fourth value can also be understood as the killing level in Table 1 above.

[0238] The electronic device executing the strategy of increasing the CPU resource idle rate corresponding to the fourth value can be understood as the execution module executing CPU killing according to Table 1. The strategy of increasing the CPU resource idle rate corresponding to the fourth value can be understood as the process or service that needs to be killed corresponding to the killing level.

[0239] The second preset file can be understood as the CPU detection and killing configuration table cpu_adj shown in Table 1 above.

[0240] The execution module performs CPU killing according to the killing level, which can reasonably manage the processes or services in the electronic device, so that too many processes or services will not be killed, thereby improving the user experience.

[0241] Optional, in Figure 7On the basis of the corresponding embodiment, the second preset file includes multiple intervals. If the fourth value is in the first interval, the strategy for improving the CPU resource idle rate corresponding to the fourth value includes the electronic device cleaning up one or more of the following: processes of foreground applications, processes of user-visible applications, processes of user-perceivable background applications, processes of backup tasks, background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and are not used for part of the third preset time period, processes of cached background applications, and empty processes; if the fourth value is in the second interval, the strategy for improving the CPU resource idle rate corresponding to the fourth value includes the electronic device cleaning up one or more of the following: background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and is not used for part of the time period within the third preset time period, processes of cached background applications, and empty processes. services, cached background application processes, and empty processes that exceed the third preset time period and are not used for a portion of the third preset time period; if the fourth value is in the third interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: services, cached background application processes, and empty processes that have been running for a period of time exceeding the third preset time period and are not used for a portion of the third preset time period; if the fourth value is in the fourth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes the electronic device cleaning up one or more of the following: cached background application processes and empty processes; if the fourth value is in the fifth interval, the strategy for improving the idle rate of CPU resources corresponding to the fourth value includes: the electronic device cleaning up empty processes; wherein, the value in the first interval is greater than the value in the second interval, the value in the second interval is greater than the value in the third interval, the value in the third interval is greater than the value in the fourth interval, and the value in the fourth interval is greater than the value in the fifth interval.

[0242] In the embodiment of the present application, the strategy for improving the CPU resource idle rate corresponding to the fourth value can refer to the relevant description of the embodiment corresponding to the above Table 1, and will not be repeated here.

[0243] The first interval can be understood as the interval of 40% to 50% of the detection level in Table 1, the second interval can be understood as the interval of 30% to 40% of the detection level in Table 1, the third interval can be understood as the interval of 20% to 30% of the detection level in Table 1, the fourth interval can be understood as the interval of 10% to 20% of the detection level in Table 1, and the fifth interval can be understood as the interval of 0% to 10% of the detection level in Table 1.

[0244] Among them, the service whose running time does not exceed the second preset time period can be understood as the application service of type A in Table 1. The second preset time period can be the time period of the most recently used application service pre-set by the electronic device. The specific second preset time period is not limited in the embodiment of the present application.

[0245] The service whose running time exceeds the third preset time period and is not used in part of the third preset time period can be understood as the application service of type B in Table 1. It can be understood that the third preset time period can be greater than or equal to the second preset time period, and the third preset time period can be preset by the electronic device. The specific third preset time period is not limited in the embodiment of the present application.

[0246] The execution module performs CPU killing according to the killing level, which can reasonably manage the processes or services in the electronic device, so that processes or services with lower priorities can be killed first, reducing the impact on user experience.

[0247] Optional, in Figure 7 On the basis of the corresponding embodiment, when the electronic device executes the strategy for increasing the idle rate of CPU resources corresponding to the fourth value, if the strategy includes applications or services that are not allowed to be cleaned, the applications or services that are not allowed to be cleaned will not be cleaned; wherein, the applications or services that are not allowed to be cleaned include: applications or services in a preset application list, and / or applications or services in applications loaded by the electronic device whose user usage frequency is higher than a threshold, and / or applications or services ranked in the top Q in user usage frequency among applications loaded by the electronic device.

[0248] In the embodiment of the present application, the anti-virus module of the electronic device can execute the strategy of increasing the CPU resource idle rate corresponding to the fourth value. Figure 3 According to the relevant description in the corresponding embodiment, the killing module can kill and clean up the process or service according to the CPU killing configuration table cpu_adj generated by the CPU killing configuration center.

[0249] The CPU killing configuration center can query the application blacklist, application whitelist, and other application control mechanisms provided by the system application control interface to generate the table. For example, the control mechanism provided by the system application control interface can set applications or services that are not allowed to be cleaned.

[0250] The preset application list may include an application blacklist, an application whitelist, etc.

[0251] For the top Q ranked applications or services, the electronic device may set a specific Q value, for example, Q may be 3, and the specific Q value is not limited in the embodiments of the present application.

[0252] The policy includes applications or services that are not allowed to be cleaned up, so that some more important applications in the system can be added to the application whitelist. In this way, the applications will not be killed, which will not affect the user experience.

[0253] Optional, in Figure 7 On the basis of the corresponding embodiment, the method may further include: if the electronic device needs to increase the idle rate of the memory when increasing the idle rate of the CPU resource, the electronic device first increases the idle rate of the memory.

[0254] In the embodiment of the present application, increasing the CPU resource idle rate can be understood as CPU killing, and increasing the memory idle rate can be understood as memory killing. The specific coupling implementation method of CPU killing and memory killing can refer to the above Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0255] By arranging priorities for memory and CPU checks, the same process or system resources will not be checked multiple times, thus avoiding redundant checking processes and reducing the probability of abnormalities in electronic devices during operation.

[0256] Optional, in Figure 7 On the basis of the corresponding embodiment, after the electronic device improves the memory idle rate, it can also include: the electronic device updates the CPU resource idle rate; if the third value is greater than the updated CPU resource idle rate, the electronic device continues to improve the CPU resource idle rate.

[0257] In the embodiment of the present application, if the third value is greater than the updated CPU resource idle rate, it means that after the electronic device increases the memory idle rate, the CPU is still in a high load state, and the CPU can be checked and killed. The specific process of the electronic device to check and kill the CPU can refer to the above Figure 6 The relevant descriptions of steps S609 to S611 in the corresponding embodiment are not repeated here.

[0258] If the CPU is not in a high-load state after the memory idle rate is increased, the CPU may not be checked; if the CPU is in a high-load state after the memory idle rate is increased, the CPU may be checked; in this way, the checking and killing module of processes or services can be flexibly controlled so that the electronic device will not excessively check and kill processes or services, thereby reducing the impact on users.

[0259] Optional, in Figure 7 On the basis of the corresponding embodiment, after the electronic device increases the CPU resource idle rate, it may also include: if the difference between the increased CPU resource idle rate and the third value is greater than or equal to the first preset threshold, then reducing the first value and / or increasing the second value; if the difference between the increased CPU resource idle rate and the third value is less than the second preset threshold, then increasing the first value and / or decreasing the second value.

[0260] In the embodiment of the present application, the difference between the improved CPU resource idle rate and the third value can be understood as the above Figure 3 The difference between the percentage of recovered CPU resources and the percentage of required CPU resources in the corresponding embodiment; the first preset threshold can be understood as the first threshold; the second preset threshold can be understood as the second threshold; no further details will be given.

[0261] The CPU state reservation mechanism in the electronic device can execute the process of adjusting the first value and / or the second value. In this way, the CPU state reservation mechanism can more accurately calculate the required CPU resources according to the CPU resources recovered after the CPU is checked and killed.

[0262] Optional, in Figure 7 On the basis of the corresponding embodiment, the method may further include: in response to the user sliding operation in the first interface of the second application, the electronic device queries the first preset file to obtain a fifth value and a sixth value, wherein the fifth value is the CPU resource utilization required for the electronic device to display the interface after the first interface slides, and the sixth value is the CPU resource recovery rate when the electronic device exits displaying the interface before the first interface slides; the electronic device obtains a seventh value based on the fifth value and the sixth value, and the seventh value is the CPU resource utilization required for the electronic device when sliding in the first interface; if the seventh value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate.

[0263] In the embodiment of the present application, the scene of sliding in the first interface of the second application can be understood as the scene of sliding in the application. It can be understood that the proportion of CPU resources required before and after sliding in the application can be different.

[0264] The fifth value can be understood as the proportion of reserved resources required for the interface after the first interface slides in the CPU reserved resource table cpu_pre.xml when the second application is in the in-application sliding scenario. The sixth value can be understood as the proportion of fallback resources required for the interface before sliding out of the first interface in the CPU reserved resource table cpu_pre.xml when the second application is in the in-application sliding scenario.

[0265] The seventh value may be the difference between the fifth value and the sixth value, or a multiple of the difference between the fifth value and the sixth value, or other calculation methods of the difference between the fifth value and the sixth value, which is not limited in the embodiments of the present application.

[0266] The seventh value being greater than the CPU resource idle rate can be understood as insufficient remaining CPU resources of the electronic device; improving the CPU resource idle rate of the electronic device can include the electronic device executing a CPU check and kill.

[0267] In response to the user's trigger operation, the electronic device can reserve the required CPU resources in advance before the application interface slides, so that the CPU resources required when the application interface slides are relatively sufficient, thereby reducing the lag of the electronic device.

[0268] Optional, in Figure 7 Based on the corresponding embodiments, the method may further include: in response to the user's operation of entering the second interface of the second application from the first interface, the electronic device queries the first preset file to obtain an eighth value and a ninth value, wherein the eighth value is the CPU resource utilization required for the electronic device to display the second interface, and the ninth value is the CPU resource recovery rate when the electronic device exits displaying the first interface; the electronic device obtains a tenth value based on the eighth value and the ninth value, and the tenth value is the CPU resource utilization required for the electronic device to enter the second interface from the first interface; if the tenth value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate.

[0269] In the embodiment of the present application, the scene of entering the second interface of the second application from the first interface can be understood as the scene of the in-application transition. It is understandable that the required CPU resource ratio can be different before and after the in-application transition.

[0270] The eighth value can be understood as the proportion of reserved resources required for the second interface displayed in the CPU reserved resource table cpu_pre.xml when the second application is in the in-application transition scenario. The ninth value can be understood as the proportion of fallback resources when exiting the display of the first interface in the CPU reserved resource table cpu_pre.xml when the second application is in the in-application transition scenario.

[0271] The tenth value may be the difference between the eighth value and the ninth value, or a multiple of the difference between the eighth value and the ninth value, or other calculation methods of the difference between the eighth value and the ninth value, which is not limited in the embodiments of the present application.

[0272] The tenth value being greater than the CPU resource idle rate can be understood as insufficient remaining CPU resources of the electronic device; improving the CPU resource idle rate of the electronic device can include the electronic device executing a CPU check and kill.

[0273] In response to the user's triggering operation, the electronic device can reserve the required CPU resources in advance before the application interface jumps, so that the CPU resources required when the application interface jumps are relatively sufficient, thereby reducing the lag of the electronic device.

[0274] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0275] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the method steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0276] The embodiment of the present application can divide the functional modules of the device implementing the method according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0277] like Figure 8 FIG. 8 is a schematic diagram of a chip structure provided by an embodiment of the present application. The chip 800 includes one or more (including two) processors 801 , a communication line 802 , a communication interface 803 and a memory 804 .

[0278] In some implementations, the memory 804 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.

[0279] The method described in the above embodiment of the present application can be applied to the processor 801, or implemented by the processor 801. The processor 801 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware or software instructions in the processor 801. The above processor 801 can be a general processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 801 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.

[0280] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 804, and the processor 801 reads the information in the memory 804 and completes the steps of the above method in combination with its hardware.

[0281] The processor 801 , the memory 804 , and the communication interface 803 may communicate with each other via the communication line 802 .

[0282] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.

[0283] The embodiment of the present application also provides a computer program product including one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium may include a magnetic medium (e.g., a floppy disk, a hard disk or a tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0284] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. Computer-readable media may include computer storage media and communication media, and may also include any medium that can transfer a computer program from one place to another. The storage medium may be any target medium that can be accessed by a computer.

[0285] As a possible design, the computer readable medium may include a compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM or other optical disc storage; the computer readable medium may include a magnetic disk storage or other magnetic disk storage device. Moreover, any connection line may also be appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while optical discs reproduce data optically using lasers.

[0286] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

Claims

1. A CPU resource management method, characterized in that: The method comprises: The electronic device displays the interface of the first application; In response to a user operation of entering an interface of a second application from an interface of the first application, the electronic device queries a first preset file to obtain a first value and a second value, wherein the first value is a CPU resource utilization rate required for the electronic device to display the interface of the second application, and the second value is a CPU resource recovery rate when the first application retreats to the background; The electronic device obtains a third value based on the first value and the second value, the third value being a CPU resource utilization rate required when the electronic device enters the interface of the second application from the interface of the first application; the third value is a difference between the first value and the second value; If the third value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate; The electronic device improves the CPU resource idle rate, including: the electronic device cleans up one or more of the following: processes of foreground applications, processes of user-visible applications, processes of user-perceivable background applications, processes of backup tasks, background processes without recovery capabilities, services whose running time does not exceed a second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds a third preset time period and are not used for a portion of the third preset time period, cached background application processes, and empty processes.

2. The method according to claim 1, characterized in that The CPU of the electronic device includes n cores, where n is an integer greater than or equal to 1. The first value is proportional to the following values: the time that the electronic device occupies the n cores when displaying the interface of the second application, and the weight of the n cores; The second value is directly proportional to the time that the interface of the first application occupies the n cores when it is displayed in the foreground, and is inversely proportional to the time that the first application occupies the n cores when it is running in the background.

3. The method according to claim 1 or 2, characterized in that: The first value satisfies the following formula: Among them, source rate is the first value, m is the preset time period, n is the number of CPU cores, coreN i,j,time The time that the electronic device occupies the jth core when displaying the interface of the second application, coreN i,j,weight is the weight of the j-th kernel; The second value satisfies the following formula: Among them, subside rate is the second value, coreN i,j,fg is the time that the interface of the first application occupies the jth core when it is displayed in the foreground, coreN i,j,bg The time that the first application occupies the jth core when running in the background.

4. The method according to claim 1, characterized in that: The electronic device improves the CPU resource idle rate, including: The electronic device obtains a fourth value based on a difference between the third value and the CPU resource idle rate, and the electronic device searches the second preset file for a strategy for improving the CPU resource idle rate corresponding to the fourth value; The electronic device executes the strategy corresponding to the fourth value for increasing the idle rate of the CPU resource.

5. The method according to claim 4, characterized in that The second preset file includes multiple intervals. If the fourth value is in the first interval, the strategy for improving the idle rate of the CPU resource corresponding to the fourth value includes the electronic device clearing one or more of the following: processes of foreground applications, processes of user-visible applications, processes of user-perceivable background applications, processes of backup tasks, background processes without recovery capabilities, services whose running time does not exceed the second preset time period, processes of applications running in the foreground of the electronic device before the first application is started, services whose running time exceeds the third preset time period and are not used for a part of the third preset time period, processes of cached background applications, and empty processes; If the fourth value is in the second interval, the strategy for improving the idle rate of the CPU resource corresponding to the fourth value includes the electronic device clearing one or more of the following: a background process without recovery capability, a service whose running time does not exceed the second preset time period, a process of an application running in the foreground of the electronic device before the first application is started, a service whose running time exceeds the third preset time period and is not used for a part of the time period within the third preset time period, a process of a cached background application, and an empty process; If the fourth value is within the third interval, the strategy for improving the idle rate of the CPU resource corresponding to the fourth value includes the electronic device cleaning up one or more of the following: services whose running time exceeds the third preset time period and are not used for a part of the time period within the third preset time period, processes of cached background applications, and empty processes; If the fourth value is within the fourth interval, the strategy for improving the idle rate of the CPU resource corresponding to the fourth value includes the electronic device clearing one or more of the following: processes of cached background applications and empty processes; If the fourth value is within the fifth interval, the strategy for improving the idle rate of the CPU resource corresponding to the fourth value includes: the electronic device clearing an empty process; The value in the first interval is greater than the value in the second interval, the value in the second interval is greater than the value in the third interval, the value in the third interval is greater than the value in the fourth interval, and the value in the fourth interval is greater than the value in the fifth interval.

6. The method according to claim 4 or 5, characterized in that: When the electronic device executes the policy for increasing the idle rate of the CPU resource corresponding to the fourth value, if the policy includes applications or services that are not allowed to be cleaned up, the applications or services that are not allowed to be cleaned up are not cleaned up; Among them, the applications or services that are not allowed to be cleaned include: applications or services in the preset application list, and / or applications or services whose user usage frequency is higher than a threshold among the applications loaded by the electronic device, and / or applications or services ranked in the top Q in user usage frequency among the applications loaded by the electronic device.

7. The method according to any one of claims 1-2, 4-5, characterized in that: The method further comprises: If the electronic device needs to increase the memory idle rate when increasing the CPU resource idle rate, the electronic device first increases the memory idle rate.

8. The method according to claim 7, characterized in that After the electronic device improves the memory idle rate, the electronic device further includes: The electronic device updates the CPU resource idle rate; If the third value is greater than the updated CPU resource idle rate, the electronic device continues to increase the CPU resource idle rate.

9. The method according to any one of claims 1-2, 4-5, and 8, characterized in that: After the electronic device increases the CPU resource idle rate, the electronic device further includes: If the difference between the increased CPU resource idle rate and the third value is greater than or equal to a first preset threshold, reducing the first value and / or increasing the second value; If the difference between the increased CPU resource idle rate and the third value is smaller than a second preset threshold, the first value is increased and / or the second value is decreased.

10. The method according to any one of claims 1-2, 4-5, and 8, characterized in that: The method further comprises: In response to a user sliding operation in the first interface of the second application, the electronic device queries the first preset file to obtain a fifth value and a sixth value, wherein the fifth value is a CPU resource utilization rate required for the electronic device to display an interface after the first interface slides, and the sixth value is a CPU resource recovery rate when the electronic device exits displaying an interface before the first interface slides; The electronic device obtains a seventh value based on the fifth value and the sixth value, where the seventh value is a CPU resource utilization rate required when the electronic device slides in the first interface; If the seventh value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate.

11. The method according to claim 10, characterized in that The method further comprises: In response to an operation of a user entering a second interface of the second application from the first interface, the electronic device queries the first preset file to obtain an eighth value and a ninth value, wherein the eighth value is a CPU resource utilization rate required for the electronic device to display the second interface, and the ninth value is a CPU resource recovery rate when the electronic device exits displaying the first interface; The electronic device obtains a tenth value based on the eighth value and the ninth value, where the tenth value is a CPU resource utilization rate required when the electronic device enters the second interface from the first interface; If the tenth value is greater than the CPU resource idle rate, the electronic device increases the CPU resource idle rate.

12. An electronic device, characterized in that: include: A memory and a processor, the memory being used to store a computer program, and the processor being used to execute the computer program to perform the method according to any one of claims 1 to 11.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the computer executes the method according to any one of claims 1 to 11.

14. A computer program product, characterized in that The invention comprises a computer program, which, when being executed, enables an electronic device to execute the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Resource management method and device, mobile terminal and computer readable storage medium

    CN110018903A

  • Control method and electronic equipment

    CN110045908A

  • Application preloading method, application starting method and electronic equipment

    CN116048648A

  • Load resource scheduling method and electronic equipment

    CN116089096A

  • Memory recovery method and device and terminal equipment

    CN116126744A