A freezing management method, terminal device and computer-readable storage medium

By querying the frozen flag bit of the process in the smartphone and managing its status, it solves the problem of abnormal operation caused by logical conflicts after the operating system is updated, and achieves stable operation and low power consumption of the terminal device.

CN117762502BActive Publication Date: 2024-09-06HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311442765.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2024-09-06
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

After the smartphone operating system is updated, the logic of new functions may conflict with the logic of installed applications, causing the terminal device to run abnormally, such as high power consumption and lags.

Method used

Provide a freezing management method that determines the status of a process by querying its freezing flag, and defrosts or freezes the process when necessary to avoid conflicts and ensure the normal operation of the terminal device. The method includes establishing a queue in the terminal device to record the situation when the process is called, so as to respond to the call after thawing, periodically querying whether the queue is empty or in a frozen state, and thawing the process in time.

Benefits of technology

It effectively avoids conflicts between multiple freezing management mechanisms, reduces the power consumption of terminal equipment, and ensures the normal operation and stable performance of the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117762502B
    Figure CN117762502B
Patent Text Reader

Abstract

The present application provides a freezing management method, a terminal device, and a computer-readable storage medium, which relate to the field of terminal technology. The freezing management method is applied to a terminal device, which includes a first process, and the method includes: when the terminal device includes a first queue corresponding to the first process and the first queue is not empty, query the freezing flag of the first process, the first queue is used to record the situation that the first process is called after the first process is frozen; in response to querying the first flag corresponding to the first process, unfreeze the first process, and update the freezing flag of the first process to a second flag; wherein, in response to querying the second flag corresponding to the first process, the freezing flag of the first process is not unfrozen and not updated; the first flag indicates that the first process is in a frozen state, and the second flag indicates that the first process is in a thawed state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a freezing management method, a terminal device, and a computer-readable storage medium. Background Art

[0002] Smartphones are terminal devices with independent operating systems, independent operating spaces, and users can install applications provided by third-party service providers. Smartphones can also access wireless networks through mobile communication networks. The operating system installed in a smartphone is the core control software of the smartphone, and is a program that manages and controls the hardware and software resources of the phone. The operating system can determine how users interact with the phone, as well as the efficiency of the interaction.

[0003] Mobile phone manufacturers and operating system manufacturers will continuously release new versions of operating systems in order to improve and optimize mobile phone performance. If there are problems in the old version of the operating system, the updated new version of the operating system can generally provide solutions to the problems, or if the functions in the old version of the operating system are not perfect, the updated new version of the operating system will add some new functions. In this way, with the update of the operating system, the performance and stability of the terminal device will also be improved.

[0004] However, when there are new functions in the updated operating system, the logic corresponding to the new functions in the operating system may conflict with the logic of the applications installed in the terminal device, resulting in abnormalities in the operation of the terminal device, such as high power consumption and operation lag. Summary of the invention

[0005] In view of this, the present application provides a freezing management method, a terminal device and a computer-readable storage medium, which can achieve consistent freezing management when there are two sets of freezing management mechanisms for applications in the terminal device, avoid conflicts, and reduce the possibility of abnormal operation.

[0006] In a first aspect, the present application provides a freezing management method, which is applied to a terminal device, wherein the terminal device includes a first process, and the method includes: when the terminal device includes a first queue corresponding to the first process and the first queue is not empty, querying the freezing flag of the first process, and the first queue is used to record the situation in which the first process is called after the first process is frozen.

[0007] In response to querying the first flag bit corresponding to the first process, the first process is thawed and the frozen flag bit of the first process is updated to the second flag bit; wherein, in response to querying the second flag bit corresponding to the first process, the frozen flag bit of the first process is not thawed and not updated; the first flag bit indicates that the first process is in a frozen state, and the second flag bit indicates that the first process is in a thawed state.

[0008] In the above implementation, in order to record the situation that the first process in the frozen state is called, the terminal device will correspondingly establish a first queue for the first process when the first process is in the frozen state. If the first process in the frozen state is called by other processes, the terminal device will record the information of this call in the first queue, so that after the first process switches from the frozen state to the thawed state, the terminal device can perform corresponding feedback on the call based on the information recorded in the first queue.

[0009] It should be noted that the first process refers to the unfrozen object in the following text. For example, if the terminal device needs to unfreeze the binder process, the first process is the binder process. For another example, if the terminal device needs to unfreeze application A, the first process is the process corresponding to application A. In the following text, if the freeze flag is 1, it means the frozen state, then the first flag is 1. If the freeze flag is 0, it means the unfrozen state, then the second flag is 0. The first queue refers to the to-do list mentioned later.

[0010] Based on the above design, when the first queue corresponding to the first process is not empty, the terminal device may consider that the frozen first process needs to be thawed, so as to ensure that the first process can respond to the call of other processes in a timely manner, thereby ensuring the normal operation of the terminal device. Therefore, if the terminal device inquires the first flag bit corresponding to the first process, indicating that the first process is in a frozen state, the first process can be thawed, and the frozen flag bit of the first process can be updated to the second flag bit. If the terminal device inquires the second flag bit corresponding to the first process, indicating that the first process is in a thawed state, there is no need to thaw the first process at this time. In this way, the terminal device implements the thawing operation based on the first flag bit corresponding to the first process, thereby avoiding the terminal device from being unable to thaw the process that is already in a thawed state, causing the terminal device to repeat the thawing action, ensuring that the terminal device only performs the thawing operation on the process that is already in a frozen state, thereby avoiding the problem of the terminal device repeatedly performing the thawing action causing the terminal device to increase its operating power consumption.

[0011] In a possible implementation of the first aspect, before querying the frozen flag of the first process, the terminal device may also write a first status value to the first process group, the first process group includes the first process, and the first status value indicates that the first process group is in a thawed state; querying the frozen flag of the first process includes: querying the frozen flag of each process in the first process group.

[0012] The terminal device can write the first status value to the first process group through the function provided by the process group management interface, so as to instruct the kernel to perform a thawing operation on the processes included in the first process group.

[0013] The first process group is the Cgroup process group that needs to be unfrozen in the following text. For example, in the following text, when Cgroup process group A needs to be unfrozen, the first process group is Cgroup process group A. For another example, in the following text, when Cgroup process group B needs to be unfrozen, the first process group is Cgroup process group B. The first state value corresponds to THAWED (thawed state) in the following text.

[0014] In another possible implementation of the first aspect, the first process group also includes a second process in the terminal device; after querying the frozen flag of each process in the first process group, the method also includes: in response to querying the first flag corresponding to the second process, unfreezing the second process, and updating the frozen flag of the second process to the second flag; wherein, in response to querying the second flag corresponding to the second process, the frozen flag of the second process is not unfrozen and not updated.

[0015] The first process group may include multiple processes, that is, the first process group includes not only the first process but also the second process. The first process refers to the process currently processed by the terminal device, and the second process refers to other processes except the first process. Therefore, after querying the frozen flag of the first process, the terminal device also needs to query the frozen flag of each other second process in the first process group.

[0016] In a possible implementation of the first aspect, the terminal device may further freeze the first process, update the freezing flag of the first process to the first flag, generate a first queue, and after the first process is called, record the calling of the first process in the first queue. In this way, the terminal device may record the calling request of the first process through the first queue, ensuring that after the frozen first process is unfrozen, it can respond to all calling actions without omission.

[0017] In a possible implementation manner of the first aspect, the method further includes: periodically querying whether the terminal device includes the first queue and whether the first queue is empty.

[0018] Regularly querying whether the terminal device includes the first queue and whether the first queue is empty can ensure that when the first process in the terminal device is in a frozen state, the terminal device promptly unfreezes the first process when called, thereby ensuring that the first process can respond to the calling action in a timely manner to ensure the normal operation of the terminal device.

[0019] In a possible implementation manner of the first aspect, the terminal device may also query a frozen flag of the first process when the first process is not running;

[0020] In response to querying the second flag corresponding to the first process, the first process is frozen, and the frozen flag of the first process is updated to the first flag; wherein, in response to querying the first flag corresponding to the first process, the frozen flag of the first process is not frozen and not updated.

[0021] The first process in a non-running state refers to a process that has not been operated by the user within a preset time period. Such a process occupies the resources of the terminal device. Therefore, the terminal device can freeze the first process in a non-running state after querying it to release the resources of the terminal device.

[0022] In the above implementation, before freezing the first process, the terminal device can determine whether the kernel can freeze the first process by querying the freeze flag of the first process. If the terminal device queries the second flag corresponding to the first process, it indicates that the first process is in a thawed state, and it can be determined that the kernel freezes the first process, and the freeze flag of the first process that is switched from the thawed state to the frozen state is changed to the first flag accordingly. If the terminal device queries the first flag corresponding to the first process, it indicates that the first process is in a frozen state, and it can be determined that the kernel cannot freeze the first process, and the kernel does not freeze and does not update the freeze flag of the first process.

[0023] In a possible implementation manner of the first aspect, the terminal device may periodically query the running status of the first process, where the running status includes a non-running state and a running state.

[0024] In some examples, the first process is in a non-running state, which means that the first process has not been operated by the user within a preset time period; the first process is in a running state, which means that the first process has been operated by the user within a preset time period.

[0025] By regularly querying the running status of the first process in the terminal device, it can be determined whether freezing management needs to be performed on the first process, thereby preventing the first process from occupying more resources in the terminal device for a long time, thereby reducing the power consumption of the terminal device.

[0026] In a possible implementation of the first aspect, the terminal device includes a first freezing management module, a second freezing management module, and a freezing driver. When the first process is not running, the terminal device can query the first freezing management module or the second freezing management module to find that the first process is not running. The first freezing management module or the second freezing management module sends a first instruction to the freezing driver in the kernel, and the first instruction is used to instruct the freezing driver to freeze the first process. In response to the first instruction, the freezing driver queries the freezing flag of the first process. When the second flag corresponding to the first process is queried, the freezing driver freezes the first process and updates the freezing flag of the first process to the first flag.

[0027] The freezing driver is in the kernel, which includes all processes in the terminal device and the freezing flag corresponding to each process. The freezing driver can freeze the processes in the terminal device, and the freezing driver can provide the terminal device with a freezing management interface for freezing processes.

[0028] The first freezing management module may be the power saving wizard mentioned later, and correspondingly, the second freezing management module is the freezing management module of the native operating system recorded later. In the case where the first freezing management module is the freezing management module of the native operating system recorded later, correspondingly, the second freezing management module is the power saving wizard mentioned later.

[0029] In some examples, the first freezing management module or the second freezing management module can freeze the process through a freezing management interface provided by a freezing driver.

[0030] When the first freezing management module or the second freezing management module finds that the first process is not running, it is considered that the first process occupies the resources of the terminal device, which will lead to resource waste. Then, the first freezing management module or the second freezing management module can send a first instruction to the freezing driver through the freezing management interface provided by the freezing driver to instruct the freezing driver to freeze the first process. Before freezing the first process based on the first instruction, the freezing driver queries the freezing flag of the first process. When the freezing driver finds the second flag corresponding to the first process, it indicates that the first process is not frozen at this time. The freezing driver can successfully freeze the first process. Subsequently, the freezing driver can update the freezing flag of the first process to the first flag.

[0031] Correspondingly, if the freezing driver queries the first flag corresponding to the first process, it indicates that the first process is in a frozen state at this time. If the freezing driver freezes the first process again at this time, the first process cannot respond to the freezing operation of the freezing driver, and the freezing fails.

[0032] In some examples, when the freezing driver does not query the first flag of the first process, the first freezing management module sends a first instruction to the freezing driver, and the freezing driver freezes the first process based on the first instruction. After that, the first process is in a frozen state. At this time, there is a situation where the second freezing management module believes that the first process needs to be frozen, then the second freezing management module will send the first instruction to the freezing driver again, instructing the freezing driver to freeze the first process. However, since the first process is already in a frozen state, the freezing driver freezes the first process again, and the first process cannot respond to this freezing operation. In other words, the freezing driver fails to freeze the first process. At this time, the freezing driver will continue to perform the freezing operation on the first process, causing the freezing driver to repeatedly perform the freezing operation that cannot succeed. In this way, the power consumption of the terminal device will increase.

[0033] In a possible implementation of the first aspect, the terminal device includes a first freezing management module and a freezing driver; when the terminal device includes a first queue corresponding to the first process and the first queue is not empty, the freezing flag of the first process is queried, including: when the first freezing management module queries that the terminal device includes a first queue corresponding to the first process and the first queue is not empty, the first freezing management module and / or the second freezing management module sends a first instruction to the freezing driver; in response to the first instruction, the freezing driver queries the freezing flag of the first process; in response to the query of the first flag corresponding to the first process, the first process is unfrozen, and the freezing flag of the first process is updated to the second flag, including: in response to the query of the first flag, the freezing driver unfreezes the first process and updates the freezing flag of the first process to the second flag.

[0034] In the above implementation, before freezing the first process, the terminal device can determine whether the kernel can freeze the first process by querying the freeze flag of the first process. If the terminal device queries the second flag corresponding to the first process, it indicates that the first process is in a thawed state, and it can be determined that the kernel freezes the first process, and the freeze flag of the first process that is switched from the thawed state to the frozen state is changed to the first flag accordingly. If the terminal device queries the first flag corresponding to the first process, it indicates that the first process is in a frozen state, and it can be determined that the kernel cannot freeze the first process, and the kernel does not freeze and does not update the freeze flag of the first process.

[0035] In some examples, when the freezing driver does not query the freezing flag of the first process, the first freezing management module sends a first instruction to the freezing driver, and the freezing driver freezes the first process based on the first instruction. After that, the first process is in a frozen state. There is a second process in the terminal device that has not been frozen. At this time, if the first queue corresponding to the first process and the second process, and the first queue is not empty, the second freezing management module will think that the first process and the second process need to be thawed, then the second freezing management module will send a first instruction to the freezing driver, instructing the freezing driver to thaw the first process. Since the first process is already in a frozen state, the freezing driver can thaw the first process. However, the second process is in a thawed state, and the second process cannot respond to this thawing operation. In other words, the freezing driver fails to thaw the second process. At this time, the freezing driver will continue to perform the freezing operation on the second process, causing the freezing driver to repeat the freezing operation that cannot succeed. In this way, the power consumption of the terminal device will increase.

[0036] In a second aspect, the present application provides a terminal device, comprising a memory and one or more processors; the memory and the processor are coupled; the memory is used to store computer program code, and the computer program code comprises computer instructions; when the processor executes the computer instructions, the terminal device executes the method described in the first aspect and any possible design thereof.

[0037] In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions, which, when executed on a terminal device, enables the terminal device to execute the method described in the first aspect and any possible design thereof.

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

[0039] In a fifth aspect, the present application provides a device, which is included in a terminal device, and the device has the function of implementing the behavior of the terminal device in any of the above aspects and possible implementation methods. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, an allocation module or unit, a scanning module or unit, a recycling module or unit, a moving module or unit, and a storage module or unit, etc.

[0040] In a sixth aspect, an embodiment of the present application provides a chip system, which includes a processor and may also include a memory, for implementing any one of the methods provided in the first aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.

[0041] It can be understood that the terminal device described in the second aspect and any possible design method provided above, the computer-readable storage medium described in the third aspect, and the computer program product described in the fourth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A schematic diagram of a terminal device provided in an embodiment of the present application;

[0043] Figure 2 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0044] Figure 3 A software structure diagram of a terminal device provided in an embodiment of the present application;

[0045] Figure 4 A schematic diagram of freezing management provided in an embodiment of the present application;

[0046] Figure 5 A schematic diagram of a freezing management method provided in an embodiment of the present application;

[0047] Figure 6 A schematic diagram of a freezing management method provided in an embodiment of the present application;

[0048] Figure 7 A schematic diagram of a freezing management method provided in an embodiment of the present application;

[0049] Figure 8 A schematic diagram of a freezing management conflict provided in an embodiment of the present application;

[0050] Fig. 9 A schematic diagram of a freezing management method provided in an embodiment of the present application;

[0051] Fig.10 A schematic diagram of another freezing management conflict provided in an embodiment of the present application;

[0052] Fig.11 A schematic diagram of a freezing management method provided in an embodiment of the present application;

[0053] Fig.12 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In the following, the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

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

[0056] Before introducing the embodiments of the present application, the technologies involved in the embodiments of the present application are first introduced in detail.

[0057] 1. Freezing applications refers to a way of managing applications that have not been operated by users for a long time. By freezing applications, the computing resources of the terminal device occupied by the applications can be released. After the application is frozen, the processes related to the application will suspend certain processing. For example, the frozen application cannot respond to calls from other applications.

[0058] In some examples, the terminal device sends a SIGSTOP signal to a process in an application, and in response to receiving the SIGSTOP signal, the process in the application enters a frozen state.

[0059] It should be noted that the freezing of an application needs to be distinguished from the application entering a blocked state. The application entering a blocked state means that the application enters a low-power sleep state while waiting for resources. When resources arrive, the application in the sleep state can directly process the resources, that is, it is awakened. After the application is frozen, it cannot process the incoming resources, that is, it cannot be awakened.

[0060] It should be noted that freezing an application needs to be distinguished from closing an application. Freezing an application does not terminate the execution of the application or destroy the application. Freezing an application only temporarily suspends the application to optimize the allocation and use of computing resources. Once the application needs to be run again, the application can be unfrozen and resumed to achieve the purpose of quickly starting the application. However, when a closed application is opened again, corresponding preparations need to be made, which will cause a long waiting time.

[0061] In the terminal device in the embodiment of the present application, the freezing management of the application can be implemented through a third-party application (for example, a power saving wizard, an application manager, etc.), a freezing management module of the operating system, etc.

[0062] 2. Control groups (Cgroup) can refer to the entire Cgroup technology or a specific Cgroup process group. Cgroup technology is a mechanism for managing processes in groups. Cgroup technology manages and controls the use of system resources by processes in the form of groups. For example, a terminal device groups all processes through Cgroup process groups to obtain one or more Cgroup process groups, and then allocates and controls resources for the Cgroup process groups that need to be managed in one or more Cgroup process groups.

[0063] In the embodiment of the present application, the Cgroup process group can be used to implement freezing management of the application. For example, the terminal device can set the state of the Cgroup process group to the frozen state (FROZEN) through the Cgroup interface (i.e., the process group management interface), thereby freezing all processes in the Cgroup process group. In this way, the frozen process will no longer be scheduled or run, that is, the frozen process will no longer consume the resources of the central processing unit (CPU) and the memory resources. Until the terminal device sets the state of the Cgroup process group to the thawed state (THAWED), all processes in the Cgroup process group will be thawed.

[0064] 2. Binder (Chinese: adhesive) mechanism: the logic of inter-process communication. Process 1 obtains information from process 2, and process 1 can initiate a binder call. After receiving the binder call, process 2 returns a response call to process 1.

[0065] 3.iaware process: a process that manages and controls applications.

[0066] In the embodiment of the present application, the iaware process can manage and control the application. For example, the iaware process can freeze the application or unfreeze the application.

[0067] The power saving wizard described below uses the iaware process to freeze or unfreeze applications to achieve the purpose of saving power.

[0068] In some examples, the iaware process implements freezing management of applications through the Cgroup process group.

[0069] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0070] In order to better understand the embodiments of the present application, the terminal device provided in the embodiments of the present application is first introduced.

[0071] like Figure 1As shown, the terminal device 100 may be a mobile phone 11, a tablet computer 12, a smart screen 13, a laptop computer 14, a vehicle-mounted device, a wearable device (such as a smart watch), an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), an artificial intelligence device, etc. The embodiment of the present application does not limit the specific type of the terminal device 100 or the installed operating system.

[0072] The operating system installed in the terminal device is used to manage and control the software and hardware resources of the terminal device. Currently, the terminal device operating system is developed, maintained and updated by various manufacturers.

[0073] In some embodiments, if there are problems in the old version of the operating system, the updated new version of the operating system can generally provide solutions to the problems, or if the functions in the old version of the operating system are not perfect, the updated new version of the operating system will add some new functions. In this way, as the operating system is updated, the performance and stability of the terminal device are also improved.

[0074] However, the logic corresponding to the new functions of the operating system may conflict with other logic already existing in the terminal device.

[0075] In some examples, operating systems are divided into native operating systems and customized operating systems according to the degree of development. A native operating system generally refers to the original operating system developed by the manufacturer, while a customized operating system generally refers to an operating system that is optimized based on the original operating system. Therefore, the logic added to the customized operating system based on the unupdated native operating system may conflict with the logic in the updated native operating system, causing the customized operating system to fail to operate normally.

[0076] For example, there is no security protection logic in the unupdated native operating system, and when the mobile phone manufacturer optimizes the customized operating system, it adds security protection logic on the basis of the unupdated native operating system. Afterwards, the manufacturer who built the native operating system adds security protection logic to the native operating system, and the security protection logic added to the native operating system is different from the security protection logic in the customized operating system, or there is a conflict between the security protection logic added to the native operating system and the security protection logic in the customized operating system during execution, which will cause both security protection logics to fail to operate normally, affecting the normal use of the terminal device.

[0077] In some examples, the operating system can provide interfaces and services for the normal operation of the application software. Then, after the operating system is updated, there may be a problem that the logic of the updated operating system conflicts with the logic of the application software, causing the application software to fail to operate normally.

[0078] For example, when the application manager application is running, the operating system can provide an interface for the application manager application so that the application management application can obtain relevant information of other applications installed on the terminal device through the interface, so that the application manager application can manage other applications installed on the terminal device. In the case where the operating system updates the interface used by the application manager application, there may be a situation where the application manager application cannot obtain relevant information of other applications installed on the terminal device through the interface, which will cause the application manager application to fail to run normally.

[0079] In order to ensure that the terminal device can operate normally after the operating system is updated, the operation of the terminal device will be tested based on the test tool before the new version of the operating system is released. As a result, it is found that the power consumption of the terminal device has increased significantly.

[0080] To this end, the embodiment of the present application analyzes the power consumption of all processes running in the terminal device before the operating system is updated, and the power consumption of all processes running in the terminal device after the operating system is updated, and finds that in the updated operating system, the power consumption of processes related to the management application is higher. When further analyzing the logs related to the processes related to the management application, it is found that there is a problem that the frozen management application cannot be executed, and based on the specific content of the log, it is found that the problem of high power consumption of the terminal device is caused by the freezing conflict in the process of freezing the application by two freezing management logics at the same time. In this way, the embodiment of the present application proposes a freezing management method, which can determine whether other freezing management mechanisms are currently managing applications based on the freezing flag bit when there are multiple freezing management mechanisms in the terminal device, thereby avoiding the situation where multiple freezing management mechanisms manage one application at the same time, and realizing that the logics of multiple freezing management mechanisms can all run stably, thereby avoiding abnormalities in the freezing management process and reducing the power consumption of the terminal device.

[0081] The following introduces the hardware structure of the terminal device provided in the embodiment of the present application.

[0082] like Figure 2 As shown, Figure 2The structure diagram of the terminal device 100 is shown. The terminal device 100 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295.

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

[0084] The processor 210 may include one or more processing units, for example, the processor 210 may include an application processor (AP), a modem processor, a graphics processor (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. Different processing units may be independent devices or integrated into one or more processors.

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

[0086] The processor 210 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory may store instructions or data that the processor 210 has just used or cyclically used. If the processor 210 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

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

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

[0089] The charging management module 240 is used to receive charging input from the charger. The power management module 241 is used to connect the battery 242, the charging management module 240 and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240 to power the processor 210, the internal memory 221, the external memory, the display screen 294, the camera 293, and the wireless communication module 260.

[0090] The wireless communication function of the terminal device 100 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor and baseband processor.

[0091] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0092] The mobile communication module 250 may provide a solution for wireless communications including 2G / 3G / 4G / 5G etc. applied to the terminal device 100. The modem processor may include a modulator and a demodulator.

[0093] The wireless communication module 260 can provide wireless communication solutions for application in the terminal device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.

[0094] In some embodiments, the antenna 1 of the terminal device 100 is coupled to the mobile communication module 250, and the antenna 2 is coupled to the wireless communication module 260, so that the terminal device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology.

[0095] The terminal device 100 implements the display function through a GPU, a display screen 294, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs that execute program instructions to generate or change display information.

[0096] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel.

[0097] The terminal device 100 can realize the shooting function through the ISP, the camera 293, the video codec, the GPU, the display screen 294 and the application processor. The ISP is used to process the data fed back by the camera 293. The camera 293 is used to capture a static image or a video. In some embodiments, the terminal device 100 may include 1 or N cameras 293, where N is a positive integer greater than 1.

[0098] The external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100.

[0099] The internal memory 221 can be used to store computer executable program codes, which include instructions. The processor 210 executes various functional applications and data processing of the terminal device 100 by running the instructions stored in the internal memory 221. The internal memory 221 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the terminal device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 221 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0100] The terminal device 100 can implement audio functions such as music playing and recording through the audio module 270, the speaker 270A, the receiver 270B, the microphone 270C, the earphone interface 270D, and the application processor.

[0101] The sensor module 280 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc. The terminal device may collect various data through the sensor module 280.

[0102] The button 290 includes a power button, a volume button, etc. The button 290 can be a mechanical button. It can also be a touch button. The terminal device 100 can receive the button input and generate a key signal input related to the user settings and function control of the terminal device 100. The motor 291 can generate a vibration prompt. The motor 291 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 292 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 295 is used to connect the SIM card. The terminal device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.

[0103] The software system of the terminal device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the runtime and system library, and the kernel layer.

[0104] The application layer can include a series of application packages.

[0105] like Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, power saving wizard, etc.

[0106] The power saving wizard application is used to manage other applications running in the terminal device. In some examples, the power saving wizard can obtain the running status of other applications and determine that the applications that are not running are the applications that need to be frozen. Then, the power saving wizard can freeze the applications that need to be frozen through the Cgroup process group.

[0107] It should be noted that both the application and the binder process can be frozen. In some examples, the power saving wizard can detect whether there is a running binder process through the check_binder_calling_work function, and if it is detected that the binder process is not running, the binder process can be frozen.

[0108] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0109] like Figure 3As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a freeze manager, and the like.

[0110] The window manager is used to manage window programs. The content provider is used to store and obtain data and make it accessible to applications. The view system includes visual controls. The view system can be used to build applications. The display interface can be composed of one or more views. The resource manager provides various resources for applications. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction.

[0111] The freezing manager may be a freezing management module in the operating system. For example, when the freezing manager obtains that the status of the application is not running, the freezing manager may freeze the application.

[0112] Runtime includes core libraries and virtual machines. Runtime is responsible for the scheduling and management of the operating system.

[0113] The core library consists of two parts: one part is the function that the Java language needs to call, and the other part is the core library of the operating system.

[0114] The application layer and the application framework layer run in a 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 life cycle management, stack management, thread management, security and exception management, and garbage collection.

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

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

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

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

[0119] A 2D graphics engine is a drawing engine for 2D drawings.

[0120] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, sensor driver, refrigeration driver, etc.

[0121] The following is an illustrative introduction to the freezing management method provided in the embodiment of the present application in combination with the software architecture of the terminal device 100.

[0122] like Figure 3 As shown, the freezing manager can freeze the application through the freezing driver, and the power saving wizard can also freeze the application through the freezing driver. Among them, the freezing driver can provide a process group management interface for the freezing manager and the power saving wizard, so that the freezing manager and the power saving wizard can realize the freezing management of the application through the Cgroup process group. It should be noted that the Cgroup process group of the freezing manager and the Cgroup process group of the power saving wizard are independent of each other.

[0123] The Power Saver can be mounted using the CgroupV1 interface or CgroupV2 interface provided by the kernel. Taking the CgroupV1 interface as an example, the Power Saver can create a new process group in the mount point used for freezing management in the CgroupV1 interface according to the actual needs of the application to be managed. For example, if application A needs to be managed, a new process group is created. Figure 4 The Cgroup process group A shown in the figure. Then, the power saving wizard can set the process number of the Cgroup process group that needs to be controlled in the procs node of the Cgroup process group that needs to be controlled, and write FROZEN to freezer.state to achieve the purpose of freezing application A, or write THAWED to freezer.state to achieve the purpose of thawing application A.

[0124] Taking the freezing manager as the freezing management module in the operating system as an example, the freezing management module in the operating system can be mounted using the CgroupV2 interface provided by the kernel. Then, in the freezing management mount point in the freezing management module CgroupV2 interface in the operating system, a new process group can be created according to the actual needs of the application to be managed. For example, if application A needs to be managed, a new process group can be created. Figure 4The Cgroup process group B shown in . The freezing management module CgroupV2 interface in the operating system can perform hierarchical and classified management and control on each Cgroup process group therein. The specific management and control rules are not repeated here. Afterwards, the freezing management module in the operating system can set the process number of the Cgroup process group that needs to be controlled in the procs node in the Cgroup process group that needs to be controlled, and write FROZEN to freezer.state to achieve the purpose of freezing application A, or write THAWED to freezer.state to achieve the purpose of thawing application A.

[0125] Among them, after the power saving wizard or the freezing management module writes FROZEN to freezer.state, such as Figure 3 The freezing driver shown in will perform freezing operations on all processes in the corresponding Cgroup process group.

[0126] In some embodiments, the terminal device may obtain the running status of the application to determine whether the application needs to be frozen based on the running status of the application, that is, to determine whether the application is a target application.

[0127] In some examples, the terminal device may obtain the running status of the application program at a certain period, and when the application program is not running, the terminal device may use the application program as the target application program. Figure 4 As shown, the power saving wizard in the terminal device detects that the user has not operated the video playback application A for a long time, and the total processor (CPU) occupancy rate of all cores of all processes related to the video playback application A is 2%, and the memory occupancy rate is 3 megabytes (MB) (i.e. Figure 4 In the process ①), at this time, the terminal device can determine that the video playback application A needs to be frozen to reduce the computing resources and power consumption occupied by the terminal device running the video playback application A. For another example, the freezing management module of the native operating system in the terminal device can be Figure 4 In process ②, the running status of the video playback application A is obtained, and the application A can also be determined as the target application.

[0128] In some embodiments, the processes included in the Cgroup process group correspond to the application programs that need to be managed. Figure 4 If the Power Saver can freeze application A, then its corresponding Cgroup process group A only includes processes corresponding to application A. If the Power Saver can also freeze application A and application B, then its corresponding Cgroup process group can include processes corresponding to application A and processes corresponding to application B.

[0129] It should be noted that the two different Cgroup process groups included in the Power Saving Wizard may include processes of the same application. For example, the Cgroup process group A corresponding to the Power Saving Wizard only includes processes corresponding to application A, while the Cgroup process group C corresponding to the Power Saving Wizard may include processes corresponding to application A and processes corresponding to application B.

[0130] In some embodiments, when it is determined that a freezing application is required, the present application embodiment provides a freezing management method, such as Figure 5 As shown, freezing of the target application can be achieved through the following steps (step S501-step S502):

[0131] Step S501: Send a freezing instruction for freezing a target application to the kernel through a process group management interface.

[0132] The Power Saver and the freezing management module of the native operating system write the status of the corresponding Cgroup process group through their respective corresponding process group management interfaces, thereby implementing the process of sending management instructions to the kernel. For example, when the Power Saver freezes application A, the Power Saver can write the status of Cgroup process group A, which includes all processes corresponding to application A, as FROZEN through the process group management interface. Then, the kernel can freeze all processes in Cgroup process group A, that is, all processes corresponding to application A in the kernel are in a frozen state.

[0133] Among them, although all processes corresponding to application A in the kernel are in a frozen state, the state of Cgroup process group B of the freezing management module of the native operating system will not change with the state of the process in the kernel. Therefore, the state of Cgroup process group B is still THAWED.

[0134] Step S502: The kernel obtains the freeze flag of the target application.

[0135] The freeze flag is used to indicate the frozen state of the target application. In some examples, if the freeze flag of the video player application is 0, it means that the video player application is in the unfrozen state, and if the freeze flag of the video player application is 1, it means that the video player application is in the frozen state.

[0136] In some embodiments, the frozen flag is stored in the kernel. In some embodiments, the presence of the frozen flag is related to whether the process exists. For example, if the process exists in the terminal device, there will be a corresponding frozen flag. If the process

[0137] It should be noted that both the frozen flag and the status of the Cgroup process group can indicate the frozen status of the application-related process, but the frozen flag is a global variable in the operating system, and the status of the Cgroup process group is a local variable. Figure 4 As shown in the figure, in the terminal system, the power saving wizard manages the processes related to application A through Cgroup process group A, which includes n processes, and the freezing management module of the native operating system manages the processes related to application A through Cgroup process group B, which includes m processes. Then, when the state of Cgroup process group B corresponding to the freezing management module of the native operating system is FROZEN, it can only be explained that the freezing management module of the native operating system has recently issued an instruction to the kernel to freeze the processes related to application A. In fact, the power saving wizard may have issued a freezing instruction to the kernel afterwards, so that the freezing state of each process corresponding to application A in the current kernel corresponds to the freezing instruction received by the kernel, but not to the FROZEN state of Cgroup process group B.

[0138] For example, the Power Saver and the freezing management module of the native operating system write the status of the Cgroup process group through their respective corresponding process group management interfaces to implement the freezing management process of the application A corresponding to the Cgroup process group. For example, when the Power Saver freezes application A, the Power Saver can write the status of the Cgroup process group A as FROZEN through the process group management interface. The freezing management module of the native operating system will not manage the Cgroup process group B through the process group management interface. At this time, the freezing flag of application A becomes 1, and the status of the Cgroup process group A corresponding to the Power Saver changes from THAWED to FROZEN, while the status of the Cgroup process group B corresponding to the freezing management module of the native operating system remains THAWED.

[0139] It can be understood that the power saving wizard or the freezing management module of the native operating system can correspond to multiple Cgroup process groups.

[0140] Based on the above description, after the kernel receives the freezing flag, it can implement freezing processing on the target application based on the freezing flag, that is, execute the following step S503:

[0141] Step S503: The kernel freezes the target application based on the freeze flag and the freeze instruction.

[0142] In some embodiments, if the freeze instruction is used to freeze application A, and the freeze flag bits of all processes corresponding to application A are 1, indicating that application A is already in a frozen state, then the kernel does not need to freeze all processes corresponding to application A. If the freeze instruction is used to freeze application A and application B, and the freeze flag bits of all processes corresponding to application A are 1, and the freeze flag bits of all processes corresponding to application B are 0, indicating that application A is already in a frozen state, and application B is in a thawed state, then the kernel does not need to freeze all processes corresponding to application A, and only freezes all processes corresponding to application B.

[0143] In some embodiments, Figure 4 In process ③ or process ④, the freezing driver of the kernel layer of the terminal device can obtain the freezing flag of the target application. After that, the freezing driver can determine whether to perform the freezing operation on the process of the target application according to the freezing flag.

[0144] In some examples, if the freezing flag of the process corresponding to the target application indicates that the process corresponding to the target application is in a frozen state, then after the power saving wizard or the freezing management module of the native operating system sends a management instruction for indicating freezing to the kernel, the kernel will not perform a freezing operation on the process corresponding to the target application. If the freezing flag of the target application indicates that the target application is in a non-frozen state, then after the power saving wizard or the freezing management module of the native operating system sends a management instruction for indicating freezing to the kernel, the kernel will perform a freezing operation on the process corresponding to the target application.

[0145] In addition to freezing application A, the power saving wizard and the freezing management module of the native operating system can also freeze the binder process. The binder process is used to realize the communication between two applications or two processes. By freezing the binder process, the communication between two applications or two processes can be stopped. In the description of the subsequent steps, the freezing object of the terminal device is taken as the binder process / application A as an example.

[0146] In some embodiments, the power saving wizard can perform the following operations during the process of freezing the binder process / application A: Figure 6 The process shown achieves thawing:

[0147] Step S601: Detect whether there is a todo queue.

[0148] In some embodiments, the power saving wizard can detect whether there is a corresponding todo queue for the binder process / application A. When the binder process / application A is in a frozen state, in order to store the call information when application B calls the binder process / application A, the terminal device will correspondingly establish a todo queue for the binder process / application A. Therefore, the power saving wizard in the terminal device can determine whether the binder process / application A is in a frozen state by detecting whether there is a todo queue.

[0149] In some examples, the power saving wizard may periodically execute step S601 according to a predetermined cycle.

[0150] Optionally, if there is no corresponding todo queue in the binder process / application A, the power saving wizard can end the todo queue detection.

[0151] If the binder process / application A has a corresponding todo queue, it indicates whether the binder process / application A is in a frozen state. The power saving wizard can continue to perform the following step S602:

[0152] Step S602: Determine whether the todo queue is empty.

[0153] Based on the above embodiments, it can be known that the todo queue is used to store call information, that is, when there are other applications calling application A, the call information can be stored in the todo queue corresponding to application A. If there are no other applications calling application A, the todo queue should be empty. Therefore, when the todo queue corresponding to the binder process / application A is empty, it means that there are currently no other applications calling the binder process / application A, and the power saving wizard does not need to unfreeze application A. When the todo queue corresponding to the binder process / application A is not empty, it means that there are currently other applications calling the binder process / application A, and the power saving wizard needs to unfreeze application A to ensure that the terminal device can operate normally.

[0154] Optionally, when the todo queue is empty, it means that other applications have not called the binder process / application A, and the power saving wizard can end the todo queue detection.

[0155] In some embodiments, when the todo queue is not empty, it means that other applications have called the binder process / application A, and the following step S603 may be performed:

[0156] Step S603: Write the status of the corresponding process group as THAWED.

[0157] Based on the above embodiment, it can be known that the power saving wizard implements freezing management of application A by writing the status of the process group to the process group management interface. For details, please refer to the above embodiment and will not be repeated here.

[0158] After the electric elf writes the state of the corresponding process group as THAWED to the process group management interface, the kernel can perform a thawing operation on each process in the process group based on the write action. In order to avoid the kernel performing a thawing operation on a process that is already in a thawing state, resulting in the thawing operation being unable to be implemented and the kernel repeatedly thawing, the embodiment of the present application can first determine the frozen state of the process through step S604:

[0159] Step S604: Determine whether the freeze flag of the process in the process group is 1.

[0160] In some embodiments, when the freeze flag of the binder process / application A is 1, it indicates that the process corresponding to the binder process / application A is in a frozen state, indicating that the kernel can execute step S605 on the process corresponding to the binder process / application A:

[0161] Step S605: The kernel performs a thawing operation on the process.

[0162] It can be understood that after the kernel performs the thawing operation on the process, the freeze flag corresponding to the process becomes 0, indicating that the process is in a thawing state.

[0163] Optionally, when the freeze flag of the binder process / application A is 0, it indicates that the process corresponding to the binder process / application A is in a thawed state, and the kernel may not perform a thaw operation on the process corresponding to the binder process / application A.

[0164] In some examples, since the Cgroup process group A used by the power saving wizard to manage the binder process / application A is independent of the Cgroup process group B used by the freezing management module of the native operating system, if the power saving wizard manages the binder process / application A and writes the status of the Cgroup process group A as THAWED through the process group management interface, and the process corresponding to the binder process / application A in the actual kernel is already in the thawed state, the kernel cannot perform the thawing operation on the process that is already in the thawed state. At this time, the power saving wizard can stop the subsequent freezing operation on the binder process / application A.

[0165] The above Figure 6The process shown can be applied to the process of unfreezing the binder process / application A by the power saving wizard when the freezing management module of the native operating system freezes the binder process / application A (recorded as scenario 1). In this process, when the power saving wizard determines that the binder process / application A needs to be unfrozen, it can determine whether other freezing mechanisms have frozen the binder process / application A through the freezing flag bit, so that it can avoid two freezing mechanisms simultaneously freezing the same binder process / application A, and solve the problem of freezing abnormality.

[0166] In addition, the above Figure 6 The process shown can be applied to the case where the power saving wizard freezes the binder process / application A, and the freezing management module of the native operating system unfreezes the binder process / application A (recorded as scenario 2).

[0167] The following mainly takes scenario 1 as an example to illustrate the freezing management process.

[0168] like Figure 7 As shown in FIG. 1 , when the binder process / application A has entered the frozen state, the freeze flag of the binder process / application A is 1 indicating the frozen state. Figure 7 As shown in FIG. 1 , when the binder process / application A in the frozen state is called by application B, the call information corresponding to the call action is stored in the todo queue corresponding to the binder process / application A. Figure 7 As shown, the freezing management method includes the following process (step S701-step S703):

[0169] Step S701: The power saving wizard obtains the todo queue corresponding to the binder process / application A.

[0170] Step S702: In response to the existence of a corresponding todo queue for the binder process / application A and the todo queue is not empty, the power saving wizard writes a thawing instruction corresponding to the binder process / application A to the kernel through the process group management interface.

[0171] If there is a todo queue corresponding to binder process / application A and the todo queue is not empty, the power saving wizard believes that the binder process / application A has been frozen and there is a call, then the power saving wizard may consider that the binder process / application A needs to be unfrozen. Therefore, the unfreeze instruction corresponding to the binder process / application A can be written to the kernel through the process group management interface.

[0172] However, if the freezing management module of the native operating system can also freeze the binder process / application A, if the power saving wizard directly tries to unfreeze the binder process / application A, the following will appear: Figure 8 The situation shown.

[0173] like Figure 8 As shown, after the freezing management module of the native operating system freezes application A, application A enters the frozen state. If there is a call to application A in the frozen state, the call information of the call action will be stored in the todo queue. Since the power-saving wizard regularly detects the binder process and the todo queue of application A, the power-saving wizard will find that the todo queue of the binder process and application A is not empty. At this time, the power-saving wizard will think that the binder process and application A are in the frozen state and have been called. Then, the power-saving wizard will try to unfreeze the binder process and application A. Since the freezing management module of the native operating system freezes application A, when the power-saving wizard tries to unfreeze the binder process and application A, the power-saving wizard writes the unfreezing instructions corresponding to the binder process and application A to the kernel through the process group management interface. The kernel finds that the binder process is in the unfrozen state, and the process corresponding to application A is in the frozen state. Then, the kernel will actually perform the unfreezing operation on application A successfully, while the unfreezing operation on the binder process will fail. Then, the kernel will perform the unfreezing operation on the binder process multiple times. For example, if the first module of the kernel fails to unfreeze the binder process, it will report 0binder call (unfreeze request) to the second module of the kernel multiple times. However, after receiving the 0binder call, the second module of the kernel finds that the binder process / application A in the Cgroup process group A is in the unfreeze state, and cannot perform the unfreeze operation on the binder process, and cannot give feedback to the first module of the kernel. This will result in higher power consumption.

[0174] In addition, since the binder process is not actually unfrozen, the call information in the binder process's todo queue is not processed. In this way, the power saving wizard will find that the binder process's todo queue is not empty in the next cycle of detection, and repeat the above process of trying to unfreeze but failing. In this way, the first module of the kernel will repeatedly report 0binder calls to the second module in the subsequent process, resulting in higher power consumption of the kernel.

[0175] Direct thawing will result in Figure 8In the situation shown, the kernel can query the freeze flag of the binder process / application A through step S703, so that the kernel can determine whether the binder process / application A needs to be unfrozen based on the actual state of the binder process / application A.

[0176] Step S703: The kernel queries the freeze flag of the process corresponding to the binder process / application A.

[0177] Step S704: In response to the freeze flag of the process being 0, the kernel does not perform a thawing operation on the process.

[0178] If the process whose freeze flag is 0 is already in the thawed state, the kernel may no longer perform the thaw operation on the process, thereby avoiding repeated execution of actions caused by the kernel being unable to perform the thaw operation on the process in the thawed state.

[0179] If the todo queue of binder process / application A is not empty, the power saving wizard believes that binder process / application A is in a frozen state, and binder process / application A is called by application B. Then, according to the logic of the power saving wizard, the power saving wizard can unfreeze the binder process / application A. Before unfreezing, the power saving wizard checks that the status flag of binder process / application A is 1, and it can be determined that the binder process / application A is frozen by other freezing management programs. Therefore, the kernel can avoid repeatedly performing unfreezing operations on processes in the unfrozen state.

[0180] In some examples, the freeze flag (proc->is_frozen) corresponding to the binder process / application A can also be represented by true or false to indicate a specific value. For example, if the binder process proc->is_frozen is true, it means that the binder process is in a frozen state. At this time, the power saving wizard may no longer manage the freezing or thawing of the binder process.

[0181] The above describes how to unfreeze a terminal device when an application has been frozen. The following describes how to avoid repeated freezing of a terminal device when an application has been frozen.

[0182] In some embodiments, the freezing management module of the native operating system can perform the following operations during the freezing management of the binder process / application A: Fig. 9 The process shown achieves freezing:

[0183] Step S901: Based on the running status of application A, determine that application A is an application that needs to be frozen.

[0184] In some embodiments, the freezing management module of the native operating system detects that the binder process / application A has not been operated by the user for a long time, and all processes related to the binder process / application A occupy system resources. Then, application A can be regarded as an application that needs to be frozen.

[0185] In some examples, the freezing management module of the native operating system may periodically execute step S901 according to a predetermined period.

[0186] After the freezing management module of the native operating system determines that application A is an application that needs to be frozen, the freezing management module of the native operating system may continue to perform the following step S902:

[0187] Step S902: Write the state of the corresponding process group as FROZEN.

[0188] Based on the above embodiments, it can be known that the freezing management module of the native operating system implements freezing management of the application by writing the status of the process group to the process group management interface. For details, please refer to the above embodiments, which will not be repeated here.

[0189] After the freezing management module of the native operating system writes the state of the corresponding process group to FROZEN through the process group management interface, the kernel can perform a freezing operation on each process group based on the write action.

[0190] The kernel cannot perform a freeze operation on a process that is in a frozen state, such as Fig.10 As shown, after the power saving wizard freezes the binder process, the binder process enters the frozen state. Then, when the freezing management module of the native operating system detects that the binder process and application A are not running, it will be considered that the binder process / application A needs to be frozen. Since the binder process is actually already in the frozen state, and the freezing management module of the native operating system does not know that the binder process is already in the frozen state at this time, the freezing management module of the native operating system will continue to write the process group including the binder process and the process corresponding to application A as FROZEN through the process group management interface. Since the binder process has actually been frozen by the power saving wizard, the kernel cannot perform the freezing operation on the binder process in the frozen state, nor can it obtain the success message of the binder process in response to the freezing operation. That is to say, after sending the freezing instruction, the kernel executes the freezing response countdown. After the freezing response countdown ends, the kernel will consider that the freezing has failed.

[0191] In the case of freezing failure, the kernel will think that the binder process is communicating. Since the communication of the binder process can be completed within tens of milliseconds, the kernel will send the freezing command again after 1 second. If the number of freezing failures is less than P, the kernel will think that the binder process has communicated multiple times. If the number of freezing failures is greater than or equal to P, the kernel will think that the binder process has abnormal communication. At this point, the kernel can send a kill command to the binder process. At this point, the binder process will be killed. It can be seen that the binder process that should have been frozen was mistakenly killed due to the conflict between the power saving wizard and the freezing management module of the native operating system, which caused the terminal device to fail to operate normally.

[0192] Among them, Fig.10 As shown in the figure, if there is a dependency between the binder process and application C, and application C is in the running state, then application C will pull up the binder process again after the binder process is killed, so that the binder process is restarted. However, the restarted binder process may be frozen by the power saving wizard again because it does not actually run any action. In this way, the terminal device will have abnormal power consumption during operation.

[0193] It is understandable that the restarted binder process kernel may also be frozen by the freezing management module of the native operating system first. At this time, the terminal device can operate normally.

[0194] In order to prevent the kernel from performing a freezing operation on a process that is already in a frozen state, which results in the freezing operation being unable to be implemented, and the kernel being unable to perform a freezing operation on a process that is already in a frozen state, the embodiment of the present application can first determine the freezing state of the process through step S903:

[0195] Step S903: Determine whether the freeze flag of the process in the process group is 1.

[0196] In some embodiments, when the freeze flag of application A is not 1, it indicates that the process corresponding to application A is in a thawed state, indicating that the kernel can execute step S904 on the binder process / process corresponding to application A:

[0197] Step S904: the kernel performs a freezing operation on the process.

[0198] It can be understood that after the kernel performs the thawing operation on the process, the freeze flag corresponding to the process becomes 0, indicating that the process is in a thawing state.

[0199] Optionally, when the freezing flag of application A is 1, it indicates that the process corresponding to application A is in a frozen state, and the kernel may not perform a thawing operation on the process corresponding to application A.

[0200] In some examples, since the Cgroup process group A used by the power saving wizard to manage the binder process / application A and the Cgroup process group B used by the freezing management module of the native operating system are independent of each other, if the freezing management module of the native operating system manages the binder process / application A and writes the state of the Cgroup process group B as FROZEN through the process group management interface, and the process corresponding to the binder process / application A in the actual kernel is already in a frozen state, the kernel cannot perform the freezing operation on the process that is already in a frozen state. At this time, the kernel can stop performing the freezing operation on the process that is already in a frozen state.

[0201] Due to the above Fig.10 Direct freezing may cause abnormal conditions. Fig.11 As shown, when the binder process / application A enters the frozen state, the freezing flag of the binder process / application A changes to 1, indicating the frozen state. At this time, the freezing management module of the native operating system determines that the binder process / application A needs to be frozen based on the running state of the binder process / application A, and can execute the following freezing management method process (step S1101-step S1102):

[0202] Step S1101: write a freeze instruction to the kernel through the process group management interface.

[0203] The specific operation of the freezing management module of the native operating system writing the freezing instruction to the kernel through the process group management interface can be found in the above embodiment and will not be described in detail here.

[0204] Step S1102: The kernel queries the freeze flag of the binder process / application A.

[0205] In some examples, the kernel can use the stub function to detect the frozen state of the binder process / application A.

[0206] Step S1103: In response to the freezing flag of the process being 1, the kernel does not perform the freezing operation on the process.

[0207] When the freeze flag of the binder process / application A is 1, it can be determined that the binder process / application A is frozen by other freezing management programs (such as the freezing wizard in the above embodiment), so the freezing management module of the native operating system can stop freezing management of the binder process / application A. In this way, the freezing management module of the native operating system in the terminal device can avoid repeatedly performing freezing management when the binder process / application A is frozen by other freezing mechanisms.

[0208] In some embodiments, after the terminal device system is updated, the terminal device frequently becomes hot and consumes power at a high rate. After excluding possible hardware failures, the power consumption test results of the software running in the terminal device show that the power consumption of the iaware process and the processes related to the binder mechanism have a high growth rate.

[0209] Keeping other conditions unchanged, the power consumption of software in terminal devices with different versions of operating systems is tested. The power consumption of processes with higher power consumption growth is shown in the following table:

[0210]

[0211] The above table shows the power consumption test results of five different terminal devices. The operating system version installed in mobile phone 1, mobile phone 2, and mobile phone 3 is V1 (i.e., the operating system before the update). The operating system version installed in mobile phone 4 and mobile phone 5 is V2 (i.e., the operating system after the update). It can be seen that in terminal devices with the same operating system installed, the power consumption values ​​of each process are similar. In terminal devices with different operating systems installed, the power consumption values ​​of each process vary greatly.

[0212] The iaware process is used to manage applications, and the binder process is responsible for the communication between the two processes.

[0213] First, after decomposing the iaware process into multiple threads, we found that the power consumption of the actions handler thread was high. The power consumption of the actions handler thread is related to the control of freezing and thawing of the application. So, when further analyzing the logs related to the actions handler thread, we found that the actions handler thread has been repeatedly executing the reporting operation of 0binder call. Therefore, we further analyzed the following Figure 8 For details, please refer to the above Figure 8 The relevant embodiments will not be described in detail here.

[0214] Secondly, after analyzing the logs corresponding to the binder process, it was found that the freezing management module of the native operating system had multiple freezing operations on the binder process, and each freezing operation resulted in a timeout. In addition, when the number of timeouts is greater than or equal to P, the freezing management module of the native operating system will kill the binder process. Furthermore, when application C restarts the binder process, the freezing management module of the native operating system will repeat the above multiple freezing and killing processes. Based on the above process, we can further analyze the following: Fig. 9 For details, please refer to the above Fig. 9 The relevant embodiments will not be described in detail here.

[0215] In view of this, the freezing management method provided in the embodiment of the present application can query the freezing flag corresponding to the application before performing the operation of thawing or freezing management on the application to determine whether the current application is in a state of being managed by other freezing management mechanisms. If other freezing management mechanisms have frozen the application, the application will no longer be treated as an object of freezing management. In this way, abnormal situations caused by conflicts between multiple freezing management mechanisms can be avoided, and the problem of high power consumption can be avoided, ensuring the normal operation of the terminal device.

[0216] Combination of the above Figure 1-Figure 11 The freezing management method provided in the embodiment of the present application is described in detail. Fig.12 The terminal device provided in the embodiment of the present application is described in detail.

[0217] In one possible design, Fig.12 This is a schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Fig.12 As shown, the terminal device 1200 may include: a display unit 1201, a processing unit 1202, and a transceiver unit 1203. The terminal device 1200 may be used to implement the functions of the terminal device involved in the above method embodiment.

[0218] Optionally, the display unit 1201 is used to support the terminal device 1200 to display interface content; and / or to support the terminal device 1200 to execute Figure 5 , Figure 6 , Figure 7 , Fig. 9 or Fig.11 The method in .

[0219] Optionally, the processing unit 1202 is used to support the terminal device 1200 to execute Figure 5 , Figure 6 , Figure 7 , Fig. 9 or Fig.11 The method in .

[0220] Optionally, the transceiver unit 1203 is used to support the terminal device 1200 to execute Figure 5 , Figure 6 , Figure 7 , Fig. 9 or Fig.11 The method in .

[0221] The transceiver unit may include a receiving unit and a sending unit, and may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. The operations and / or functions of each unit in the terminal device 1200 are respectively to implement the corresponding process of the freezing management method described in the above method embodiment. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional unit, and for the sake of brevity, they will not be repeated here.

[0222] Optionally, Fig.12 The terminal device 1200 shown may also include a storage unit ( Fig.12 (not shown), the storage unit stores a program or instruction. When the processing unit 1202 and the transceiver unit 1203 execute the program or instruction, Fig.12 The terminal device 1200 shown can execute the freezing management method described in the above method embodiment.

[0223] Fig.12 The technical effects of the terminal device 1200 shown can refer to the technical effects of the freezing management method described in the above method embodiment, and will not be repeated here.

[0224] In addition to being in the form of the terminal device 1200, the technical solution provided in the embodiment of the present application may also be a functional unit or chip in the terminal device, or a device used in conjunction with the terminal device.

[0225] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned terminal device, the terminal device executes each function or step in the above-mentioned method embodiment.

[0226] The embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed on a terminal device, the terminal device executes each function or step in the above method embodiment.

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

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

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

[0230] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

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

[0232] The above contents are only specific implementation methods 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 shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A freezing management method, characterized in that: Applied to a terminal device, the terminal device includes a first process, and the method includes: When a first queue corresponding to the first process is included in the terminal device and the first queue is not empty, querying a freezing flag of the first process, wherein the first queue is used to record a situation in which the first process is called after the first process is frozen; In response to querying the first flag bit corresponding to the first process, the first process is unfrozen and the frozen flag bit of the first process is updated to the second flag bit; wherein, in response to querying the second flag bit corresponding to the first process, the frozen flag bit of the first process is not unfrozen and is not updated; the first flag bit indicates that the first process is in a frozen state, and the second flag bit indicates that the first process is in a unfrozen state.

2. The method according to claim 1, characterized in that Before querying the freezing flag of the first process, the method further includes: Writing a first status value to a first process group, the first process group including the first process, the first status value indicating that the first process group is in a thawed state; The querying of the freezing flag of the first process includes: Query the freeze flag of each process in the first process group.

3. The method according to claim 2, characterized in that The first process group also includes a second process in the terminal device; After querying the freeze flag of each process in the first process group, the method further includes: In response to querying the first flag bit corresponding to the second process, the second process is unfrozen and the frozen flag bit of the second process is updated to the second flag bit; wherein, in response to querying the second flag bit corresponding to the second process, the frozen flag bit of the second process is not unfrozen and not updated.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Freezing the first process, and updating a freezing flag of the first process to the first flag; generating the first queue; After the first process is called, the calling of the first process is recorded in the first queue.

5. The method according to claim 4, characterized in that The method further comprises: Periodically query whether the terminal device includes the first queue and whether the first queue is empty.

6. The method according to any one of claims 1 to 3, characterized in that The method further comprises: When the first process is not running, querying a freezing flag of the first process; In response to querying the second flag bit corresponding to the first process, the first process is frozen, and the frozen flag bit of the first process is updated to the first flag bit; wherein, in response to querying the first flag bit corresponding to the first process, the frozen flag bit of the first process is not frozen and is not updated.

7. The method according to claim 6, characterized in that The method further comprises: The running state of the first process is queried periodically, where the running state includes the not-running state and the running state.

8. The method according to claim 5, characterized in that The terminal device includes a first freezing management module, a second freezing management module and a freezing drive; When the first process is not running, querying a freeze flag of the first process includes: When the first freezing management module or the second freezing management module inquires that the first process is not running, the first freezing management module or the second freezing management module sends a first instruction to the freezing driver; In response to the first instruction, the freezing driver queries a freezing flag of the first process; In response to querying the second flag bit corresponding to the first process, freezing the first process and updating the frozen flag bit of the first process to the first flag bit, includes: In response to finding the second flag bit corresponding to the first process, the freezing driver freezes the first process and updates the freezing flag bit of the first process to the first flag bit.

9. The method according to claim 8, characterized in that The terminal device includes a first freezing management module and a freezing driver; When a first queue corresponding to the first process is included in the terminal device and the first queue is not empty, querying a freezing flag of the first process includes: When the first freezing management module inquires that the terminal device includes a first queue corresponding to the first process and the first queue is not empty, the first freezing management module and / or the second freezing management module sends a first instruction to the freezing driver; In response to the first instruction, the freezing driver queries a freezing flag of the first process; In response to querying the first flag bit corresponding to the first process, unfreezing the first process and updating the frozen flag bit of the first process to the second flag bit include: In response to querying the first flag, the freezing driver unfreezes the first process and updates the freezing flag of the first process to a second flag.

10. A terminal device, characterized in that: The terminal device includes a memory and one or more processors; 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 terminal device executes the method as described in any one of claims 1 to 9.

11. A computer-readable storage medium, characterized in that: The method comprises computer instructions, and when the computer instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 9.