Process freezing method and device

By setting the process to an uninterruptible sleep state in specific scenarios, the problem of background processes occupying resources is solved, the performance and battery life of electronic devices are improved, and the user experience is optimized.

CN120255683APending Publication Date: 2025-07-04HONOR DEVICE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311835942.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, background processes occupy too much CPU and memory resources of electronic devices, affecting device performance and battery life. The existing freezing strategy cannot effectively solve this problem.

Method used

In specific scenarios, by creating a target thread, the process to be frozen is set to an uninterruptible sleep state, reducing the resource consumption of background processes, and optimizing the freezing strategy using the on-board and adding car schemes to avoid affecting the user experience.

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 CN120255683A_ABST
    Figure CN120255683A_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

Technical Field

[0001] Embodiments of the present application relate to the field of terminals, and in particular, to a method and device for freezing processes. Background Art

[0002] Currently, the operating system of an electronic device (such as a mobile phone), such as the Android operating system, can run the processes of some applications in the background to ensure the startup speed when the user resumes using these application processes. However, if there are too many processes running in the background (i.e., background processes), it will consume a large amount of system resources of the electronic device, such as the central processing unit (CPU) and memory. Summary of the Invention

[0003] Embodiments of the present application provide a method and device for freezing processes, which can reduce the resource consumption of background processes and improve the performance and battery life of electronic devices.

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

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

[0006] Based on the method provided by the present 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 status, which can reduce the resource consumption of background processes and improve the performance and battery life of the electronic device.

[0007] In a 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 and turning off the screen scenario, a first application starting scenario, a first application exiting scenario, a first application shooting scenario, and a first application sliding and dropping frames scenario. That is, in the electronic device unlocking scenario, the electronic device entering or exiting the leftmost home screen scenario, the electronic device answering and turning off the screen scenario, the first application starting scenario, the first application exiting scenario, the first application shooting scenario, or the first application sliding and dropping frames scenario, the electronic device can create a target thread and set the process to be frozen among multiple processes of the electronic device to an uninterruptible sleep status based on the target thread, which can reduce the resource consumption of applications running in the background and improve the performance and battery life of the electronic device.

[0008] In a possible implementation, 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. In this way, it is possible to avoid freezing the foreground process, the process related to the foreground process, and the background process allowed to run by the user, thus avoiding affecting the user experience.

[0009] In a possible implementation, 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. In this way, it is possible to avoid freezing processes such as the navigation process, the motion or health detection process, and the audio process that are allowed to run by the user, thus avoiding affecting the user experience.

[0010] In a 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; where the first duration is determined according to the start time and end time of a first scenario. For example, the first duration can be the duration of the time period between the start time and end time of the first scenario. Taking the first scenario as the startup scenario of a first application as an example, when the first application is in the startup scenario, 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 processes to be frozen among the multiple processes are determined. The processes to be frozen are set to an uninterruptible sleep state (i.e., the processes to be frozen are frozen). Thus, it is possible to freeze the corresponding background processes when the electronic device displays the startup animation of the first application, avoiding the problem of jamming when the electronic device displays the startup animation of the first application, and thus improving the user experience.

[0011] In a 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; the first duration is determined according to 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. Setting the process to be frozen to an uninterruptible sleep state within the first duration can reduce the resource consumption of the applications running in the background and improve the performance and battery life of the electronic device.

[0012] In a 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, freeze N background processes for a second preset duration, where N is an integer greater than or equal to 1; Step 2, within the second preset duration, calculate the processor load value at preset time intervals; 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 the preset value; Step 4, execute steps 1 - 3 for 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. It should be noted that when the processor load value is less than the preset value (for example, 80%) for the last time within the second preset duration, it can be considered that the effect of reducing the load is achieved. That is, the time difference (the first time difference) between the start moment of the second preset duration and the moment when the processor load value is less than the preset value for the last time is the reasonable duration for freezing the background processes. Therefore, it is reasonable to determine the freezing duration (i.e., the first duration) corresponding to different scenarios according to the average value of multiple (for example, L) first time differences, which can not only achieve the effect of reducing the load but also avoid the problem that the freezing duration is too long and affects the stability of the background processes.

[0013] In a possible implementation, when the first scenario is that the electronic device enters the negative first screen scenario or the electronic device answers the call in the screen-off 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 frame drop 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.

[0014] In a possible implementation, the electronic device includes a second application, and the method further includes: within the first duration, in response to the second application being in the second scenario, set the process corresponding to the first application to an uninterruptible sleep state. In this way, during the freezing period (i.e., within the first duration), if it is recognized that the second application is in the second scenario, it means that the process corresponding to the first application has switched to a background process, and the process corresponding to the first application (i.e., the new background process) can be frozen. This avoids the process of the first application occupying a high CPU load and affecting the startup or running speed of the second application.

[0015] In a possible implementation, setting the process corresponding to the second application to an uninterruptible sleep state includes: if the second time difference between the start time of the second scenario 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 > 0), it means that the first duration will still last for a relatively long time. At this time, the process of the first application can be specifically frozen to avoid the impact of occupying the process of the first application on the startup or operation of the second application.

[0016] In a possible implementation, after setting the process to be frozen to an uninterruptible sleep state for the first duration, the process to be frozen exits the uninterruptible sleep state and is set to an uninterruptible sleep state again at least after an interval of the second duration. That is, within the first duration, the process to be frozen is in an uninterruptible sleep state (frozen state), and within the second duration, the process to be frozen is not in an uninterruptible sleep state (i.e., thawed state). In this way, the problem of continuously freezing the process to be frozen and affecting the stability of the application can be avoided.

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

[0018] In a possible implementation, the electronic device includes a third application. The method further includes: within the second duration, in response to the third application being in the third scenario, recording the start time of the third scenario and calculating the third time difference between the start time of the third scenario 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. In this way, at the end of the freezing interval (i.e., the second duration), the freezing can be immediately triggered to reduce the processor load as soon as possible.

[0019] In a second aspect, the present application provides a chip system, which includes one or more interface circuits and one or more processors. The interface circuits and the processors are interconnected by lines. The above chip system can be applied to an electronic device including a communication module and a memory. The interface circuit is used to receive a signal from the memory of the electronic device and send the received signal to the processor, and the signal includes computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device can execute the method as described in the first aspect and any of its possible design manners.

[0020] In a third aspect, the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions run on an electronic device (such as a mobile phone), the electronic device is caused to execute the method as described in the first aspect and any of its possible design manners.

[0021] Fourthly, the present application provides a computer program product. When the computer program product runs on a computer, the computer is caused to execute the method as described in the first aspect and any possible design manner thereof.

[0022] Fifthly, an embodiment of the present application provides a process management device for an application program, including a processor. The processor is coupled to a memory, and the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the device is caused to implement the method as described in the first aspect and any possible design manner thereof. The device may be an electronic device or a server device; or may be a component of an electronic device or a server device, such as a chip.

[0023] Sixthly, an embodiment of the present application provides a process management device for an application program. The device may be divided into different logical units or modules according to functions, and each unit or module executes different functions, so that the device executes the method as described in the first aspect and any possible design manner thereof.

[0024] It can be understood that for 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, reference may be made to the beneficial effects in the first aspect and any possible design manner thereof, and details are not described herein again. Description of the Drawings

[0025] Figure 1 Schematic diagram of a refrigeration mechanism of a related technology provided by an embodiment of the present application;

[0026] Figure 2 Schematic diagram of a thawing mechanism of a related technology provided by an embodiment of the present application;

[0027] Figure 3 Schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application;

[0028] Figure 4 Schematic diagram of the software architecture of an electronic device provided by an embodiment of the present application;

[0029] Figure 5 Schematic diagram of the interaction between modules provided by an embodiment of the present application;

[0030] Figure 6 Schematic diagram of a scenario provided by an embodiment of the present application;

[0031] Figure 7 Schematic diagram of another scenario provided by an embodiment of the present application;

[0032] Figure 8Schematic diagram of another scenario provided by the embodiments of the present application;

[0033] Figure 9 Interaction schematic diagram applicable to the freezing method of a process provided by the embodiments of the present application;

[0034] Figure 10 Schematic diagram of the state of a process provided by the embodiments of the present application;

[0035] Figure 11 Schematic diagram of a test scenario for rapid startup and exit of an application provided by the embodiments of the present application;

[0036] Figure 12 Schematic diagram of the state of another process provided by the embodiments of the present application;

[0037] Figure 13 Schematic diagram showing that freezing cannot be triggered during freezing provided by the embodiments of the present application;

[0038] Figure 14 Schematic diagram of the state of another process provided by the embodiments of the present application;

[0039] Figure 15 Schematic diagram of a boarding plan provided by the embodiments of the present application;

[0040] Figure 16 Schematic diagram showing that freezing cannot be triggered during the freezing interval provided by the embodiments of the present application;

[0041] Figure 17 Schematic diagram of an additional vehicle plan provided by the embodiments of the present application;

[0042] Figure 18 Schematic diagram of the structure of a chip system provided by the embodiments of the present application. Detailed implementation manners

[0043] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application. Among them, in the description of the present application, unless otherwise specified, "at least one" means one or more, and "a plurality" means two or more than two. In addition, in order to clearly describe the technical solutions in the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and effects. Those skilled in the art can understand that the terms "first" and "second" do not limit the quantity and execution order, and the terms "first" and "second" do not necessarily limit being different.

[0044] For the sake of clear and concise description of the following embodiments, a brief introduction to relevant concepts or technologies is given first:

[0045] Foreground process: A foreground process is a process that is visible and operable to the user. Foreground processes can preferentially run on a processor with stronger processing capabilities (e.g., a big-core processor), execute quickly, and have a relatively high scheduling priority.

[0046] Background process: A background process is a process that is not operable by the user (unless closed). The priority of a background process is lower than that of a foreground process. Background processes usually run on a processor with weaker processing capabilities (e.g., a small-core processor) and execute more slowly. Foreground processes and background processes can be swapped.

[0047] Thread: A thread is the smallest unit that the operating system can perform operation scheduling on. It is contained within a process and is the actual operating unit within the process. A thread refers to a single sequential control flow within a process. Multiple threads can be concurrent within a process, and each thread executes different tasks in parallel. A thread is the basic unit for independent scheduling and dispatching. A thread can be a kernel thread scheduled by the operating system kernel; it can also be a user thread scheduled by the user process itself; or a thread with mixed scheduling by the kernel and the user process.

[0048] Freezing: The electronic device restricts the system resources occupied by background processes. The system resources can include CPU resources, sensors, memory, etc.

[0049] Thawing: The electronic device removes the restriction on the system resources occupied by background processes.

[0050] Currently, the operating system of an electronic device (e.g., a mobile phone) (e.g., the Android operating system) can run the processes of some applications in the background to ensure the startup speed when the user resumes using these application processes. However, if there are too many processes running in the background (i.e., background processes), it will occupy a relatively large amount of system resources such as the CPU and memory of the electronic device. How to restrict background processes so as not to affect the performance and battery life of the electronic device is an urgent matter to be solved.

[0051] In some related technologies, to solve the above problems, a freezing strategy with a tombstone mechanism can be adopted to restrict the resource usage of background processes.

[0052] Exemplarily, such as Figure 1As shown, in response to an operation of clicking on the icon of Application A (abbreviated as A in the figure), the Activity Manager Service (AMS) can call updateOomAdjLocked to update the adj (CACHED_APP_MIN_ADJ) of Application A. The adj of Application A can be used to indicate the process priority of Application A. For example, the adj of the process of Application A can be changed to 0, and Application A is switched to the foreground application (i.e., the process of Application A is the foreground process). In response to the operation of exiting Application A and clicking on the icon of Application B, the AMS can change the adj of Application A to 700, and Application A becomes the previous application. In response to the operation of exiting Application B and clicking on the icon of Application C, the AMS can change the adj of Application A to 900, and Application A is switched to a cached application (i.e., the process of Application A is in the cached state). When the adj of Application A is greater than or equal to 900, the system can freeze the process of Application A (for example, CachedAppOptimizer can call freezeAppAsyncLSP to freeze the process of Application A). To prevent tasks of the process of Application A from not being completed when entering the cached state and thus indirectly affecting the user experience, after the debounce time (i.e., the anti-shake time, for example, it can be 10 minutes), the system freezes the process of Application A. The abstraction layer can notify the control groups (cgroup) of the kernel 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 the embodiments of the present application, exiting an application (for example, 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 directly started from the background. Closing an application (for example, Application A) means that the process of Application A is killed, and the next time Application A is started, the OnCreate method needs to be called again.

[0053] As Figure 2As shown, when the state of Application A changes and the adj value of Application A changes, for example, when the adj of Application A is less than 900, the system can unfreeze the process of Application A (for example, CachedAppOptimizer can call unfreezeAppLSP to unfreeze the process of Application A). Before officially unfreezing the process of Application A, it can first check whether the process has received a synchronous binder request (SYNC_RECEIVED_WHILE_FROZEN) during the freezing period. If so, the process can be killed. This is because the synchronous Binder to the frozen process will make the state of the process uncertain, so the process needs to be killed. Then, the abstraction layer can notify the kernel cgroup to unfreeze the process of Application A, and the kernel cgroup can unfreeze the process of Application A, so that the process of Application A is unfrozen.

[0054] However, the freezing strategy of the tombstone mechanism cannot freeze (also known as freeze) the process within the debounce time (for example, 10 minutes). This is to prevent the application process from having unfinished tasks when entering the cached state, which indirectly affects the user experience. Therefore, the freezing strategy of the tombstone mechanism cannot guarantee the resource consumption of the electronic device during the debounce time, thus affecting the performance and battery life of the electronic device.

[0055] In some other related technologies, a basic freezing control period can be set, and the application can be dynamically controlled between freezing and unfreezing based on the set basic freezing control period in a cycle, so as to achieve a balance between energy saving and the normal execution of the application function.

[0056] However, freezing and unfreezing the application by setting the freezing control period cannot effectively solve the problem of background processes preempting the CPU resources of the foreground application in some important scenarios (such as application startup, exit, etc.).

[0057] This application provides a method for freezing processes, which can briefly freeze background processes during user interaction scenarios (such as application startup, exit, etc.) during the interval of other freezing schemes (such as during the debounce time). Reduce the resource consumption of background processes, solve the problem of background processes preempting the system resources of foreground processes, improve the performance and battery life of electronic devices, and thus enhance the user experience.

[0058] Figure 3 It is a schematic structural diagram of an electronic device 100 provided by an embodiment of this application.

[0059] As Figure 3As shown, 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, antennas 1, 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0060] Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric 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.

[0061] It can 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 combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0062] 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), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

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

[0064] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may hold the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be directly called from the said memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0065] 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, etc.

[0066] It can be understood that the interface connection relationships between the modules illustrated in this embodiment are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection methods or combinations of multiple interface connection methods in the above embodiments.

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

[0068] 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 the inputs from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, the wireless communication module 160, etc. In some other embodiments, the power management module 141 may also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device.

[0069] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.

[0070] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: the antenna 1 can be multiplexed as the diversity antenna of the wireless local area network.

[0071] The mobile communication module 150 can provide wireless communication solutions such as 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves through the antenna 1 and radiate it out.

[0072] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator 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 transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194.

[0073] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.

[0074] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, such that the electronic device 100 can communicate with the network and other devices through wireless communication technologies. The wireless communication technologies 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 technologies, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).

[0075] The electronic device 100 implements the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to execute mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

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

[0077] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc. The ISP is used to process the data fed back by the camera 193. The camera 193 is used to capture static 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 coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0078] The camera 193 can include 1 to N. For example, the electronic device can include 2 front cameras and 4 rear cameras. The NPU is a neural-network (NN) computing processor. By drawing on the structure of the biological neural network, such as the transmission mode between human brain neurons, it can quickly process the input information and can also continuously self-learn. Through the NPU, applications such as the intelligent cognition of the electronic device 100 can be realized, such as: image recognition, face recognition, voice recognition, text understanding, etc.

[0079] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to implement the storage capacity expansion of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement the 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 codes, and the executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. For example, in the embodiment of this application, the processor 110 can execute the instructions stored in the internal memory 121. The internal memory 121 can include a storage program area and a storage data area. Among them, the storage program area can store an operating system, applications required for at least one function (such as a sound playback function, an image playback function, etc.). The storage data area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.). In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0080] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and an application processor, etc. For example, music playback, recording, etc.

[0081] The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used for encoding and decoding audio signals. The speaker 170A, also called a "loudspeaker", is used to convert an audio electrical signal into a sound signal. The receiver 170B, also called a "handset", is used to convert an audio electrical signal into a sound signal. The microphone 170C, also called a "microphone", "transmitter", is used to convert a sound signal into an electrical signal. The headphone jack 170D is used to connect a wired headphone.

[0082] The button 190 includes a power-on button, volume buttons, etc. The button 190 can be a mechanical button or a touch button. 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 and can also be used for touch vibration feedback. The indicator 192 can be an indicator light and can be used to indicate the charging state, power change, and can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect the SIM card. The SIM card can be in contact with and separated from the electronic device 100 by inserting 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.

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

[0084] The software system of the above electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservices architecture, or cloud architecture. In the embodiments of the present invention, taking the Android system with a layered architecture as an example, the software structure of the electronic device 100 is exemplarily described.

[0085] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers is through interfaces. In some embodiments, the Android system can 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 take the Android system as an example. In other operating systems (such as HarmonyOS, 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.

[0086] Among them, the application layer can include a series of application packages.

[0087] As Figure 4 shown, the application packages can include video, games, maps, WLAN, music, short messages, gallery, calls, navigation, power-saving wizard, etc. Of course, the application layer can also include other application packages, such as applications like Bluetooth, calendar, camera, settings, etc. This application does not make any limitations. In the embodiments of the present application, the application layer can also include a first application, a second application, a third application, etc. The first application, the second application, or the third application can be, for example, any one of the aforementioned applications (such as video, game, etc. applications).

[0088] In the embodiments 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 solutions (such as the tombstone mechanism solution)), and to verify whether the state of the process has changed.

[0089] The application framework layer provides application programming interfaces (APIs) and programming frameworks 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. The embodiments of the present application do not impose any restrictions on this.

[0090] In the embodiments of the present application, the application framework layer may further include a real-time protection system (iaware real-time subsystem). The real-time protection system can run in the system_server process. The real-time protection system may include an initialization module, a scenario recognition module, a scenario judgment module, a process collection module, a process recognition module, and a rule matching module, etc. Among them, the process collection module, the process recognition module, and the rule matching module belong to the iaware.freeze thread.

[0091] Among them, the initialization module is used to read the state of the quick freezing function switch from a first preset configuration file. The state of the quick freezing function switch can be an on state, indicating that the mobile phone can activate the quick freezing function provided by the present application.

[0092] The scenario recognition module is used to recognize the scenario of non-desktop (noHome) applications. Among them, non-desktop applications refer to applications other than desktop applications.

[0093] The scenario judgment module is used to determine whether the current scenario of the application belongs to a preset scenario. The preset scenario may include, for example, at least one of an electronic device unlocking scenario, an electronic device entering or exiting the leftmost home screen scenario, an electronic device answering and turning off the screen scenario, a first application startup scenario, a first application exit scenario, a first application shooting scenario, and a first application sliding and frame dropping scenario.

[0094] Among them, the 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 where the electronic device collects the user's fingerprint through a fingerprint sensor in the locked 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 where the electronic device receives the password entered by the user in the locked 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 where the electronic device collects face data through a camera (e.g., a front camera) in the locked screen state and compares the collected face data with the face data entered by the user to determine whether to unlock the electronic device.

[0095] The scenario where the electronic device enters the leftmost home screen refers to a scenario where the electronic device displays the leftmost home screen after receiving a preset operation from the user (e.g., an operation of swiping the screen to the right on the main screen of the electronic device). Of course, the preset operation can also be other operations, which are not limited in this application.

[0096] The scenario where the electronic device turns off the screen during a call refers to a scenario where the screen automatically turns off when the electronic device senses an object (e.g., the user's side face) approaching through a light sensor during a call.

[0097] The first application startup scenario may refer to a scenario where the electronic device starts the first application after receiving an operation (e.g., a click operation) on the icon of the first application on the desktop by the user. Or, the first application startup scenario may refer to a scenario where the electronic device starts the first application after receiving an operation on the card of the first application in the task list by the user.

[0098] The first application exit scenario may refer to a scenario where the electronic device returns to the desktop after receiving an operation to exit the first application. The operation to exit the first application may be, for example, the operation of the user clicking the home key (a functional key for returning to the desktop). Among them, the home key can be a physical key or a virtual key, which is not limited in this application. Or, the operation to exit the first application may be the operation of the user clicking the back key (e.g., clicking once, or clicking twice continuously). Among them, the back key is used to return to the previous interface. Or, the operation to exit the first application may be a quick gesture operation. The quick gesture operation can be any one of the following operations: an operation of swiping up a first distance from the bottom of the screen, an operation of swiping right from the left end of the screen, an operation of swiping left from the right end of the screen.

[0099] The first application shooting scenario refers to a scenario where the first application calls the camera for shooting during operation. For example, the first application can be a chat application. When the user needs to send a picture during a chat, the camera can be called to shoot the required picture.

[0100] The first application sliding frame dropping scenario may refer to a scenario where, during the operation of the first application, in response to a user's sliding operation, corresponding processing is performed (for example, scrolling display), but frame dropping and lag occur during the corresponding processing (for example, scrolling display).

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

[0102] 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, etc.

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

[0104] The kernel layer is the layer between the hardware and the software. The kernel layer at least includes a display driver, a camera driver, an audio driver, and a sensor driver (not shown in the figure). The kernel layer may also include a real time (RT) scheduler, a very important person (VIP) scheduler, a completely fair scheduler (CFS) scheduler / energy aware scheduler (EAS) scheduler, etc.

[0105] In the embodiments of the present application, the kernel layer may also include a freezing module.

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

[0107] The hardware layer includes a central processing unit / processor (CPU), a GPU, a double data rate SDRAM (synchronous dynamic random-access memory) (DDR SDRAM), etc. Of course, the hardware layer may also include other hardware, such as a display, a camera, etc.

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

[0109] The system libraries may include multiple functional modules. For example: surface manager, Media Libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc.

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

[0111] The Media Libraries support the playback and recording of various common audio and video formats, as well as static image files, etc. The Media Libraries can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0112] OpenGL ES is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.

[0113] SGL is a drawing engine for 2D drawing.

[0114] Android Runtime includes core libraries and a virtual machine. Android Runtime is responsible for the scheduling and management of the Android system. The core libraries contain two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0115] The HAL layer is an encapsulation of the Linux kernel driver, providing an interface upward and shielding the implementation details of the lower-level hardware.

[0116] Next, in combination with Figure 5 The software modules involved in the process freezing method provided by the embodiments of this application and the interactions between the modules will be described.

[0117] As Figure 5As shown, the initialization module can read and parse the configuration file (the first preset configuration file) of the quick freezing function to determine the state of the quick freezing function switch. The state of the quick freezing function switch can be the on state, indicating that the mobile phone can activate the quick freezing function provided by this application. When the state of the quick freezing function switch is the on state, the initialization module can obtain the matching rules of the quick freezing function. Then, the initialization module can send the matching rules of the quick freezing function to the rule matching module. When the state of the quick freezing function switch is the on state, the scene recognition module can recognize the current scene (the first scene) and send the first scene to the scene judgment module. The scene judgment module can judge whether the first scene belongs to the preset scene. The preset scene can include, for example, at least one of the electronic device unlocking scene, the electronic device entering or exiting the leftmost home screen scene, the electronic device answering and turning off the screen scene, the first application startup scene, the first application exit scene, the first application shooting scene, and the first application sliding and frame dropping scene. If the scene of the application belongs to the preset scene, a target thread (for example, the iaware.freeze thread) is created. The target thread can include a process collection module, a process recognition module, and a rule matching module. Among them, the process collection module can be used to collect the process information of the electronic device (for example, the mobile phone). The process information can include the PID of the currently active process. The process collection module can send the process information to the process recognition module. The process recognition module can recognize 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 and packaging processing module of the power saving wizard application can be used to judge whether the process is in the frozen state (for example, during the freezing period of other freezing solutions (such as the tombstone mechanism solution)), and verify whether the state of the process to be frozen has changed. If the process to be frozen is not in the frozen state and the state of the process has not changed, the power saving wizard application notifies the freezing module to execute freezing on the process to be frozen, that is, sets the process to be frozen to the uninterruptible sleep state.

[0118] The following uses the accompanying drawings to give examples of the scenes involved in the embodiments of this application.

[0119] Exemplarily, as Figure 6 shown in (a) of, the electronic device (for example, the mobile phone) can display the main interface 601, and the main interface 601 includes the identifier 602 of the camera application. The electronic device can receive an operation (for example, a click operation) of the user on the identifier 602 of the camera application. In response to this operation, the electronic device displays the startup animation of the camera application (for example, the identifier 602 gradually enlarges). Then, as Figure 6As shown in (b) thereof, the electronic device may display a shooting preview interface 603.

[0120] In an embodiment of the present application, in response to an operation of the user on the identifier 602 of the camera application, the electronic device may recognize that the camera application is in a startup scenario and may create a target thread. The process information of multiple processes of the electronic device is collected through the target thread. The processes to be frozen among the multiple processes are determined. The processes to be frozen are set to an uninterruptible sleep state (i.e., the processes to be frozen are frozen). Thus, the corresponding background processes 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.

[0121] For another example, as Figure 7 shown in (a) thereof, when the electronic device displays the preview interface 701 of the camera application, it may receive an operation of the user swiping up a first distance from the bottom of the screen (an operation to exit the camera application). In response to this operation, the electronic device may display an animation for exiting the camera application (for example, the interface 701 gradually shrinks). Then, as Figure 7 shown in (b) thereof, the mobile phone may display the interface 702 of the camera application.

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

[0123] For another example, as Figure 8 shown in (a) thereof, when the electronic device displays the interface 801 of the WeChat application and receives an operation of the user to start the shooting function (for example, a click operation on the shooting control 802), in response to this operation, as Figure 8 shown in (b) thereof, the electronic device may display the shooting interface 803.

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

[0125] 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 make specific limitations on the application scenarios and user operations.

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

[0127] As Figure 9 shown, the embodiments of the present application provide a process freezing method, which is applied to an electronic device (for example, a mobile phone). Taking the electronic device as a mobile phone as an example, the mobile phone may include an initialization module, a scene recognition module, a scene judgment module, a process collection module, a process recognition module, 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:

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

[0129] When the mobile phone is powered on, the 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 an on state, indicating that the mobile phone can start the quick freezing function provided by the present application, that is, the mobile phone can execute the following steps (for example, step 902 - step 911).

[0130] 902. The scene recognition module recognizes the first scene.

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

[0132] The scene recognition module can recognize the scenes of non - desktop (noHome) applications. Among them, non - desktop applications refer to applications other than desktop applications.

[0133] In a possible design, the scenario recognition module can recognize the first scenario by means of "instrumentation".

[0134] Exemplarily, the scenario recognition module can perform "instrumentation" in the startup function of the application, that is, insert an instrumentation function into the insertion point of the startup function of the application in advance. When the execution reaches the insertion point of the startup function of the application, the instrumentation function is executed, and thus the first scenario can be recognized in real time as the application startup scenario.

[0135] 903. The scenario recognition module sends the first scenario to the scenario judgment module.

[0136] The scenario recognition module can send the currently recognized scenario (the first scenario) to the scenario judgment module. For example, the first scenario can be the application startup scenario.

[0137] 904. The scenario judgment module determines whether the first scenario belongs to a preset scenario.

[0138] In the embodiments of the present application, preset scenarios can be preset in the scenario judgment module. Exemplarily, the preset scenarios can include at least one of an electronic device unlocking scenario, an electronic device entering or exiting the negative first screen scenario, an electronic device answering and turning off the screen scenario, a first application startup scenario, a first application exit scenario, a first application shooting scenario, and a first application sliding frame dropping scenario.

[0139] The scenario judgment module can determine whether the current scenario (the first scenario) belongs to a preset scenario. For example, when the first scenario is the application startup scenario, the first scenario belongs to the preset scenario. When the first scenario is the landscape / portrait switching scenario, the first scenario does not belong to the preset scenario.

[0140] If the first scenario belongs to the preset scenario, the background processes can be considered for freezing to improve the user interaction experience. That is, subsequent steps (for example, steps 905 - step 911) can be executed to determine the background processes to be frozen and perform the freezing. If the first scenario does not belong to the preset scenario, the subsequent steps do not need to be executed.

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

[0142] That is, when it is recognized that the first scenario is a preset scenario, a target thread (for example, the iaware.freeze thread) can be created. The target thread can include a process collection module, a process recognition module, and a rule matching module. Among them, the process collection module can be used to collect the process information of the mobile phone.

[0143] Among them, the process information can include the PID of the currently active process. The currently active processes can include foreground processes and background processes.

[0144] Exemplarily, the PIDs of the currently active processes may include, for example, 7813, 8319, and so on.

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

[0146] The process collection module may send the PIDs of the currently active processes to the process identification module.

[0147] 907. The process identification module may identify the characteristic information of the currently active processes.

[0148] After receiving the PIDs of the currently active processes from the process collection module, the process identification module may identify the characteristic information of each process corresponding to the PIDs of the currently active processes.

[0149] Among them, the characteristic information of the process may include the status, relevance, type, and permissions of the process.

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

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

[0152] The permissions of the process are used to indicate whether the user allows the process to run.

[0153] Exemplarily, when the type of the process is a navigation type (i.e., the process is a navigation process) and the permissions of the process are that the user allows the process to run, the process may continuously call the GPS to collect data.

[0154] When the type of the process is a sports or health detection type (i.e., the process is a sports or health detection process) and the permissions of the process are that the user allows the process to run, the process may continuously call the sensor (for example, an acceleration sensor) to collect data.

[0155] When the type of the process is an audio type (i.e., the process is an audio process) and the permissions of the process are that the user allows the process to run, the process may continuously call the audio module (for example, a microphone or a speaker) to play audio.

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

[0157] Exemplarily, assume that the currently active processes include processes with PIDs 7813 and 8319, and the characteristic information of the above processes can be as shown in Table 1.

[0158] Table 1

[0159]

[0160] That is, the process with PID 7813 is a background process, not related to the foreground process, its process type is of the navigation type, and the process permission is allowed to run by the user. The process with PID 8319 is a background process, not related to the foreground process, its process type is of the audio type, and the process permission is not allowed to run by the user.

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

[0162] The rule matching module can obtain the matching rules of the quick freezing function from the initialization module. When the status of the quick freezing function switch is in the on state, the initialization module can read and parse the second preset configuration file through the configreader class to obtain the matching rules of the quick freezing function. Then, the initialization module can send the matching rules of the quick freezing function to the rule matching module.

[0163] Among them, the matching rules can include the following matching conditions:

[0164] Condition 1: If the status of the process is the foreground running state (i.e., the process is a foreground process), then the process does not belong to the processes to be frozen.

[0165] Condition 2: If the relevance of the process indicates that the process is related to the foreground process, then the process does not belong to the processes to be frozen.

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

[0167] For each process in the currently active processes, if the characteristic information of the process meets any one of the matching conditions of the matching rules, it is considered that the process does not belong to the processes to be frozen. Excluding (removing) the processes that do not belong to the processes to be frozen from the currently active processes, the processes to be frozen can be obtained. That is, the processes to be frozen are processes other than foreground processes, processes related to foreground processes, and background processes allowed to run by the user. The background processes allowed to run by the user include at least one of navigation processes, motion or health detection processes, and audio processes.

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

[0169] Among them, the freezing duration refers to the duration for which all the processes to be frozen are in the frozen state (i.e., the non-interruptible sleep state).

[0170] The freezing interval refers to the shortest time interval between two freezings, that is, the shortest time interval between the end time of the last freezing of all the processes to be frozen and the start time of the next freezing. During the freezing interval, the process is in the thawed state, that is, it is not in the non-interruptible sleep state.

[0171] The following gives an exemplary description of the method for determining the freezing duration.

[0172] In a possible design, if the start time and end time of the first scenario can be identified, the freezing duration of the background process can be adjusted as needed according to the start time and end time of the first scenario. For example, the freezing duration can be the duration of the time period between the start time and end time of the first scenario.

[0173] For example, when the first scenario is the startup scenario, the start time and end time of the application startup scenario can be identified. During the start time and end time of the application startup scenario, the processes to be frozen (e.g., background process 1 and background process 2) can be frozen, that is, the background process 1 and background process 2 are set to the non-interruptible sleep state. As Figure 10 shown, during the start time and end time of the application startup scenario, when the process of the application (foreground process) is in the startup animation period, the processes to be frozen (e.g., background process 1 and background process 2) can be set to the non-interruptible sleep state (UninterruptibleSleep(non-IO)).

[0174] In another possible design, if the start time and end time of the first scenario cannot be identified, the freezing duration of the processes to be frozen in different first scenarios can be determined according to the preset mapping relationship. That is, the freezing duration can be determined according to 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.

[0175] Exemplarily, the preset mapping relationship can be as shown in Table 2, and different scenarios can correspond to different gears of the first preset duration.

[0176] Table 2

[0177]

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

[0179] In some embodiments, the above preset mapping relationship can be determined according to the following steps.

[0180] S1. First, start N (for example, 20) applications and move them to the background to run, 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 s).

[0181] S2. Within the second preset duration (for example, 5 s), calculate the processor load value (i.e., CPU load) every preset time interval (for example, 20 ms).

[0182] Exemplarily, as shown in Table 3, the processor load values calculated for each time interval in different scenarios (case1 - case7 represent different scenarios) are respectively presented.

[0183] Table 3

[0184]

[0185]

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

[0187] S4. For each scenario, execute steps S1 - S3 L times (for example, 50 times) to obtain L time differences, calculate the mean value of the L time differences, and determine the preset duration corresponding to each scenario according to the mean value.

[0188] As shown in Table 4, taking L as 50 as an example, that is, for different scenarios (case1 - case7 represent different scenarios), steps S1 - S3 can be executed 50 times to obtain 50 time differences, and calculate the mean value of the 50 time differences. Among them, the unit of the time difference can be milliseconds (ms).

[0189] Table 4

[0190] Number of times Case 1 Case2 Case3 Case 4 Case 5 Case 6 Case 7 1 1951 204 643 747 267 2056 1259 2 3185 216 465 791 189 423 592 3 5000 183 362 831 164 469 459 … … … … … … … … 50 3294 162 435 729 116 436 338 Mean value 3069.9 154.78 427.06 768.46 142.76 488.6 523.22

[0191] Furthermore, determine the first preset duration corresponding to each scenario according to the mean value corresponding to each scenario.

[0192] Exemplarily, as shown in Table 4, the average value of the time difference corresponding to case1 can be 3069.9 ms, and this average value is close to the highest gear (MAX) in Table 3. Therefore, the first preset duration corresponding to case1 can be the highest gear (MAX) in Table 2, that is, 3 s.

[0193] For another example, as shown in Table 4, the average values of the time differences corresponding to case2 - case7 are relatively close to the lowest gear (MIN) in Table 3. Therefore, the first preset durations corresponding to case2 - case7 can be the lowest gear (MIN) in Table 2, that is, 1 s.

[0194] It should be noted that when the last processor load value within the second preset duration is less than the preset value (for example, 80%), it can be considered that the effect of reducing the load is achieved. That is, the time difference between the start time of the second preset duration and the time when the last processor load value is less than the preset value is the reasonable duration for freezing background processes. Therefore, it is reasonable to determine the freezing durations corresponding to different scenarios according to the average value of the time difference, which can not only achieve the effect of reducing the load but also avoid the problem that too long freezing duration affects the stability of background processes.

[0195] The following gives an exemplary description of the determination method of the freezing interval.

[0196] In some embodiments, a test scenario for rapid startup and exit of an application can be constructed. Exemplarily, as Figure 11 shown, it is a schematic diagram of a test scenario for rapid startup and exit of an application. Assume that within a period of time, for example, within time period T, an application is started every 1 s, and each application runs for 0.5 s and then exits. For example, application A can be started at the 0 s, application A can exit at the 0.5 s, application B can be started at the 1 s, application B can exit at the 1.5 s, and so on.

[0197] For the test scenario of rapid startup and exit of an application, different freezing strategies can be adopted, and the freezing occupancy ratios of different freezing strategies can be calculated. Among them, the values of the freezing durations and / or freezing intervals corresponding to different freezing strategies are different.

[0198] Among them, the freezing occupancy ratio = freezing time / total time. Among them, the freezing time refers to the sum of the freezing durations within the total time. The total time is the duration of a period of time (for example, time period T).

[0199] As shown in Table 5, within a period of time (for example, within time period T, and time period T can be 15 s for example), the freezing occupancy ratios when different freezing strategies are adopted. The values of the freezing durations and / or freezing intervals corresponding to different freezing strategies are different.

[0200] Table 5

[0201]

[0202]

[0203] Among them, the freezing durations of Strategies 10 - 12 indicate that in the application startup scenario, the freezing duration is 3s, and in the application exit scenario, the freezing duration is 1.5s. The freezing durations of the remaining strategies are the same in both the application startup scenario and the application exit scenario.

[0204] According to Table 1, the longer the freezing duration, the shorter the freezing interval, the larger the freezing occupancy ratio, and the higher the efficiency of triggering freezing. That is, the shorter the freezing interval, the higher the efficiency of triggering freezing. However, if the freezing interval is too short, it may affect the stability of the application (process). For example, take the WeChat application as an example For example, the WeChat application can receive messages during the freezing interval. If the freezing interval is too short, the WeChat application may be frozen again before it has time to receive the message, resulting in the WeChat application having an abnormal message reception, affecting the stability of the WeChat application Therefore, when setting the freezing interval, the freezing occupancy ratio and the stability of the application can be comprehensively considered to achieve a balance between the freezing occupancy ratio and the stability of the application.

[0205] In some embodiments, considering the freezing occupancy ratio and the stability of the application comprehensively, the freezing interval can be set to 1s.

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

[0207] Among them, 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. Among them, the freezing reason can be used to indicate the first scenario (for example, the application startup scenario).

[0208] After obtaining the information of the process to be frozen, the power saving wizard application can make the following judgments:

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

[0210] 2. If the process indicated by the PID of the process to be frozen is not in the frozen state, it can also verify whether the state of the process has changed. For example, verify 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.

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

[0212] 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, it can notify the freezing module to freeze the process to be frozen.

[0213] If the power saving wizard application determines that some of the processes indicated by the PID of the process to be frozen are in the frozen state, or the state of the process has changed, it can delete the part of the process from the process to be frozen and send the remaining processes to the freezing module in the kernel layer for freezing.

[0214] Exemplarily, the power saving wizard application can write the PID of the process to be frozen into the cgroup.procs file and write the Frozen state into the cgroup.freeze file, so that the freezing module in the kernel layer can freeze the process to be frozen, that is, set the process to be frozen to an uninterruptible sleep state.

[0215] Exemplarily, if the electronic device is in the first scenario, such as Figure 12 shown, a target thread can be created. When the target thread is in the running state, the processes to be frozen (for example, background process 1, background process 2, and background process 3) can be determined. The target thread can freeze the processes to be frozen through the power saving wizard application and the freezing module in the kernel layer, that is, set the processes to be frozen (for example, background process 1, background process 2, and background process 3) to an uninterruptible sleep state.

[0216] In some embodiments, when a background process is being frozen, there may be some background processes with a relatively high CPU load occupancy.

[0217] Exemplarily, as Figure 13 shown, it is assumed that during the freezing period, the user exits from application A (for example, the first application) (to the desktop), and at this time, the process of application A switches from the foreground process to the background process. Then, the user starts application B (for example, the second application). Since fast freezing cannot be triggered during the freezing period (that is, step 911 cannot be executed). In this case, the background process corresponding to application A still occupies a relatively high CPU load, which will affect the startup speed of application B.

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

[0219] The embodiment of the present application provides a solution (which can be called the on-board solution), which can specifically freeze the background processes with a relatively high CPU load occupancy during the freezing period.

[0220] The boarding solution provided by the embodiments of this application is that during the freezing period, if a new background process (for example, the background process of the first application) is recognized, the recognized new background process can be frozen according to a preset rule.

[0221] The preset rule can be, for example: if the remaining freezing duration is greater than or equal to x milliseconds, then the recognized new background process is frozen. Among them, the value of x can be, for example, 500 or 1000, and this application does not make specific limitations. Optionally, the CPU load of the new background process recognized during the freezing period is higher than a preset threshold (for example, 80%).

[0222] 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 recognizing a new scenario (the second scenario, for example, the startup scenario of application B) 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 scenario and the end time of the freezing period.

[0223] Exemplarily, as Figure 15 shown, during the freezing period, the user exits from application A (to the desktop), and then, the user starts application B. If the duration between the moment when application B starts and the end time of the freezing period is equal to x milliseconds, then the process of application A can be frozen. Among them, x is greater than 0.

[0224] It should be noted that if the remaining freezing duration is greater than x milliseconds, it means that the current freezing period will still last for a long time. At this time, targeted freezing can be performed on the background process with a high CPU load to avoid the background process with a high CPU load affecting the application started during the current freezing period.

[0225] In some embodiments, during the freezing interval, there may be some background processes with a high CPU load. And freezing cannot be triggered during the freezing interval. This is because if freezing is triggered during the freezing interval, it will cause stability problems of the application.

[0226] Exemplarily, as Figure 16 shown, assume that during the freezing interval, application C starts. At this time, if freezing is triggered, it will cause stability problems of the application.

[0227] An embodiment of the present application provides a solution (the additional freezing solution). During the freezing interval, if a new user interaction scenario is recognized (for example, the third application is in the third scenario), and the third scenario belongs to the preset scenarios, the start time of the new user interaction scenario can be recorded, and the time difference (the third time difference) between the start time of the new user interaction scenario and the end time of the freezing interval can be calculated, and the freezing is triggered after delaying by this time difference. That is, at the end of the freezing interval, "adding a vehicle" triggers the freezing to reduce the processor load as soon as possible.

[0228] Exemplarily, as Figure 17 shown, when Application C is started, the start time of Application C can be recorded, and the time difference between the start time of Application C and the end time of the freezing interval can be calculated, and the freezing is triggered after delaying by this time difference. That is, at the end of the freezing interval, "adding a vehicle" triggers the freezing to reduce the processor load as soon as possible.

[0229] In summary, the getting-on vehicle solution can be used to solve the problem that the processor load is relatively high because rapid freezing cannot be triggered during freezing, and the additional freezing solution can be used to solve the problem that the processor load is relatively high because rapid freezing cannot be triggered during the freezing interval.

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

[0231] Some embodiments of the present application provide an electronic device, which may include: a touch screen, a memory, and one or more processors. The touch screen, the memory, and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute each function or step executed by the electronic device in the above method embodiments. The structure of the electronic device can refer to Figure 3 the structure of the electronic device 100 shown.

[0232] An embodiment of the present application also provides a chip system (for example, a system on a chip (SoC)), as Figure 18As shown, 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 by a line. For example, the interface circuit 1802 can be used to receive signals from other devices (such as the memory of an electronic device). For another example, the interface circuit 1802 can be used to send signals to other devices (such as the processor 1801 or the touch screen of an electronic device). Exemplarily, the interface circuit 1802 can read the 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 (such as a mobile phone) can execute each step in the above embodiments. Of course, the chip system can also include other discrete devices, and the embodiments of the present application do not make specific limitations on this.

[0233] The embodiments of the present application also provide a computer-readable storage medium, which includes computer instructions. When the computer instructions run on the above-mentioned electronic device, the electronic device is enabled to execute each function or step that the electronic device (such as a mobile phone) executes in the above method embodiments.

[0234] The embodiments of the present application also provide a computer program product. When the computer program product runs on an electronic device, the electronic device (such as a mobile phone) is enabled to execute each function or step that the electronic device executes in the above method embodiments.

[0235] Through the description of the above embodiments, those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

[0236] In several embodiments provided by the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical functional division. In actual implementation, there can be other division methods. For example, 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 displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.

[0237] The unit described as a separation component may or may not be physically separated. The component shown as a unit may be a single physical unit or multiple physical units, that is, it may be located in one place or distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0238] In addition, each functional unit in various embodiments of the present application may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.

[0239] 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 embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions for causing a device (which may be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read only memory (ROM), random access memory (RAM), magnetic disks, or optical discs and other various media that can store program codes.

[0240] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for freezing 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 where the electronic device is unlocked, enters or exits the leftmost home screen, answers a call in the screen-off state, the first application is launched, the first application exits, the first application takes a photo, and the first application has a frame-drop during sliding.

3. The method according to claim 1, characterized in that, 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 to 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, wherein 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 for 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 scenario where the electronic device enters the leftmost home screen or the scenario where the electronic device answers a call in the screen-off state, the first preset duration corresponding to the first scenario is 1 second; When the first scenario is the scenario where the electronic device is unlocked or the first application has a frame-drop during sliding, the first preset duration corresponding to the first scenario is 1.5 seconds; When the first scenario is the scenario where the first application is launched, 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 a start time of the second scenario and an 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 at least after 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 a start time of the third scenario, and calculating a third time difference between the start time of the third scenario and an 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.

Citation Information

Cited By

  • Process freezing method and apparatus

    EP4749399A1

  • Process freezing method and apparatus

    WO2025138903A1