Process freezing method and device

CN121569263APending Publication Date: 2026-02-24HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202480043078.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-12-27
Filing Date
2024-08-16
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

The existing technology cannot effectively solve the problem that background processes occupy too much electronic device resources, affecting the performance and battery life of electronic devices.

Method used

In specific scenarios, by creating target threads, identifying and setting the process to be frozen to an uninterruptible sleep state, reducing the resource consumption of background processes.

Benefits of technology

It effectively reduces the resource consumption of background processes, improves the performance and battery life of electronic devices, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121569263A_ABST
    Figure CN121569263A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a process freezing method and device, relates to the field of terminals, and can reduce resource consumption of background processes and improve performance and endurance of electronic equipment. The method is applied to the electronic equipment and comprises the steps of creating a target thread in response to that the electronic equipment is in a first scene; determining a to-be-frozen process based on the target thread; and the process to be frozen is set to be in an uninterruptible sleep state based on the target thread, and the process to be frozen is set to be in an uninterruptible sleep state based on the target thread.
Need to check novelty before this filing date? Find Prior Art

Description

A process freezing method and device

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on December 27, 2023, with application number 202311835942.7 and invention name “A process freezing method and device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of the present application relate to the terminal field, and in particular to a process freezing method and device. Background Art

[0003] Currently, operating systems (e.g., Android operating systems) on electronic devices (e.g., mobile phones) can place some application processes in the background to ensure fast startup when users resume using these application processes. However, if too many background processes (i.e., background processes) are running, they will occupy a large amount of the electronic device's central processing unit (CPU), memory, and other system resources.

[0004] Summary of the Invention

[0005] The embodiments of the present application provide a process freezing method and apparatus, which can reduce resource consumption of background processes and improve the performance and battery life of electronic devices.

[0006] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0007] In a first aspect, a method for freezing a process is provided, which is applied to an electronic device. The method includes: creating a target thread in response to the electronic device being in a first scenario; determining a process to be frozen based on the target thread; and setting the process to be frozen to an uninterruptible sleep status based on the target thread.

[0008] Based on the method provided in this application, when the electronic device is in the first scenario, a target thread can be created, and based on the target thread, the process to be frozen among multiple processes of the electronic device can be set to an uninterruptible sleep state, which can reduce the resource consumption of background processes and improve the performance and battery life of the electronic device.

[0009] In one possible implementation, the electronic device includes a first application, and the first scenario includes at least one of an electronic device unlocking scenario, an electronic device entering or exiting the leftmost home screen scenario, an electronic device answering a call and the screen goes out scenario, a first application startup scenario, a first application exit scenario, a first application shooting scenario, and a first application sliding and frame loss scenario. That is, in the electronic device unlocking scenario, the electronic device entering or exiting the leftmost home screen scenario, the electronic device answering a call and the screen goes out scenario, the first application startup scenario, the first application exit scenario, the first application shooting scenario, or the first application sliding and frame loss scenario, the electronic device can create a target thread and, based on the target thread, set the processes to be frozen among the multiple processes of the electronic device to an uninterruptible sleep state, thereby reducing resource consumption of applications running in the background and improving the performance and battery life of the electronic device.

[0010] In one possible implementation, the processes to be frozen are processes other than the foreground process, processes related to the foreground process, and background processes allowed by the user. This avoids freezing the foreground process, processes related to the foreground process, and background processes allowed by the user, thereby preventing the user experience from being affected.

[0011] In one possible implementation, the background processes allowed by the user include at least one of a navigation process, a sports or health check process, and an audio process. This prevents freezing of user-allowed processes such as the navigation process, sports or health check process, and audio process, thereby preventing a negative impact on the user experience.

[0012] In one possible implementation, setting the process to be frozen to an uninterruptible sleep state includes: setting the process to be frozen to an uninterruptible sleep state within a first duration; wherein the first duration is determined based on the start time and end time of the first scene. For example, the first duration can be the duration of the time period between the start time and the end time of the first scene. That is, taking the first scene as the first application startup scene as an example, when the first application is in the startup scene, the electronic device can create a target thread. The process information of multiple processes of the electronic device is collected through the target thread. The process to be frozen among the multiple processes is determined. The process to be frozen is set to an uninterruptible sleep state (i.e., the process to be frozen is frozen). Thus, the corresponding background process can be frozen when the electronic device displays the startup animation of the first application, avoiding the problem of freeze when the electronic device displays the startup animation of the first application, thereby improving the user experience.

[0013] In one possible implementation, setting the to-be-frozen process in an uninterruptible sleep state includes: setting the to-be-frozen process in an uninterruptible sleep state for a first duration; the first duration is determined based on a first preset duration corresponding to a first scenario. That is, the first duration can be determined based on the first preset duration corresponding to the first scenario, and setting the to-be-frozen process in an uninterruptible sleep state for the first duration can reduce resource consumption by background applications and improve the performance and battery life of the electronic device.

[0014] In one possible implementation, the first preset duration corresponding to the first scenario is determined according to the following steps: Step 1: When the electronic device is in the first scenario, N background processes are frozen for a second preset duration, where N is an integer greater than or equal to 1; Step 2: Within the second preset duration, the processor load value is calculated at preset time intervals; Step 3: Recording a first time difference between the start time of the second preset duration and a target time, where the target time is the time when the last calculated processor load value is less than a preset value within the second preset duration; Step 4: Executing Steps 1-3 L times to obtain L first time differences, calculating the average of the L first time differences, and determining the first preset duration corresponding to the first scenario based on the average, where L is an integer greater than or equal to 2. It should be noted that when the last processor load value within the second preset duration is less than a preset value (e.g., 80%), it can be considered that the load reduction effect has been achieved. That is, the time difference (first time difference) between the start time of the second preset duration and the last time the processor load value is less than the preset value is a reasonable duration for freezing background processes. Therefore, it is reasonable to determine the freezing time (i.e., the first time) corresponding to different scenarios based on the average of multiple (for example, L) first time differences. This can not only achieve the effect of reducing the load, but also avoid the problem of the freezing time being too long, which affects the stability of the background process.

[0015] In one possible implementation, when the first scenario is the electronic device entering a negative-one screen scenario or the electronic device answering a call and turning off the screen scenario, the first preset duration corresponding to the first scenario is 1 second; when the first scenario is the electronic device unlocking scenario or the first application sliding and dropping frames scenario, the first preset duration corresponding to the first scenario is 1.5 seconds; when the first scenario is the first application startup scenario, the first preset duration corresponding to the first scenario is 3 seconds.

[0016] In one possible implementation, the electronic device includes a second application, and the method further includes: within a first duration, in response to the second application being in a second scenario, setting the process corresponding to the first application to an uninterruptible sleep state. Thus, during the freezing period (i.e., within the first duration), if the second application is identified as being in the second scenario, indicating that the process corresponding to the first application has switched to a background process, the process corresponding to the first application (i.e., the new background process) can be frozen. This prevents the first application's process from occupying a high CPU load and affecting the startup or running speed of the second application.

[0017] In one possible implementation, setting the process corresponding to the second application to an uninterruptible sleep state includes: if a second time difference between the start time of the second scene and the end time of the first duration is greater than a preset time difference, setting the process corresponding to the second application to an uninterruptible sleep state. It should be noted that if the second time difference is greater than the preset time difference (for example, x milliseconds, where x is greater than 0), indicating that the first duration will continue for a considerable period of time, the process of the first application can be specifically frozen to prevent the occupation of the process of the first application from affecting the startup or operation of the second application.

[0018] In one possible implementation, after a process to be frozen is placed in an uninterruptible sleep state for a first duration, the process to be frozen exits the uninterruptible sleep state, and after at least a second duration, the process to be frozen is placed in an uninterruptible sleep state again. That is, during the first duration, the process to be frozen is in an uninterruptible sleep state (frozen state), and during the second duration, the process to be frozen is not in an uninterruptible sleep state (i.e., thawed state). This avoids the problem of the process to be frozen being constantly frozen, thereby affecting the stability of the application.

[0019] In a possible implementation, the second duration is 1 second.

[0020] In one possible implementation, the electronic device includes a third application, and the method further includes: within a second duration, in response to the third application being in a third scene, recording the start time of the third scene, calculating a third time difference between the start time of the third scene and the end time of the second duration, and setting the process to be frozen to an uninterruptible sleep state after the third time difference has elapsed. In this way, freezing can be immediately triggered at the end of the freezing interval (i.e., the second duration) to reduce processor load as quickly as possible.

[0021] In a second aspect, the present application provides a chip system comprising one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected via a circuit. The chip system can be applied to an electronic device comprising a communication module and a memory. The interface circuit is configured to receive a signal from the memory of the electronic device and send the received signal to the processor, the signal comprising a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device can execute the method described in the first aspect and any possible design thereof.

[0022] In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions. When the computer instructions are executed on an electronic device (such as a mobile phone), the electronic device executes the method described in the first aspect and any possible design thereof.

[0023] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any possible design thereof.

[0024] In a fifth aspect, embodiments of the present application provide an application process management device, comprising a processor coupled to a memory, the memory storing program instructions. When the program instructions stored in the memory are executed by the processor, the device implements the method described in the first aspect and any possible design thereof. The device may be an electronic device or a server device; or it may be a component of the electronic device or server device, such as a chip.

[0025] In the sixth aspect, an embodiment of the present application provides a process management device for an application, which can be divided into different logical units or modules according to function, and each unit or module performs different functions, so that the device executes the method described in the above-mentioned first aspect and any possible design method thereof.

[0026] It can be understood that the beneficial effects that can be achieved by the chip system described in the second aspect, the computer-readable storage medium described in the third aspect, the computer program product described in the fourth aspect, and the devices described in the fifth and sixth aspects provided above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] FIG1 is a schematic diagram of a freezing mechanism of a related technology provided by an embodiment of the present application;

[0028] FIG2 is a schematic diagram of a thawing mechanism of a related technology provided by an embodiment of the present application;

[0029] FIG3 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0030] FIG4 is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;

[0031] FIG5 is a schematic diagram of interaction between modules provided in an embodiment of the present application;

[0032] FIG6 is a schematic diagram of a scenario provided in an embodiment of the present application;

[0033] FIG7 is a schematic diagram of another scenario provided by an embodiment of the present application;

[0034] FIG8 is a schematic diagram of another scenario provided by an embodiment of the present application;

[0035] FIG9 is an interactive diagram applicable to a freezing method of a process provided in an embodiment of the present application;

[0036] FIG10 is a state diagram of a process provided by an embodiment of the present application;

[0037] FIG11 is a schematic diagram of a test scenario for quick application startup and exit provided in an embodiment of the present application;

[0038] FIG12 is a state diagram of another process provided in an embodiment of the present application;

[0039] FIG13 is a schematic diagram of a freezing failure during a freezing period provided by an embodiment of the present application;

[0040] FIG14 is a state diagram of another process provided in an embodiment of the present application;

[0041] FIG15 is a schematic diagram of a boarding solution provided in an embodiment of the present application;

[0042] FIG16 is a schematic diagram of a freezing failure during a freezing interval provided by an embodiment of the present application;

[0043] FIG17 is a schematic diagram of a vehicle adding solution provided in an embodiment of the present application;

[0044] FIG18 is a schematic structural diagram of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the present application, unless otherwise specified, "at least one" means one or more, and "a plurality of" means two or more than two. In addition, in order to facilitate the clear description of the technical solutions in the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will 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.

[0046] To make the description of the following embodiments clear and concise, a brief introduction to the relevant concepts or technologies is first given:

[0047] Foreground processes: Foreground processes are visible and accessible to users. Foreground processes are prioritized for execution on processors with higher processing power (e.g., processors with larger cores), resulting in faster execution and higher scheduling priority.

[0048] Background processes: Background processes are processes that are inaccessible to users (unless closed). Background processes have a lower priority than foreground processes. Background processes typically run on processors with lower processing power (for example, low-core processors) and execute more slowly. Foreground processes and background processes are interchangeable.

[0049] Thread: A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within that process. A thread refers to a single, sequential flow of control within a process. Multiple threads can run concurrently within a process, each executing different tasks in parallel. A thread is the basic unit of independent scheduling and dispatch. A thread can be a kernel thread scheduled by the operating system kernel; a user thread scheduled by a user process; or a thread scheduled by a combination of the kernel and user processes.

[0050] Freezing: Electronic devices limit background processes from occupying system resources, which can include CPU resources, sensors, or memory.

[0051] Thaw: Unfreezes electronic devices and restricts background processes from occupying system resources.

[0052] Currently, operating systems (e.g., Android) on electronic devices (e.g., mobile phones) can place some application processes in the background to ensure fast startup when users resume using these application processes. However, if too many background processes (i.e., background processes) are running, they will occupy a large amount of the electronic device's CPU, memory, and other system resources. How to limit background processes so as not to affect the performance and battery life of electronic devices is an urgent issue that needs to be addressed.

[0053] In some related technologies, in order to solve the above problem, a freezing strategy of the tombstone mechanism can be adopted to limit the resource usage of the background process.

[0054] For example, as shown in Figure 1, in response to clicking the icon of Application A (abbreviated as A in the figure), the activity manager service (AMS) may call updateOomAdjLocked to update Application A's adj (CACHED_APP_MIN_ADJ). Application A's adj can be used to indicate Application A's process priority. For example, Application A's adj can be changed to 0, switching Application A to the foreground application (i.e., Application A's process is the foreground process). In response to exiting Application A and clicking the icon of Application B, the AMS may change Application A's adj to 700, switching Application A to the previous application. In response to exiting Application B and clicking the icon of Application C, the AMS may change Application A's adj to 900, switching Application A to the cached application (i.e., Application A's process is cached). When Application A's adj is greater than or equal to 900, the system may freeze Application A's process (e.g., CachedAppOptimizer may call freezeAppAsyncLSP to freeze Application A's process). In order to prevent the process of application A from having unfinished tasks when entering the cached state, thereby indirectly affecting the user experience, the system can freeze the process of application A after the debounce time (i.e., the debounce time, for example, can be 10 minutes). The abstract layer can notify the kernel's control groups (cgroup) to freeze the process of application A, and the kernel cgroup can freeze the process of application A, so that the process of application A is frozen. In an embodiment of the present application, exiting an application (e.g., application A) means that application A is switched to the background (i.e., the process of application A is switched to the background process), and the next time application A is started, it can be started directly from the background. Closing an application (e.g., application A) means that the process of application A is killed, and the OnCreate method needs to be called again when application A is started next time.

[0055] As shown in Figure 2, when the state of Application A changes and its adj value changes—for example, when Application A's adj value is less than 900—the system can unfreeze Application A's process (for example, CachedAppOptimizer can call unfreezeAppLSP to unfreeze Application A's process). Before officially unfreezing Application A's process, the system can first check whether the process received a synchronization binder request (SYNC_RECEIVED_WHILE_FROZEN) while frozen. If so, the process can be killed. This is because sending a synchronization binder request to the frozen process makes the process's state uncertain, so the process must be killed. The abstraction layer then notifies the kernel cgroup to unfreeze Application A's process, which then unfreezes it.

[0056] However, the tombstoning mechanism's freezing strategy cannot freeze (also known as freezing) processes within the debounce time (for example, 10 minutes). This is to prevent application processes from entering the cached state with unfinished tasks, which indirectly affects the user experience. Therefore, the tombstoning mechanism's freezing strategy cannot guarantee resource consumption during the debounce time, affecting the performance and battery life of electronic devices.

[0057] In other related technologies, a basic freezing control cycle can be set, and the application is dynamically controlled between freezing and thawing based on the set basic freezing control cycle cycle, so as to achieve a balance between energy saving and normal execution of application functions.

[0058] However, freezing and thawing applications by setting a freezing control cycle cannot effectively solve the problem of background processes preempting the CPU resources of foreground applications in some important scenarios (for example, application startup, exit, etc.).

[0059] This application provides a process freezing method that can temporarily freeze background processes during user interaction scenarios (such as application startup and exit) during the intervals between other freezing solutions (for example, during the debounce time). This reduces the resource consumption of background processes, solves the problem of background processes preempting system resources from foreground processes, improves the performance and battery life of electronic devices, and thus enhances the user experience.

[0060] FIG3 is a schematic structural diagram of an electronic device 100 provided in an embodiment of the present application.

[0061] As shown in Figure 3, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0062] Among them, the sensor module 180 can 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.

[0063] It should be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0064] 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 processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0065] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0066] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0067] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0068] It is understood that the interface connection relationship between the modules illustrated in this embodiment is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

[0069] The charging management module 140 is configured to receive charging input from a charger. While charging the battery 142 , the charging management module 140 can also provide power to the electronic device through the power management module 141 .

[0070] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. In some other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.

[0071] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0072] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network.

[0073] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low-noise amplifier (LNA), and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor and convert them into electromagnetic waves for radiation via the antenna 1.

[0074] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium- or high-frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs sound signals through an audio device (including but not limited to the speaker 170A, the receiver 170B, etc.) or displays images or videos through the display screen 194.

[0075] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0076] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with a network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0077] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0078] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), a light-emitting diode (LED), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED).

[0079] The electronic device 100 can realize the shooting function through the ISP, camera 193, video codec, GPU, display screen 194 and application processor. The ISP is used to process the data fed back by the camera 193. The camera 193 is used to capture still images or videos. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0080] The cameras 193 may include 1 to N cameras. For example, the electronic device may include 2 front cameras and 4 rear cameras. The NPU is a neural network (NN) computing processor that quickly processes input information by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, and can also continuously self-learn. The NPU can realize applications such as intelligent cognition of the electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0081] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are saved in the external memory card. The internal memory 121 can be used to store computer executable program code, and the executable program code includes instructions. The processor 110 can execute various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 can execute instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, applications required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (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.

[0082] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0083] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. The speaker 170A, also known as a "speaker," is used to convert audio electrical signals into sound signals. The receiver 170B, also known as a "handset," is used to convert audio electrical signals into sound signals. The microphone 170C, also known as a "microphone" or "microphone," is used to convert sound signals into electrical signals. The headphone jack 170D is used to connect wired headphones.

[0084] The buttons 190 include a power button, a volume button, etc. The buttons 190 can be mechanical buttons. They can also be touch buttons. The electronic device 100 can receive button inputs and generate key signal inputs related to the user settings and function controls of the electronic device 100. The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration prompts or for touch vibration feedback. The indicator 192 can be an indicator light that can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.

[0085] The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.

[0086] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.

[0087] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through interfaces. In some embodiments, the Android system may include an application layer, an application framework layer, a kernel layer, and a hardware layer. It should be noted that the embodiments of the present application are illustrated by the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.

[0088] Among them, the application layer may include a series of application packages.

[0089] As shown in Figure 4, the application package may include video, game, map, WLAN, music, short message, gallery, call, navigation, power saving wizard, etc. Of course, the application layer may also include other application packages, such as Bluetooth, calendar, camera, settings and other applications, which are not limited in this application. In the embodiment of the present application, the application layer may also include a first application, a second application, a third application, etc. The first application, the second application or the third application may be, for example, any of the aforementioned applications (for example, video, game, etc.).

[0090] In an embodiment of the present application, the power saving wizard application can be used to determine whether a process is in a frozen state (for example, during the freezing period of other freezing schemes (for example, the tombstone mechanism scheme)) and to verify whether the state of the process has changed.

[0091] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example, it may include an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, etc., which are not limited in this embodiment of the application.

[0092] In this embodiment of the present application, the application framework layer may also include a real-time protection system (iaware real-time subsystem). The real-time protection system may run in the system_server process. The real-time protection system may include an initialization module, a scene recognition module, a scene judgment module, a process acquisition module, a process identification module, and a rule matching module. The process acquisition module, process identification module, and rule matching module belong to the iaware.freeze thread.

[0093] The initialization module is used to read the status of the quick freezing function switch from the first preset configuration file. The status of the quick freezing function switch can be on, indicating that the mobile phone can start the quick freezing function provided by this application.

[0094] The scene recognition module is used to identify scenes of non-desktop (noHome) applications. Non-desktop applications refer to applications other than desktop applications.

[0095] The scene determination module is configured to determine whether the current scene of the application belongs to a preset scene. The preset scene may include, for example, at least one of the following: unlocking the electronic device, entering or exiting the leftmost home screen, answering a call, and turning off the screen, launching the first application, exiting the first application, shooting the first application, and sliding and dropping frames in the first application.

[0096] Among them, electronic device unlocking scenarios may include fingerprint unlocking scenarios, password unlocking scenarios, face recognition unlocking scenarios, etc., which are not limited in this application. The fingerprint unlocking scenario refers to a scenario in which the electronic device collects the user's fingerprint through the fingerprint sensor in the lock screen state, and compares the collected fingerprint with the fingerprint entered by the user to determine whether to unlock the electronic device. The password unlocking scenario refers to a scenario in which the electronic device receives the password entered by the user in the lock screen state, and compares the password with the password set by the user to determine whether to unlock the electronic device. The face unlocking scenario refers to a scenario in which the electronic device collects facial data through a camera (for example, a front camera) in the lock screen state, and compares the collected facial data with the facial data entered by the user to determine whether to unlock the electronic device.

[0097] The electronic device enters the leftmost home screen scenario when the electronic device receives a preset operation from the user (for example, swiping the screen to the right on the home screen of the electronic device) and displays the leftmost home screen. Of course, the preset operation can also be other operations, which are not limited in this application.

[0098] The screen-off scenario when an electronic device answers a call refers to a scenario in which the screen automatically turns off when the electronic device detects an object (for example, the user's side face) approaching through a light sensor during a call.

[0099] The first application launch scenario may refer to a scenario in which the electronic device launches the first application after receiving an operation (e.g., a click operation) from a user on an icon of the first application on the desktop. Alternatively, the first application launch scenario may refer to a scenario in which the electronic device launches the first application after receiving an operation (e.g., a click operation) from a user on a card of the first application in a task list.

[0100] The first application exit scenario may refer to a scenario in which the electronic device receives an operation to exit the first application and returns to the desktop. The operation to exit the first application may, for example, be an operation in which the user clicks the home button (a functional button for returning to the desktop). The home button may be a physical button or a virtual button, which is not limited in this application. Alternatively, the operation to exit the first application may be an operation in which the user clicks the return button (for example, clicks once, or clicks twice in succession). The return button is used to return to the previous interface. Alternatively, the operation to exit the first application may be a shortcut gesture operation. The shortcut gesture operation may be any one of the following operations: an operation of sliding up a first distance from the bottom of the screen, an operation of sliding right from the left end of the screen, or an operation of sliding left from the right end of the screen.

[0101] The first application shooting scene refers to a scene in which the camera is called to shoot during the running of the first application. For example, the first application may be a chat application, and when the user needs to send a picture during the chat, the camera can be called to shoot the required picture.

[0102] The first application sliding frame loss scenario may refer to a scenario in which the first application execution process performs corresponding processing (for example, scrolling display) in response to the user's sliding operation, but freezes and frame losses occur during the corresponding processing (for example, scrolling display).

[0103] The process collection module is used to collect process information of the electronic device. The process information may include a process identifier (PID) of a currently active process.

[0104] The process identification module is used to identify the characteristic information of each process corresponding to the PID of the currently active process. The characteristic information of the process may include the state, relevance, type and permissions of the process.

[0105] The rule matching module is used to match the characteristic information of the currently active process with the matching rules to determine the process to be frozen.

[0106] The kernel layer is the layer between hardware and software. It includes at least the display driver, camera driver, audio driver, and sensor driver (not shown). It can also include the real-time (RT) scheduler, the very important person (VIP) scheduler, the completely fair scheduler (CFS) scheduler, and the energy aware (EAS) scheduler.

[0107] In the embodiment of the present application, the inner core layer may further include a freezing module.

[0108] The freezing module is used to freeze the process to be frozen, that is, to set the process to be frozen to an uninterruptible sleep status.

[0109] The hardware layer includes the central processing unit (CPU), GPU, double data rate synchronous dynamic random-access memory (DDR SDRAM), etc. Of course, the hardware layer can also include other hardware, such as displays and cameras.

[0110] The Android system may also include other layers (not shown in the figure), such as the Android Runtime and system libraries, the hardware abstraction layer (HAL), etc., which are not limited in this application.

[0111] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0112] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0113] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0114] OpenGL ES is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0115] SGL is a graphics engine for 2D graphics.

[0116] The Android Runtime consists of core libraries and a virtual machine (VM). The Android Runtime is responsible for scheduling and management of the Android system. The core libraries consist of two parts: one for Java-based functions and the other for the Android core library. The application layer and application framework layer run in the VM. The VM executes Java files from the application and framework layers as binary files. The VM is responsible for performing functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0117] The HAL layer is an encapsulation of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the low-level hardware.

[0118] The following describes the software modules and the interactions between the modules involved in the freezing method of a process provided in an embodiment of the present application in conjunction with FIG. 5 .

[0119] As shown in Figure 5, the initialization module can read and parse the configuration file of the quick freeze function (a first preset configuration file) to determine the status of the quick freeze function switch. The status of the quick freeze function switch can be on, indicating that the mobile phone can activate the quick freeze function provided by this application. When the quick freeze function switch is on, the initialization module can obtain the matching rules of the quick freeze function. The initialization module can then send the matching rules of the quick freeze function to the rule matching module. When the quick freeze function switch is on, the scene recognition module can identify the current scene (the first scene) and send the first scene to the scene judgment module. The scene judgment module can determine whether the first scene belongs to a preset scene. Preset scenes may include, for example, at least one of the following: an electronic device unlocking scene, an electronic device entering or exiting the leftmost home screen scene, an electronic device answering a call and turning off the screen, a first application launching scene, a first application exiting scene, a first application shooting scene, and a first application sliding and dropping frames scene. If the application scene belongs to the preset scene, a target thread (e.g., the iaware.freeze thread) is created. The target thread may include a process collection module, a process identification module, and a rule matching module. The process collection module can be used to collect process information of an electronic device (e.g., a mobile phone). The process information may include the PID of the currently active process. The process collection module may send the process information to the process identification module. The process identification module may identify the characteristic information of the currently active process and send the characteristic information of each currently active process to the rule matching module. The rule matching module matches the characteristic information of the currently active process with the matching rules to determine the process to be frozen. The rule matching module sends the information of the process to be frozen to the power saving wizard application. The freezing packaging processing module of the power saving wizard application can be used to determine whether the process is in a frozen state (for example, during the freezing period of other freezing schemes (for example, the tombstone mechanism scheme)), and to verify whether the state of the process to be frozen has changed. If the process to be frozen is not in a frozen state and the state of the process has not changed, the power saving wizard application notifies the freezing module to freeze the process to be frozen, that is, to set the process to be frozen to an uninterruptible sleep state.

[0120] The following describes the scenarios involved in the embodiments of the present application with reference to the accompanying drawings.

[0121] For example, as shown in FIG6 (a), an electronic device (e.g., a mobile phone) may display a main interface 601, which includes a camera application logo 602. The electronic device may receive a user operation (e.g., a click operation) on the camera application logo 602. In response to the operation, the electronic device displays a startup animation of the camera application (e.g., the logo 602 gradually enlarges). Then, as shown in FIG6 (b), the electronic device may display a shooting preview interface 603.

[0122] In an embodiment of the present application, in response to the user's operation on the identifier 602 of the camera application, the electronic device can recognize that the camera application is in the startup scene and can create a target thread. The process information of multiple processes of the electronic device is collected through the target thread. Determine the process to be frozen among the multiple processes. Set the process to be frozen to an uninterruptible sleep state (i.e., freeze the process to be frozen). Thus, the corresponding background process can be frozen when the electronic device displays the startup animation of the camera application, avoiding the problem of jamming when the electronic device displays the startup animation of the camera application, thereby improving the user experience.

[0123] For another example, as shown in FIG7 (a), the electronic device may receive an operation in which the user swipes up a first distance from the bottom of the screen (an operation to exit the camera application) while displaying the preview interface 701 of the camera application. In response to this operation, the electronic device may display an animation effect for exiting the camera application (e.g., interface 701 gradually shrinks). Then, as shown in FIG7 (b), the mobile phone may display interface 702 of the camera application.

[0124] In an embodiment of the present application, in response to the user's operation of exiting the camera application, the electronic device can recognize that the camera application is in the exit scene and can create a target thread. The process information of multiple processes of the electronic device is collected through the target thread. Determine the process to be frozen among the multiple processes. Set the process to be frozen to an uninterruptible sleep state (that is, freeze the process to be frozen). Thus, the corresponding background process can be frozen when the electronic device displays the exit animation of the camera application (exiting the camera application), avoiding the problem of freeze when the electronic device displays the exit animation of the camera application, thereby improving the user experience.

[0125] For another example, as shown in (a) of FIG8 , the electronic device can display the WeChat application When the interface 801 receives the user's operation of starting the shooting function (for example, the user clicks the shooting control 802), in response to the operation, the electronic device can display the shooting interface 803 as shown in (b) in Figure 8.

[0126] In an embodiment of the present application, in response to the user starting the shooting function, the electronic device can recognize that the camera application is in the shooting scene and create a target thread. The process information of multiple processes of the electronic device is collected through the target thread. The process to be frozen among the multiple processes is determined. The process to be frozen is set to an uninterruptible sleep state (i.e., the process to be frozen is frozen). Thus, the corresponding background process can be frozen when the electronic device is shooting, avoiding the problem of jamming when the electronic device is shooting, thereby improving the user experience.

[0127] It should be understood that the application scenarios provided in the embodiments of the present application may also include other interfaces of other applications, and the embodiments of the present application do not specifically limit the application scenarios and user operations.

[0128] For ease of understanding, the process of the freezing method provided in the embodiment of the present application is described below with reference to the accompanying drawings.

[0129] As shown in Figure 9, an embodiment of the present application provides a method for freezing a process, which is applied to an electronic device (e.g., a mobile phone). Taking the electronic device as an example, the mobile phone may include an initialization module, a scene recognition module, a scene judgment module, a process acquisition module, a process identification module, and a rule matching module at the application framework layer, a power saving wizard application at the application layer, and a freezing module at the kernel layer. The method includes:

[0130] 901. The mobile phone loads the initialization module.

[0131] When the mobile phone is turned on, an initialization module can be loaded. The initialization module can read the status of the quick freezing function switch from the first preset configuration file. The status of the quick freezing function switch can be on, indicating that the mobile phone can activate the quick freezing function provided by this application, that is, the mobile phone can execute the following steps (e.g., steps 902-911).

[0132] 902. The scene recognition module recognizes a first scene.

[0133] Among them, the first scene can be, for example, a scene of unlocking the electronic device, a scene of the electronic device entering or exiting the negative one screen, a scene of the electronic device answering a call and turning off the screen, a scene of launching the first application, a scene of exiting the first application, a scene of shooting the first application, a scene of sliding and dropping frames of the first application, a scene of switching the screen between horizontal and vertical directions of the electronic device, etc. Among them, the scene of switching the screen between horizontal and vertical directions of the electronic device can refer to a scene in which the electronic device switches the display effect of the displayed content after sensing a change in the posture of the electronic device through a sensor (gravity sensor or acceleration sensor).

[0134] The scene recognition module can identify scenes of non-desktop (noHome) applications. Non-desktop applications refer to applications other than desktop applications.

[0135] In a possible design, the scene recognition module may recognize the first scene by means of "insertion".

[0136] Exemplarily, the scene recognition module can "insert" in the startup function of the application, that is, insert the insertion function in the insertion point of the startup function of the application in advance. When the insertion point of the startup function of the application is executed, the insertion function is executed, and the first scene can be identified in real time as the application startup scene.

[0137] 903. The scene recognition module sends the first scene to the scene judgment module.

[0138] The scene recognition module may send the currently recognized scene (first scene) to the scene determination module. For example, the first scene may be an application startup scene.

[0139] 904. The scene determination module determines whether the first scene belongs to a preset scene.

[0140] In an embodiment of the present application, a preset scene may be preset in the scene determination module. For example, the preset scene may include at least one of the following: an electronic device unlocking scene, an electronic device entering or exiting the negative one screen scene, an electronic device answering a call and turning off the screen, a first application launching scene, a first application exiting scene, a first application shooting scene, and a first application sliding frame loss scene.

[0141] The scene determination module can determine whether the current scene (first scene) belongs to the preset scene. For example, if the first scene is the application startup scene, then the first scene belongs to the preset scene. If the first scene is the landscape screen switching scene, then the first scene does not belong to the preset scene.

[0142] If the first scene belongs to a preset scene, the background process may be frozen to improve the user interaction experience. That is, the subsequent steps (e.g., steps 905-911) may be performed to determine the background process to be frozen and perform the freezing. If the first scene does not belong to a preset scene, the subsequent steps do not need to be performed.

[0143] 905. If the first scenario belongs to the preset scenario, create a target thread and collect process information of the mobile phone.

[0144] That is, when the first scene is identified as a preset scene, a target thread (e.g., iaware.freeze thread) may be created. The target thread may include a process collection module, a process identification module, and a rule matching module. The process collection module may be used to collect process information of the mobile phone.

[0145] The process information may include the PID of the currently active process, which may include a foreground process and a background process.

[0146] For example, the PID of the currently active process may include 7813, 8319, and the like.

[0147] 906. The process collection module sends process information to the process identification module.

[0148] The process collection module can send the PID of the currently active process to the process identification module.

[0149] 907. The process identification module can identify characteristic information of the currently active process.

[0150] After receiving the PID of the currently active process from the process collection module, the process identification module can identify the characteristic information of each process corresponding to the PID of the currently active process.

[0151] The characteristic information of a process may include the state, relevance, type, and permissions of the process.

[0152] The state of a process can be, for example, a foreground running state (i.e., the process is a foreground process) or a background running state (i.e., the process is a background process). The relevance of a process is used to indicate whether the process is related to the foreground process. Processes related to the foreground process can communicate with the foreground process through the binder mechanism. For example, processes related to the foreground process may include floating window processes.

[0153] The type of the process may be, for example, a navigation type, a sports or health detection type, an audio type, etc. Of course, the type of the process may also be other types, which are not limited in this application.

[0154] The permissions of a process indicate whether the user allows the process to run.

[0155] For example, when the process type is a navigation type (ie, the process is a navigation process), and the process permission is that the user allows the process to run, the process can continue to call the GPS to collect data.

[0156] When the process type is a motion or health detection type (ie, the process is a motion or health detection process), and the process permission is that the user allows the process to run, the process can continuously call sensors (eg, accelerometers) to collect data.

[0157] When the process type is an audio type (ie, the process is an audio process) and the process permission is that the user allows the process to run, the process can continuously call the audio module (eg, a microphone or a speaker) to play audio.

[0158] 908. The process identification module sends characteristic information of each currently active process to the rule matching module.

[0159] For example, assuming that currently active processes include processes with PIDs 7813 and 8319, the characteristic information of the processes may be as shown in Table 1.

[0160] Table 1

[0161] That is, the process with PID 7813 is a background process, not related to the foreground process, its process type is navigation type, and the process permission is user-allowed. The process with PID 8319 is a background process, not related to the foreground process, its process type is audio type, and the process permission is user-unallowed.

[0162] 909. The rule matching module matches the characteristic information of the currently active process with the matching rules to determine the process to be frozen.

[0163] The rule matching module can obtain the matching rules for the quick freeze function from the initialization module. If the quick freeze function is on, the initialization module can read and parse the second preset configuration file using the ConfigReader class to obtain the matching rules for the quick freeze function. The initialization module can then send the matching rules for the quick freeze function to the rule matching module.

[0164] The matching rules may include the following matching conditions:

[0165] Condition 1: If the process is in the foreground running state (i.e., the process is a foreground process), the process is not a process to be frozen.

[0166] Condition 2: If the affinity of the process indicates that the process is related to the foreground process, the process is not a process to be frozen.

[0167] Condition 3: If the process type of the process belongs to the preset type and the process permission is allowed by the user, the process does not belong to the process to be frozen.

[0168] For each currently active process, if the process's feature information meets any of the matching conditions of the matching rules, the process is considered not to be frozen. By removing (removing) the processes that are not to be frozen from the currently active processes, the processes to be frozen can be obtained. Specifically, the processes to be frozen are processes other than the foreground process, processes related to the foreground process, and background processes allowed to run by the user. Background processes allowed to run by the user include at least one of the following: navigation processes, exercise or health monitoring processes, and audio processes.

[0169] After the rule matching module determines all the processes to be frozen, it can also determine parameters such as the freezing duration (ie, the first duration) and the freezing interval (ie, the second duration) of all the processes to be frozen.

[0170] The freezing time refers to the time that all processes to be frozen are in a frozen state (ie, an uninterruptible sleeping state).

[0171] The freeze interval is the shortest time interval between two freezes, that is, the shortest time interval between the end time (end time) of the last freeze of all processes to be frozen and the start time (start time) of the next freeze. During the freeze interval, the process is in a thawed state, that is, it is not in an uninterruptible sleep state.

[0172] The following is an example of how to determine the freezing time.

[0173] In one possible design, if the start time and end time of the first scene can be identified, the freezing duration of the background process can be adjusted as needed based on the start time and end time of the first scene. For example, the freezing duration can be the length of the time period between the start time and end time of the first scene.

[0174] For example, when the first scene is the startup scene, the start time and end time of the application startup scene can be identified. During the start time and end time of the application startup scene, the processes to be frozen (for example, background process 1 and background process 2) can be frozen, that is, background process 1 and background process 2 are placed in an uninterruptible sleep state. As shown in Figure 10, during the start time and end time of the application startup scene, the application process (foreground process) is in the startup animation period, and the processes to be frozen (for example, background process 1 and background process 2) can be placed in an uninterruptible sleep state (Uninterruptible Sleep (non-IO)).

[0175] In another possible design, if the start and end times of the first scenario cannot be identified, the freezing duration of the processes to be frozen under different first scenarios can be determined based on a preset mapping relationship. Specifically, the freezing duration can be determined based on the first preset duration corresponding to the first scenario. For example, the freezing duration can be the same as the first preset duration corresponding to the first scenario.

[0176] Exemplarily, the preset mapping relationship may be as shown in Table 2, and different scenes may correspond to the first preset durations of different gears.

[0177] Table 2

[0178] It should be noted that Table 2 is only an example of the preset mapping relationship. The preset mapping relationship can be configured as other contents, which is not limited in this application.

[0179] In some implementations, the above-mentioned preset mapping relationship may be determined according to the following steps.

[0180] S1. First, start N (for example, 20) applications and return them to the background to run, thereby obtaining N background processes. When the electronic device is in the first scenario, freeze the N background processes for a second preset duration (for example, 5 seconds).

[0181] S2. Calculate the processor load value (ie, CPU load) every preset time interval (eg, 20 ms) within a second preset duration (eg, 5 s).

[0182] Exemplarily, as shown in Table 3, the processor load values ​​are calculated for each time interval under different scenarios (case 1 to case 7 represent different scenarios, respectively).

[0183] Table 3

[0184] S3. For each scenario, within a preset duration (e.g., 5s), when the last processor load value is less than a preset value (e.g., 80%), record the time difference (first time difference) between the start time of the second preset duration (i.e., the time when freezing starts) and the time (i.e., the target time) when the last processor load value is less than the preset value (e.g., 80%).

[0185] S4. For each scene, execute steps S1-S3 L times (for example, 50 times) to obtain L time differences, calculate the average of the L time differences, and determine the preset duration corresponding to each scene based on the average.

[0186] As shown in Table 4, taking L as 50 as an example, steps S1-S3 can be executed 50 times for different scenarios (case 1-case 7 represent different scenarios respectively) to obtain 50 time differences, and the average of the 50 time differences is calculated. The unit of the time difference can be milliseconds (ms).

[0187] Table 4

[0188] Furthermore, a first preset duration corresponding to each scene is determined according to the mean value corresponding to each scene.

[0189] For example, as shown in Table 4, the mean of the time difference corresponding to case 1 may be 3069.9 ms, which is close to the highest level (MAX) in Table 3. Therefore, the first preset duration corresponding to case 1 may be the highest level (MAX) in Table 2, i.e., 3 s.

[0190] For another example, as shown in Table 4, the mean values ​​of the time differences corresponding to case2-case7 are relatively close to the lowest gear (MIN) in Table 3, so the first preset duration corresponding to case2-case7 can be the lowest gear (MIN) in Table 2, i.e., 1s.

[0191] It should be noted that when the last processor load value within the second preset duration is less than a preset value (e.g., 80%), it can be considered that the load reduction effect has been achieved. That is, the time difference between the start of the second preset duration and the last time the processor load value was less than the preset value is a reasonable duration for freezing background processes. Therefore, it is reasonable to determine the freezing duration corresponding to different scenarios based on the mean of the time difference. This can not only achieve the load reduction effect, but also avoid the problem of excessive freezing duration affecting the stability of background processes.

[0192] The following is an exemplary description of how to determine the freezing interval.

[0193] In some embodiments, a test scenario for quickly launching and exiting applications can be constructed. For example, FIG11 shows a schematic diagram of a test scenario for quickly launching and exiting applications. Assume that within a period of time, such as time period T, an application is launched every 1 second, and each application exits after running for 0.5 seconds. For example, application A can be launched at 0 seconds, exited at 0.5 seconds, application B can be launched at 1 second, exited at 1.5 seconds, and so on.

[0194] For the test scenario of rapid application startup and exit, different freezing strategies can be adopted and the freezing ratio of different freezing strategies can be calculated. Different freezing strategies correspond to different freezing durations and / or freezing intervals.

[0195] Where, the freezing ratio = freezing time / total time. The freezing time refers to the sum of the freezing time within the total time. The total time is the duration of a period of time (for example, time period T).

[0196] Table 5 shows the freezing ratios for different freezing strategies over a period of time (e.g., time period T, which may be 15 seconds). Different freezing strategies have different values ​​for freezing duration and / or freezing interval.

[0197] Table 5

[0198] For policies 10-12, the freezing duration is 3 seconds in the app startup scenario and 1.5 seconds in the app exit scenario. For the other policies, the freezing durations are the same for both app startup and app exit scenarios.

[0199] According to Table 1, the longer the freezing time, the shorter the freezing interval, the greater the freezing ratio, and the higher the efficiency of triggering freezing. In other words, the shorter the freezing interval, the higher the efficiency of triggering freezing. However, if the freezing interval is too short (too short), it may affect the stability of the application (process). For example, if the application is WeChat application For example, WeChat application You can receive messages during the freezing interval. If the freezing interval is too short, WeChat application The WeChat app may be frozen again before receiving the message. An exception occurred in receiving messages, affecting the WeChat application Therefore, when setting the freezing interval, the freezing ratio and the stability of the application can be considered comprehensively to achieve a balance between the freezing ratio and the stability of the application.

[0200] In some embodiments, the freezing interval may be set to 1 second, taking into account the freezing ratio and application stability.

[0201] 910. The rule matching module sends information about the process to be frozen to the power saving wizard application.

[0202] The information of the process to be frozen may include the PID of the process to be frozen, the freezing duration, and the freezing reason. The freezing reason may be used to indicate a first scenario (eg, an application startup scenario).

[0203] After the Power Saver app obtains information about the process to be frozen, it can make the following judgments:

[0204] 1. Determine whether the process indicated by the PID of the process to be frozen is in a frozen state (for example, during the freezing period of other freezing schemes (for example, the tombstone mechanism scheme)).

[0205] 2. If the process indicated by the PID of the process to be frozen is not in the frozen state, it is also possible to check whether the state of the process has changed. For example, it can be checked whether the process has changed from a background process to a foreground process, or from a background process unrelated to the foreground process to a process related to the foreground process.

[0206] 911. The power saving wizard application notifies the freezing module to freeze the process to be frozen.

[0207] If the power saving wizard application determines that the process indicated by the PID of the process to be frozen is not in the frozen state and the state of the process has not changed, the freezing module may be notified to freeze the process to be frozen.

[0208] If the power saving wizard application determines that some processes indicated by the PIDs of the processes to be frozen are in a frozen state, or the state of the processes changes, the part of the processes can be deleted from the processes to be frozen, and the remaining processes can be sent to the freezing module of the kernel layer for freezing.

[0209] For example, the power saving wizard application can write the PID of the process to be frozen into the cgroup.procs file and the frozen state into the cgroup.freeze file, so that the freezing module of the kernel layer freezes the process to be frozen, that is, sets the process to be frozen into an uninterruptible sleep state.

[0210] Exemplarily, if the electronic device is in the first scenario, as shown in FIG12 , a target thread may be created. When the target thread is in a running state, the processes to be frozen (e.g., background process 1, background process 2, and background process 3) may be determined. The target thread may freeze the processes to be frozen through the power saving wizard application and the freezing module of the kernel layer, that is, setting the processes to be frozen (e.g., background process 1, background process 2, and background process 3) to an uninterruptible sleep state.

[0211] In some embodiments, when the background processes are in the freezing period, there may be some background processes that occupy a high CPU load.

[0212] For example, as shown in FIG13 , assume that during the freezing period, the user exits application A (e.g., the first application) (to the desktop). At this time, the process of application A switches from the foreground process to the background process. The user then launches application B (e.g., the second application). Since quick freezing cannot be triggered during the freezing period (i.e., step 911 cannot be executed), in this case, the background process corresponding to application A still occupies a high CPU load, which will affect the startup speed of application B.

[0213] As shown in Figure 14, after exiting Application A and entering Application B, Application B starts slowly. This is because the process of Application A is still running and has not been frozen, occupying a high CPU load, thus affecting the startup speed of Application B.

[0214] The embodiment of the present application provides a solution (which may be referred to as an on-board solution) that can perform targeted freezing on background processes that occupy a high CPU load during the freezing period.

[0215] The on-board solution provided by the embodiment of the present application is that during the freezing period, if a new background process (for example, the background process of the first application) is identified, the identified new background process can be frozen according to preset rules.

[0216] The preset rule may be, for example, as follows: If the remaining freezing time is greater than or equal to x milliseconds, then freeze the identified new background process. The value of x may be, for example, 500 or 1000, which is not specifically limited in this application. Optionally, the CPU load of the new background process identified during the freezing period is higher than a preset threshold (e.g., 80%).

[0217] Among them, the remaining freezing duration = lastFreezeDurationTime-(currentTime-LastFreezeTime). Among them, lastFreezeDurationTime represents the duration of the last (previous) freezing (that is, the duration of the current freezing period). currentTime represents the current time, that is, the start time of the new scene (the second scene, for example, the startup scene of application B) recognized during the current freezing period. LastFreezeTime represents the start time of the last (previous) freezing. That is, the remaining freezing duration refers to the time difference (the second time difference) between the start time of the second scene and the end time of the freezing period.

[0218] For example, as shown in Figure 15, during the freezing period, the user exits application A (to the desktop) and then launches application B. If the time between the launch of application B and the end of the freezing period is equal to x milliseconds, the process of application A can be frozen, where x is greater than 0.

[0219] It should be noted that if the remaining freezing time is greater than x milliseconds, it means that the current freezing period will continue for a long time. At this time, you can freeze the background processes that occupy a high CPU load in a targeted manner to prevent the background processes that occupy a high CPU load from affecting the applications started during the current freezing period.

[0220] In some embodiments, during a freeze interval, there may be background processes that consume a high CPU load. Therefore, a freeze cannot be triggered during this interval. This is because triggering a freeze during this interval can cause application stability issues.

[0221] For example, as shown in FIG16 , it is assumed that application C is started during the freezing interval. If freezing is triggered at this time, it will cause stability problems for the application.

[0222] This embodiment of the present application provides a solution (the "add-cart solution") where, during a freeze interval, if a new user interaction scenario is identified (for example, a third application in a third scenario), and the third scenario is a preset scenario, the start time of the new user interaction scenario can be recorded, and the time difference between the start time of the new user interaction scenario and the end time of the freeze interval (the third time difference) can be calculated. The freezing is triggered by delaying the time difference. That is, at the end of the freeze interval, the "add-cart" triggers the freezing to reduce the processor load as quickly as possible.

[0223] For example, as shown in Figure 17, when application C is started, the startup time of application C can be recorded, and the time difference between the startup time of application C and the end time of the freezing interval can be calculated. The freezing is triggered by delaying the time difference. That is, at the end of the freezing interval, the "additional car" triggers the freezing to reduce the processor load as quickly as possible.

[0224] In summary, the on-vehicle solution can be used to solve the problem of high processor load caused by failure to trigger quick freezing during the freezing period, and the add-vehicle solution can be used to solve the problem of high processor load caused by failure to trigger quick freezing during the freezing interval.

[0225] Based on the method provided in this application, when the electronic device is in the first scenario, a target thread can be created, and based on the target thread, the process to be frozen among multiple processes of the electronic device can be set to an uninterruptible sleep state, which can reduce the resource consumption of applications running in the background and improve the performance and battery life of the electronic device.

[0226] Some embodiments of the present application provide an electronic device that may include a touch screen, a memory, and one or more processors. The touch screen, memory, and processor are coupled. The memory is used to store computer program code, which includes computer instructions. When the processor executes the computer instructions, the electronic device may perform the various functions or steps performed by the electronic device in the above-described method embodiments. The structure of the electronic device may refer to the structure of electronic device 100 shown in Figure 3.

[0227] An embodiment of the present application also provides a chip system (e.g., a system on a chip (SoC)). As shown in Figure 18, the chip system includes at least one processor 1801 and at least one interface circuit 1802. The processor 1801 and the interface circuit 1802 can be interconnected via lines. For example, the interface circuit 1802 can be used to receive signals from other devices (e.g., a memory of an electronic device). For another example, the interface circuit 1802 can be used to send signals to other devices (e.g., a processor 1801 or a touch screen of an electronic device). Exemplarily, the interface circuit 1802 can read instructions stored in the memory and send the instructions to the processor 1801. When the instructions are executed by the processor 1801, the electronic device (e.g., a mobile phone) can execute the various steps in the above embodiments. Of course, the chip system can also include other discrete components, which are not specifically limited in the embodiments of the present application.

[0228] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes the various functions or steps executed by the electronic device (for example, a mobile phone) in the above-mentioned method embodiment.

[0229] An embodiment of the present application further provides a computer program product, which, when executed on an electronic device, enables the electronic device (eg, a mobile phone) to execute the functions or steps executed by the electronic device in the above method embodiment.

[0230] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0231] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0232] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0233] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0234] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0235] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A freezing method for a process, characterized in that, Applied to an electronic device, the method includes: In response to the electronic device being in a first scenario, create a target thread; Determine a process to be frozen based on the target thread; Based on the target thread, set the process to be frozen to an uninterruptible sleep status.

2. The method according to claim 1, wherein: The electronic device includes a first application, and the first scenario includes at least one of the scenarios of the electronic device being unlocked, the electronic device entering or exiting the leftmost home screen, the electronic device answering a call with the screen off, the first application starting, the first application exiting, the first application taking a photo, and the first application having a frame drop during sliding.

3. The method according to claim 1, wherein The process to be frozen is a process other than a foreground process, a process related to the foreground process, and a background process allowed to run by the user.

4. The method according to claim 3, wherein: The background processes allowed to run by the user include at least one of a navigation process, a motion or health detection process, and an audio process.

5. The method according to any one of claims 1-4, characterized in that, Setting the process to be frozen to an uninterruptible sleep status includes: Setting the process to be frozen to an uninterruptible sleep status within a first duration; wherein the first duration is determined according to the start time and end time of the first scenario.

6. The method according to any one of claims 1-4, characterized in that, Setting the process to be frozen to an uninterruptible sleep status includes: Setting the process to be frozen to an uninterruptible sleep status within a first duration; The first duration is determined according to a first preset duration corresponding to the first scenario.

7. The method according to claim 6, characterized in that, The first preset duration corresponding to the first scenario is determined according to the following steps: Step 1: When the electronic device is in the first scenario, freeze N background processes for a second preset duration, where N is an integer greater than or equal to 1; Step 2: Calculate the processor load value at preset time intervals within the second preset duration; Step 3: Record the first time difference between the start time of the second preset duration and the target time, where the target time is the time when the processor load value calculated last within the second preset duration is less than a preset value; Step 4: Execute steps 1 - 3 L times to obtain L first time differences, calculate the average value of the L first time differences, and determine the first preset duration corresponding to the first scenario according to the average value, where L is an integer greater than or equal to 2.

8. The method according to claim 6 or 7, wherein: When the first scenario is the electronic device entering the leftmost home screen scenario or the electronic device answering a call with the screen off, the first preset duration corresponding to the first scenario is 1 second; When the first scenario is the electronic device unlocking scenario or the first application having a frame drop during sliding, the first preset duration corresponding to the first scenario is 1.5 seconds; When the first scenario is the first application starting scenario, the first preset duration corresponding to the first scenario is 3 seconds.

9. The method according to any one of claims 1-8, characterized in that, The electronic device includes a second application, and the method further includes: During the first time period, in response to the second application being in a second scenario, setting the process corresponding to the first application to an uninterruptible sleep state.

10. The method according to claim 9, wherein The setting the process corresponding to the second application to an uninterruptible sleep state includes: If a second time difference between the start time of the second scenario and the end time of the first time period is greater than a preset time difference, setting the process corresponding to the second application to an uninterruptible sleep state.

11. The method according to any one of claims 5 - 10, wherein After setting the process to be frozen to an uninterruptible sleep state for a first time period, the process to be frozen exits the uninterruptible sleep state, and is set to the uninterruptible sleep state again after at least an interval of a second time period.

12. The method according to claim 11, wherein The second time period is 1 second.

13. The method according to claim 11 or 12, characterized in that, The electronic device includes a third application, and the method further includes: During the second time period, in response to the third application being in a third scenario, recording the start time of the third scenario, and calculating a third time difference between the start time of the third scenario and the end time of the second time period, and setting the process to be frozen to an uninterruptible sleep state after the third time difference.

14. An electronic device, characterized in that, The electronic device includes a display screen, a processor, and a memory; the memory stores program instructions; the processor is configured to run the program instructions stored in the memory, so that the electronic device executes the method according to any one of claims 1 - 13.

15. A computer-readable storage medium, characterized in that, The computer - readable storage medium includes program instructions, and when the program instructions run on an electronic device, the electronic device executes the method according to any one of claims 1 - 13.