Process management method and electronic device

By controlling the creation and destruction of processes in advance before checking the application's liveness status, number of processes, and process type in electronic devices, the problem of excessive processes consuming system resources is solved, ensuring the normal operation of the device.

CN122285247APending Publication Date: 2026-06-26HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-12-25
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In electronic devices, creating too many processes can lead to excessive consumption of system resources and affect the normal operation of the device.

Method used

By checking whether certain conditions are met before creating a process, including whether the application is alive, whether the current number of processes is within the limit, and whether the process is a preset process, the creation and destruction of processes can be controlled to avoid excessive consumption of system resources.

Benefits of technology

Effectively manage the number of processes to avoid excessive consumption of system resources and ensure normal equipment operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122285247A_ABST
    Figure CN122285247A_ABST
Patent Text Reader

Abstract

A process management method and electronic device are disclosed for managing processes within the electronic device to prevent excessive process creation and thus avoid excessive consumption of system resources. For example, before creating a first process for a first application, the electronic device determines whether a first condition is met. The first condition includes: the first application is alive; the total number of currently running processes of the first application is less than the maximum number of processes for the first application; and the first process is at least one of a preset set of processes. The first application being alive includes the main process of the first application being in a normal running state. If the first condition is met, the electronic device creates the first process; if the first condition is not met, the creation of the first process is prohibited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and in particular to a process management method and electronic device. Background Technology

[0002] Currently, electronic devices support multi-process operation, meaning multiple processes can run concurrently, thereby improving operating speed. However, in practical applications, each additional process consumes additional system resources (such as memory and CPU). Creating too many processes can excessively consume system resources, and in severe cases, affect the normal operation of the device. Therefore, how to manage processes is a problem that needs to be solved. Summary of the Invention

[0003] This application provides a process management method and an electronic device for managing processes in the electronic device, avoiding the creation of too many processes, thereby preventing excessive consumption of system resources.

[0004] Firstly, a process management method is provided, applied to electronic devices. For example, the electronic device can be a mobile phone. In this method, before creating the first process corresponding to a first application, the electronic device determines whether a first condition is met. The first condition includes: the first application is alive; the total number of currently running processes of the first application is less than the maximum number of processes for the first application; and the first process is at least one of the preset processes. The first application being alive includes the main process of the first application being in normal operation. If the electronic device meets the first condition, the first process is created; if the electronic device does not meet the first condition, the creation of the first process is prohibited.

[0005] Therefore, embodiments of this application provide a process management method that can manage the processes of applications in an electronic device. Taking a first application in the electronic device as an example, if a first process of the first application is to be created, it can only be created if a first condition is met; otherwise, creation is prohibited. This process management method can avoid creating too many processes, leading to an excessive number of processes and excessive consumption of system resources.

[0006] In one possible design, the first condition includes the first application being alive. Determining whether the first condition is met includes: determining whether the first application is alive based on the application liveness flag in the process manager of the first application, where the process manager manages the processes of the first application. Therefore, in this embodiment, each application can correspond to a process manager for managing the processes of the corresponding application, and each application's process manager includes the application liveness flag to indicate whether the corresponding application is alive. Taking the first application as an example, the process manager of the first application includes the application liveness flag to indicate whether the first application is alive. In this way, the electronic device can determine whether the first application is alive based on the application liveness flag in the process manager of the first application. If it is alive, the process of the first application can be created; otherwise, the creation of the process of the first application is prohibited. In this way, it can be ensured that the process of the application is created when the application is alive, and the creation of the process of the application is prohibited when the application is not alive, avoiding excessive process creation by applications and excessive consumption of system resources.

[0007] In one possible design, the application liveness flag is located in the first field of the process manager. For example, the first field can be the first field, middle field, or last field of the process manager, etc., without limitation. In short, the process manager of the first application includes an application liveness flag to indicate whether the first application is alive. This application liveness flag determines whether the first application is alive; if it is, its process can be created; otherwise, process creation is prohibited, thus preventing the application from creating too many processes and causing excessive consumption of system resources.

[0008] In one possible design, if the startup of the first application is detected, its application liveness flag is configured as a first flag, indicating that the first application is alive. If the exit of the first application is detected, its application liveness flag is configured as a second flag, indicating that the first application is not alive. Therefore, by using the application liveness flag, it is possible to determine whether the first application is alive. If it is alive, its process can be created; otherwise, the creation of its process is prohibited, thus avoiding excessive process creation and excessive consumption of system resources.

[0009] In one possible design, the first condition includes the total number of currently running processes of the first application being less than the maximum number of processes for the first application. Before determining whether the electronic device meets the first condition, the electronic device reads the maximum number of processes for the first application from the process manager of the first application. The process manager is used to manage the processes of the first application. Therefore, in this embodiment, the process manager of the first application includes the maximum number of processes for the first application. The electronic device can read the maximum number of processes for the first application from the process manager of the first application, and then determine whether the total number of currently running processes of the first application is less than the maximum number of processes. If so, processes for the first application can be created; otherwise, the creation of processes for the first application is prohibited. In this way, it is possible to avoid an excessive number of running processes of the application, which would lead to excessive consumption of system resources.

[0010] In one possible design, before reading the maximum number of processes for the first application from its process manager, the electronic device responds to the application's launch command, obtains the maximum number of processes for the first application, and adds it to the application's process manager. Therefore, in this embodiment, when the first application starts, the maximum number of processes for the first application is added to its process manager. This allows for the control of the number of processes for the first application through the maximum number of processes in the process manager, preventing the first application from creating too many processes and causing excessive consumption of system resources.

[0011] In one possible design, the maximum number of processes for the first application is located in the second field of the process manager. For example, the second resource can be the first, middle, or last field of the process manager, without limitation. Optionally, the second field can be the same as or different from the first field mentioned above. In summary, the process manager of the first application includes the maximum number of processes for the first application to limit the total number of processes of the first application, thereby preventing the first application from creating too many processes and causing excessive consumption of system resources.

[0012] In one possible design, the maximum number of processes for the first application satisfies one or more of the following: the maximum number of processes for the first application is pre-configured by the first application; or, the maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, the maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, the maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device. Therefore, in the embodiments of this application, the maximum number of processes for the first application can be determined in multiple ways, for example, it can be related to the operating load of the electronic device, the remaining battery power, etc., so that the maximum number of processes for the first application can change flexibly according to the operating load and the remaining battery power.

[0013] In one possible design, different applications on an electronic device have different maximum process limits. For example, application A might have a maximum process limit of A, while application B might have a maximum process limit of B, with A and B being different. This allows for different management of different applications, improving flexibility. Optionally, the maximum process limit for each application can be configured by the application developer, or it can be configured by the operating system. For example, the electronic device can configure a maximum process limit for each application based on its application type.

[0014] In one possible design, the first condition includes that the first process is a preset process. Determining whether the first condition is met includes: determining whether the first process is a preset process based on its structure, which includes descriptive information about the first process. For example, the structure of the first process could be a function expression of the first process. Therefore, the electronic device can identify whether the first process is a preset process through its structure. If so, the first process can be created without being subject to a process limit. In this way, it avoids the inability to create preset processes due to reaching the process limit, thus preventing the application from being affected.

[0015] In one possible design, determining whether a first process is a preset process based on its structure includes: if the structure of the first process contains a third marker, determining that the first process is a preset process; if the structure of the first process does not contain a third marker, determining that the first process is not a preset process, wherein the third marker is a marker used to indicate a preset process. Therefore, in this embodiment, the electronic device can identify whether the first process is a preset process through its structure. If so, the first process can be created without being subject to a process limit. This avoids the application's operation being affected by the inability to create preset processes due to reaching the process limit.

[0016] In one possible design, the first process is a preset process, including one or more of the following: the first process is a child process corresponding to the main process of the first application; or, the first process is a process used to log exceptions; or, the first process is a system service process. Therefore, in the embodiments of this application, preset processes such as child processes of the main process of the first application, processes used to log exceptions, and system service processes can be created directly without being subject to the upper limit on the number of processes, avoiding the inability to create preset processes due to the upper limit on the number of processes, which would affect the normal operation of the application.

[0017] In one possible design, the first process is a preset process, including: the first process is a dfx process, which is used to record exception information. Therefore, in this embodiment, if the first application needs to create a dfx process, it can create it directly without being subject to the upper limit on the number of processes of the first application, thus avoiding the inability to create a dfx process due to the upper limit on the number of processes, which would prevent the application from recording exceptions.

[0018] In one possible design, the first condition includes the first process being a preset process. If the first condition is met, the first process is created, including: if, under the first condition, the total number of preset processes currently running in the first application is less than the maximum number of preset processes in the first application, then the first process is created. It should be noted that the maximum number of preset processes in the first application refers to the maximum number of preset processes the first application can create. The maximum number of processes in the first application mentioned above refers to the maximum number of processes the first application can create. This maximum number of processes can include the maximum number of ordinary processes in the first application plus the maximum number of preset processes. Ordinary processes can be understood as processes other than preset processes. Therefore, in this embodiment, the number of preset processes in the first application can also be controlled to avoid unlimited creation of preset processes, which could lead to excessive consumption of system resources.

[0019] In one possible design, the preset maximum number of processes for the first application satisfies one or more of the following: the preset maximum number of processes for the first application is pre-configured by the first application; or, the preset maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, the preset maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, the preset maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device. Therefore, in the embodiments of this application, the preset maximum number of processes for the first application can be determined in multiple ways, for example, it can be related to the operating load of the electronic device, the remaining battery power, etc., so that the preset maximum number of processes for the first application can be flexibly changed according to the operating load and the remaining battery power.

[0020] In one possible design, before creating the first process, it is determined whether the electronic device meets a first condition, including: calling an incubation function, which creates the first process via a system call; before adding the first process to the control group of the first application, it is determined whether the electronic device meets the first condition; if the first condition is met, the first process is created, including: adding the first process to the control group of the first application; if the first condition is not met, the creation of the first process is prohibited, including: prohibiting the addition of the first process to the control group of the first application; wherein, the control group of the first application includes one or more processes, which are used to implement the functions of the first application. Therefore, in this embodiment, before adding the first process to the control group of the first application, it is determined whether the first condition is met. If it is met, the first process is added to the control group of the first application; if it is not met, the addition of the first process to the control group of the first application is prohibited. In this way, excessive addition of processes to the control group of the first application is avoided, which would lead to excessive consumption of system resources.

[0021] In one possible design, before creating the first process, the method further includes determining that the total number of all processes currently running on the electronic device is less than the maximum number of processes on the electronic device. Therefore, in this embodiment, the electronic device can be configured with a maximum number of processes, meaning the total number of all processes currently running on the electronic device does not exceed this maximum number of processes. Thus, if the first application wants to create the first process, and given that the first condition is met, if the total number of all processes currently running on the electronic device has reached the maximum number of processes on the device, then the creation of the first process is prohibited; if the maximum number of processes has not been reached, then the first process can be created. This approach avoids an excessive number of processes running on the electronic device, which could lead to excessive consumption of system resources.

[0022] In one possible design, the maximum number of processes in an electronic device is pre-configured by the device's operating system; alternatively, the maximum number of processes is determined by the device's current operating load; or, it is determined by the device's remaining battery power. For example, when the device's current operating load is high or its remaining battery power is low, the maximum number of processes is low; conversely, when the device's current operating load is low or its remaining battery power is high, the maximum number of processes is high. In other words, the maximum number of processes in an electronic device can flexibly vary based on the device's operating load and remaining battery power.

[0023] Secondly, a process management method is also provided, applied to an electronic device. For example, the electronic device may be a mobile phone. In this method, the electronic device creates a first process for a first application; in response to the creation of the first process, it is determined whether the electronic device meets a first condition, which includes: the first application is in a live state, the total number of currently running processes of the first application is less than the maximum number of processes of the first application, and the first process is at least one of the preset processes; the first application being in a live state includes the main process of the first application being in a normal running state; if the first condition is not met, the first process is destroyed; if the first condition is met, the first process is run.

[0024] Therefore, embodiments of this application provide a process management method that can manage the processes of applications in an electronic device. For example, a first application creates a first process; if a first condition is met, the first process runs; otherwise, the first process is destroyed. This process management method can avoid creating too many processes, which would lead to an excessive number of processes and excessive consumption of system resources.

[0025] In one possible design, the first condition includes the first application being alive. Determining whether the electronic device meets the first condition includes: determining whether the first application is alive based on the application live flag in the process manager of the first application, wherein the process manager is used to manage the processes of the first application.

[0026] In one possible design, if the electronic device detects that a first application has started, it configures the application liveness flag of the first application as a first flag, which indicates that the first application is alive; if it detects that the first application has exited, it configures the application liveness flag of the first application as a second flag, which indicates that the first application is not alive.

[0027] In one possible design, the first condition includes the total number of processes currently running in the first application being less than or equal to the maximum number of processes in the first application. Before determining whether the electronic device meets the first condition, the electronic device reads the maximum number of processes in the first application from the process manager of the first application, which is used to manage the processes of the first application.

[0028] In one possible design, before reading the maximum number of processes of the first application from the process manager of the first application, the electronic device responds to the start command of the first application, obtains the maximum number of processes of the first application, and adds the maximum number of processes of the first application to the process manager of the first application.

[0029] In one possible design, the maximum number of processes for the first application satisfies one or more of the following: the maximum number of processes for the first application is pre-configured by the first application; or, the maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, the maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, the maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device.

[0030] In one possible design, the upper limit of the number of processes corresponding to different applications in an electronic device is different.

[0031] In one possible design, the first condition includes that the first process is a preset process, and determining whether the electronic device meets the first condition includes: determining whether the first process is a preset process based on the structure of the first process, wherein the structure includes descriptive information of the first process.

[0032] In one possible design, determining whether a first process is a preset process based on the structure of the first process includes: if the structure of the first process contains a third marker, determining that the first process is a preset process; if the structure of the first process does not contain a third marker, determining that the first process is not a preset process, wherein the third marker is a marker used to indicate a preset process.

[0033] In one possible design, the first process is a preset process, including one or more of the following: the first process is a child process corresponding to the main process of the first application; or, the first process is a process used to log exceptions; or, the first process is a system service process.

[0034] In one possible design, the first process is a preset process, including: the first process is the dfx process, which is used to record exception information.

[0035] In one possible design, the first condition includes the first process being a preset process. If the first condition is met, the first process is created, including: if the total number of preset processes currently running in the first application is determined to be less than the upper limit of the number of preset processes in the first application, the first process is run.

[0036] In one possible design, the preset maximum number of processes for the first application satisfies one or more of the following: the preset maximum number of processes for the first application is pre-configured by the first application; or, the preset maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, the preset maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, the preset maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device.

[0037] In one possible design, creating a first process for a first application includes: calling an incubation function, which creates the first process via a system call; determining whether an electronic device meets a first condition, including: determining whether the electronic device meets the first condition before adding the first process to the control group of the first application; destroying the first process if the first condition is not met, including: preventing the first process from being added to the control group of the first application if the first condition is not met; and running the first process if the first condition is met, including: adding the first process to the control group of the first application and running the first process if the first condition is met; wherein the control group of the first application includes one or more processes, which are used to implement the functions of the first application.

[0038] In one possible design, before running the first process, the electronic device determines that the total number of all currently running processes is less than the maximum number of processes that the electronic device can handle.

[0039] Thirdly, an electronic device is also provided, comprising:

[0040] Processor, memory, and one or more programs;

[0041] The one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the processor, cause the electronic device to perform the method provided in the first or second aspect above.

[0042] Fourthly, a computer-readable storage medium is also provided for storing a computer program that, when run on a computer, causes the computer to perform the methods provided in the first or second aspect above.

[0043] Fifthly, a computer program product is also provided, comprising a computer program that, when run on a computer, causes the computer to perform the methods provided in the first or second aspect above.

[0044] In a sixth aspect, a chip is also provided, the chip being used to execute the technical solutions provided in the first or second aspect above.

[0045] For the technical effects that can be achieved in the second to sixth aspects mentioned above, please refer to the description of the technical effects that can be achieved by the corresponding design scheme in the first aspect mentioned above. This application will not repeat them here. Attached Figure Description

[0046] Figure 1 A schematic diagram of an incubator provided in one embodiment of this application;

[0047] Figure 2 A schematic diagram illustrating the startup process of a first application provided in an embodiment of this application;

[0048] Figures 3A to 3C A schematic diagram illustrating the configuration process of the maximum number of processes of a first application provided in an embodiment of this application;

[0049] Figures 4A to 4C A schematic diagram illustrating the usage of the process limit of a first application provided in an embodiment of this application;

[0050] Figure 5 A schematic diagram of a preset process provided in an embodiment of this application;

[0051] Figures 6A to 6D A schematic diagram of the creation process of a preset process provided in an embodiment of this application;

[0052] Figures 7A to 7C A schematic diagram illustrating the configuration process of an application liveness marker for a first application provided in an embodiment of this application;

[0053] Figures 8A to 8C A schematic diagram illustrating the application survival tagging process for a first application provided in an embodiment of this application;

[0054] Figure 9 A schematic diagram illustrating the exit process of a first application provided in an embodiment of this application;

[0055] Figure 10 A schematic diagram of an electronic device provided in an embodiment of this application;

[0056] Figure 11 Another schematic diagram of an electronic device provided in an embodiment of this application;

[0057] Figure 12 This is another schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0058] The following explanations of some terms used in the embodiments of this application are provided to facilitate understanding by those skilled in the art.

[0059] The embodiments of this application involve at least one, including one or more; where "multiple" means two or more. Furthermore, it should be understood that in the description of this specification, terms such as "first," "second," and "third" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or order. For example, "first process" and "second process" do not represent the degree of importance of the two or their order, but are merely for descriptive distinction. In the embodiments of this application, "and / or" merely describes an association relationship, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0060] References to "one embodiment," "in some examples," or "some embodiments" as described in the embodiments of this application mean that one or more embodiments of this specification include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in some examples," "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0061] The process management method provided in this application can be applied to electronic devices. An electronic device can be any device that supports multi-process execution. As an example, an electronic device can be a terminal device. Exemplary terminal devices may include mobile phones, tablets, laptops, PDAs, mobile internet devices (MIDs), wearable devices (e.g., smartwatches, smart bracelets, pedometers, etc.), in-vehicle devices (e.g., devices mounted on vehicles such as cars, bicycles, electric vehicles, airplanes, ships, trains, and high-speed trains), smart home appliances (e.g., televisions, air conditioners, refrigerators, washing machines, robot vacuum cleaners, air purifiers), virtual reality (VR) devices, augmented reality (AR) devices, mixed reality (MR) devices, etc. In short, this application does not limit the type of terminal device. As another example, an electronic device can also be a server. A server can also have various names such as "server-side," "cloud server," or "cloud-based." This application does not limit the type of server; for example, it can be a web server or other servers. In conclusion, the process management method provided in this application can be applied to various types of electronic devices.

[0062] As mentioned above, in this embodiment, the electronic device supports multi-process operation. A process can be understood as a single program execution process, which is used to implement one or more functions. Therefore, a process has a lifecycle, such as "creation -> running -> destruction". Multi-process operation means that multiple processes run synchronously / concurrently. One possible scenario is that the electronic device includes a first application that supports multi-process operation. The first application can be any application in the electronic device, including system applications and third-party applications, without limitation. For example, the first application can be an instant messaging application, a multimedia playback application, an image capture application, a shopping application, a social application, a game application, a map application, etc., without listing all of them.

[0063] The following section continues to use the first application as an example to illustrate the process control method provided in the embodiments of this application.

[0064] In this embodiment, after receiving a launch command for a first application, the electronic device launches the first application. Launching the first application may include creating and running the application's main process. The main process can be understood as the "core" or "brain" of the application, responsible for coordinating and managing its various functions / windows. In some embodiments, the creation of the main process may be handled by an incubator within the electronic device. The incubator creates a sub-incubator as the main process for each application launched. For example, such as... Figure 1 After receiving a process creation request (or incubation request), the incubator creates a sub-incubator, which serves as the main process of the first application. In this embodiment, the incubator may also be called an "application incubator," "application incubation component," or other names. For example, the incubator may be Zygote or app spawn. For instance, if the electronic device's operating system is Android, the incubator is Zygote; if the electronic device's operating system is HarmonyOS, the incubator is app spawn.

[0065] As mentioned earlier, the incubator receives a process creation request (or incubation request). One possible approach is that the electronic device's desktop displays the application icon of the first application. When the user clicks the application icon, the electronic device detects an input event. If this input event is identified as an event used to launch the first application, it is sent to the component management service within the electronic device. The component management service then sends a process creation request to the incubator, requesting the incubator to create the main process of the first application. Optionally, the process creation request may carry the application identifier of the first application, such as the application package name. For example, if the electronic device's operating system is Android, the component management service could be the Activity Manager Service (AMS). It should be noted that... Figure 1 Taking the first application as an example, it should be understood that in addition to the first application, the electronic device also includes a second application. The startup principle of the second application is the same as that of the first application, that is, after the incubator receives the process creation request, it creates a sub-incubator, which serves as the main process of the second application.

[0066] As mentioned earlier, the incubator creates the main process for the first application. As an example, such as... Figure 2 The incubator creates the main process of the first application, which can be divided into three phases: Phase 1, Phase 2, and Phase 3. In Phase 1, the incubator creates sub-incubators. For example, after receiving a process creation request, the incubator creates a sub-incubator. It should be noted that, as... Figure 2By default, child incubators and their parent incubators reside in the same control group (Cgroup). For clarity, we'll first explain Cgroups. Electronic devices often contain a large number of processes; for easier management, multiple processes can reside in a single Cgroup, allowing for efficient management at the Cgroup level. By default, when a process (also called a parent process) creates a child process, the child process and parent process are in the same Cgroup. Figure 2 In the first stage, after the incubator creates a child incubator, the child incubator is located in the same C group as the original incubator by default. In the second stage, the incubator creates a new C group, which serves as the C group for the first application. In other words, this new C group is used to house the processes of the first application. In the third stage, the incubator migrates the child incubator to the new C group. This child incubator becomes the first process in the new C group and serves as the main process of the first application. Figure 2 The three stages are used to create the main process of the first application.

[0067] Continue as Figure 2 The C group of the first application includes the main process of the first application. The main process of the first application can create other processes. For example, ... Figure 2 The main process of the first application can create child processes. One possible scenario is that after the main process of the first application is successfully created, the electronic device displays the homepage (or main interface) of the first application. Upon receiving a trigger operation from the user on the homepage, the main process of the first application creates a child process, which is used to implement the function corresponding to the trigger operation. Continuing with... Figure 2 For example, after the main process of the first application creates child processes, these child processes can continue to create other processes, following the same principle, which will not be repeated here. Therefore, the C group of the first application can include multiple processes of the first application. It is understandable that each additional process in the C group consumes more system resources. If the number of processes is too large, it will excessively consume system resources. For instance, if the first application is malicious or one of its processes is attacked, causing too many processes to be created within the first application's C group, until the system resources of the electronic device are exhausted, causing the electronic device to malfunction, this phenomenon can also be called a "fork bomb" attack.

[0068] To avoid "fork bomb" attacks or reduce the system resources consumed by applications creating too many processes, in this embodiment, the electronic device configures a parameter for the C group of the first application. This parameter indicates the maximum number of processes within the C group of the first application, such as... Figure 3AWhen the number of processes within the first application's C group reaches its limit, the first application cannot create new processes, thus ensuring that the number of processes within the first application's C group does not exceed the limit. Continuing... Figure 3A For example, suppose the maximum number of processes in the C group of the first application is 2, meaning that a maximum of 2 processes are allowed to exist within the C group of the first application, in order to avoid creating too many processes within the C group of the first application. For ease of understanding, the following will continue to use... Figure 3A The following example will be used as an example. The following embodiment is described in two parts. The first part is the parameter configuration process, that is, the process of configuring the maximum number of processes for the C group of the first application. The second part is the parameter usage process, that is, the process of using the maximum number of processes after configuring the maximum number of processes for the C group of the first application.

[0069] The first part configures the maximum number of processes for the C group of the first application.

[0070] In this embodiment, configuring the process limit for the C group of the first application can be handled by the incubator. It should be understood that, prior to this, the incubator needs to obtain the process limit for the first application (this process limit can be the "normal process limit" mentioned later). Optionally, the process limit can be obtained in ways including, but not limited to, at least one of the following:

[0071] (1) The maximum number of processes for the first application is pre-configured. For example, the maximum number of processes for the first application is stored in the application package of the first application. The incubator can obtain the maximum number of processes for the first application from the application package of the first application. In this way, the maximum number of processes for each application is determined by the developers of each application, so the maximum number of processes for each application may be the same or different.

[0072] (2) The maximum number of processes for the first application is pre-configured by the operating system of the electronic device. For example, the maximum number of processes for the first application is stored in the system configuration file of the electronic device. The incubator can obtain the maximum number of processes for the first application from the system configuration file. The pre-configured maximum number of processes by the operating system can include one or more. For example, if the operating system pre-configures only one maximum number of processes, this maximum number of processes can apply to one or more applications. If it applies to multiple applications, that is, multiple applications have the same maximum number of processes, all of which are the maximum number of processes pre-configured by the operating system. If the operating system pre-configures multiple maximum number of processes, these multiple maximum number of processes can apply to multiple applications. For example, if the operating system pre-configures maximum number of processes 1 and maximum number of processes 2, maximum number of processes 1 applies to application 1, and maximum number of processes 2 applies to application 2.

[0073] (3) The maximum number of processes for the first application is specified by the user. One possible approach is that the electronic device provides an interface for the user to specify the maximum number of processes for the first application. Optionally, the interface may be the interface of the first application or the interface of other applications (e.g., settings applications in the electronic device), without limitation.

[0074] (4) The maximum number of processes for the first application is determined based on its application type. That is, different application types may have different maximum process counts. For example, the maximum process count for a multimedia playback application may differ from that for a game application, or the maximum process count for an instant messaging application may differ from that for an image capture application. One possible approach is to store a correspondence between various application types and their maximum process counts in the electronic device. Based on this correspondence, the incubator can determine the maximum process count for the first application. Optionally, this correspondence may be pre-installed in the electronic device. It should be noted that for certain types of applications (e.g., game applications), a significant impact on user experience occurs when the application lags. For these applications, a higher maximum process count can be implemented to ensure the application's running speed and prevent lag. Conversely, for certain types of applications (e.g., gallery applications), a less noticeable impact on user experience occurs when the application lags. For these applications, a lower maximum process count can be implemented to avoid excessive consumption of system resources.

[0075] (5) The maximum number of processes for the first application is determined based on the current operating load of the electronic device. That is, the maximum number of processes for the first application can vary depending on the current operating load of the electronic device. The operating load of the electronic device can be expressed by one or more parameters such as CPU speed and storage space utilization. Taking CPU speed as an example, one possible approach is that the electronic device stores a correspondence between CPU speed and the maximum number of processes. After determining the current CPU speed, the incubator determines the corresponding maximum number of processes based on this correspondence. Optionally, this correspondence can be pre-installed in the electronic device. It should be understood that if the current operating load of the electronic device is high, the maximum number of processes for the first application can be low to avoid increasing the CPU's operating burden; conversely, if the current operating load of the electronic device is low, the maximum number of processes for the first application can be high to ensure a higher operating speed.

[0076] (6) The maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device. For example, when the current remaining battery power of the electronic device is high, the maximum number of processes for the first application can be high to ensure a high operating speed; conversely, when the current remaining battery power of the electronic device is low, the maximum number of processes for the first application can be low to prevent rapid power loss. One possible approach is that the electronic device stores a correspondence between various remaining battery power ranges (e.g., 1-20%, 20%-80%, 80%-100%) and the maximum number of processes. After the incubator determines the current remaining battery power (e.g., 60%), it determines which range the current remaining battery power falls into based on the correspondence and determines the maximum number of processes corresponding to that range. Optionally, the correspondence can be pre-set in the electronic device.

[0077] The above lists six ways to obtain the maximum number of processes for the first application. Optionally, these six methods can be used individually or in combination, without limitation. In addition to the above six methods, other methods can also be used to obtain the maximum number of processes for the first application, which will not be listed here.

[0078] After the incubator obtains the maximum number of processes for the first application, it can configure this maximum number of processes for the C group of the first application. The following explains when to configure the maximum number of processes for the C group of the first application. For example, ... Figure 3B The incubator's main process for creating the first application consists of three phases: Phase 1, Phase 2, and Phase 3.

[0079] Phase one involves the incubator creating sub-incubators. For example, phase one might include calling a `fork` function, which creates a sub-incubator via a system call, such as... Figure 3B This process can include three stages: incubation of sub-incubators, pre-attach, and attachment. The incubation stage can be understood as hatching a prototype sub-incubator. The pre-attach stage involves pre-attaching (or attempting to attach) the hatched sub-incubator to the C group (the original incubator's C group). The attachment stage involves officially adding (or formally attaching) the hatched sub-incubator to the C group (the original incubator's C group). After stage one, the sub-incubator and the original incubator are in the same C group.

[0080] Phase Two: The incubator creates new C groups. For example... Figure 3BPhase two can include three processes: creation, allocation, and enabling of the new C group. The allocation process is used to complete the basic configuration of the new C group (e.g., configuring the corresponding system resources). The enabling process is used to enable the new C group.

[0081] Phase Three: The incubator migrates its sub-incubators to the new C group. For example... Figure 3B Phase 3 can include two processes: pre-migrate and migration of the sub-incubator. The pre-migrate process pre-migrates the sub-incubator (which can be understood as an attempt to migrate) to the new C group. The migration process then migrates the sub-incubator (which can be understood as the actual migration) to the new C group. After being migrated to the new C group, the sub-incubator can serve as the main process of the first application. For example, the first application can configure corresponding variables for the sub-incubator so that when the electronic device runs the sub-incubator, the first application starts.

[0082] Continue with Figure 3B For example, the incubator can configure a maximum number of processes for the first application's Cgroup in Phase Two, Phase Three, or between Phase Two and Phase Three. For example, as... Figure 3B Between the pre-migration and migration processes in Phase Three, the incubator configures a maximum number of processes for the first application's C group. Optionally, the incubator can also configure the maximum number of processes before or after the pre-migration. Alternatively, the incubator can configure the maximum number of processes for the first application's C group within Phase Two, for example, between the configuration and enabling processes, or before configuration, or after enabling. In summary, this application embodiment does not limit the timing of configuring the maximum number of processes for the first application's C group.

[0083] As mentioned earlier, the incubator configures a process limit for the first application's C group. One possible approach is for the incubator to configure this limit in the process controller (PIDs controller) of the first application's C group. For ease of understanding, the process controller will be explained here first. In this embodiment, one C group can correspond to one process controller, used to manage the processes within the C group. For example, the process manager includes basic information about the C group, such as the application identifier of the application corresponding to the C group, the creation time of the C group, and the system resources corresponding to the C group. One possible scenario is that the incubator automatically generates a process controller corresponding to each C group it creates. Therefore, when the incubator creates a C group for the first application, it automatically generates a process controller corresponding to the first application's C group, and then the incubator configures the process limit for the first application within this process controller. Another possible approach is to add a field to the first application's process controller, which is used to populate the process limit for the first application. For example, as shown... Figure 3C The process controller of the first application's C group includes field A, which contains the maximum number of processes for the first application. Field A can be any one or more fields in the process controller, without limitation.

[0084] The above embodiments illustrate the process of configuring a maximum number of processes for the C group of the first application. The following section describes the process of using the maximum number of processes after configuring the maximum number of processes for the first application, which is the second part.

[0085] The second part concerns the use of the maximum number of processes in the C group of the first application.

[0086] After configuring the process limit in the C group of the first application, if the first application wants to create a new process, it can determine whether the current number of processes in the C group of the first application has reached the process limit. If so, a new process cannot be created; otherwise, a new process can be created.

[0087] For example, such as Figure 4A This is a flowchart illustrating a process control method provided in an embodiment of this application. Figure 4A The process includes:

[0088] S400, determine to create the first process, the first process is the process of the first application.

[0089] Optionally, the execution entity of S400 can be an incubator or the first application. One possible implementation of S400 is that it listens for a second process in the first application's C group calling the `fork` function to create a first process. The second process can be any existing process in the first application's C group. It should be noted that the second process calling the `fork` function to create the first process can include: incubating the first process, attaching the incubated first process to the first application's C group, and configuring the first process with the corresponding variables of the first application after it has been added to the first application's C group. This process will be discussed later. Figure 4B The Central Committee will provide a detailed explanation.

[0090] S401: Determine whether the current number of processes of the first application has reached the maximum number of processes. If so, prohibit the creation of the first process; otherwise, create the first process.

[0091] For example, the first application / incubator counts the current number of processes in the first application's C group, and retrieves the number of processes from the process manager corresponding to the first application's C group (e.g., ...). Figure 3C The process manager reads the maximum number of processes, compares the current number of processes with the maximum number of processes, and if the current number of processes has not reached the maximum number of processes, then creates the first process; if the current number of processes has reached the maximum number of processes, then prevents the creation of the first process.

[0092] As mentioned earlier, creating the first process requires adding it to the first application's C group. Therefore, S401 can occur before adding the first process to the first application's C group. For example, if the current number of processes in the first application's C group has not reached the process limit, then adding the first process to the first application's C group is allowed; otherwise, adding the first process to the first application's C group is prohibited.

[0093] The following is passed Figure 4B and Figure 4C The creation process of the first process is described in detail.

[0094] like Figure 4B The creation of the first process by an electronic device includes three processes: forking, pre-adding, and adding. The forking process can be understood as creating a prototype of the first process. The pre-adding process is used to pre-add (attempt to add) the forked first process to the first application's C group. The adding process is used to officially add (formally add) the forked first process to the first application's C group. Figure 4BIn the process, after the addition process is completed, i.e., after the first process has been added to the C group of the first application, the process count counter of the first application's C group is incremented by 1 to indicate that a new process has been added to the C group of the first application. The first application / incubator can determine whether the count of this counter is greater than the maximum number of processes. If the count of the counter is less than or equal to the maximum number of processes, the process ends directly; otherwise, the first process is removed from the C group of the first application or destroyed, the count of the counter is decremented by 1, and then the process ends. It should be understood that after the first process is added to the C group of the first application, the first application can configure corresponding variables for the first process to enable the first process to perform the functions of the first application.

[0095] like Figure 4C The creation of an electronic device involves three processes: forking, pre-adding, and adding. Figure 4C In the process, after pre-addition and before addition, the first application / incubator checks if the current number of processes in the C group is less than the maximum number of processes. If not, the addition process is skipped and the process ends directly. If so, the addition process is executed, adding the first process to the first application's C group. Then, the process count counter of the first application's C group is incremented by 1 to represent the addition of one process to the first application's C group. It should be noted that... Figure 4C In this context, the process of determining the number of processes can also be performed before pre-addition, and the principle is the same, so it will not be repeated. It should be understood that after the first process is added to the first application's C group, the first application can configure corresponding variables for the first process to enable the first process to perform the functions of the first application.

[0096] The above embodiments mainly use the first application as an example for illustration. It should be understood that, in addition to the first application, the electronic device also includes a second application, which, after being launched, also corresponds to a C group. For example, the first application corresponds to a first C group, and the second application corresponds to a second C group. The first C group and the second C group are two different C groups. The first C group corresponds to a first process limit, used to indicate that the number of processes in the first C group does not exceed the first process limit. The first process limit is configured in the first process manager corresponding to the first C group. The second C group corresponds to a second process limit, used to indicate that the number of processes in the second C group does not exceed the second process limit. The second process limit is configured in the second process manager corresponding to the second C group. The first process limit and the second process limit may be the same or different, and are not limited thereto.

[0097] In other embodiments, not only the number of application processes can be controlled, but also the number of processes currently running on the entire electronic device can be controlled. For example, the total number of currently running processes on the entire device does not exceed a threshold (also known as the upper limit of the number of processes on the entire device). For example, if the electronic device is currently running two applications, the sum of the total number of currently running processes of these two applications does not exceed the upper limit of the number of processes on the entire device. Optionally, the upper limit of the number of processes on the entire device can be determined in various ways. For example, the upper limit of the number of processes on the entire device may be pre-configured by the operating system of the electronic device, or specified by the user, or related to the current operating load of the electronic device, or related to the current remaining battery power of the electronic device, without limitation.

[0098] Based on the above embodiments, it can be seen that the electronic device controls the number of processes of the first application by setting a maximum limit on the number of processes of the first application. It is understandable that if the maximum number of processes is set too high (i.e., loose control), it means that the application is allowed to create too many processes, which can easily lead to applications accessing system resources without authorization. Conversely, if the maximum number of processes is set too low (i.e., strict control), it will also have certain impacts. For example, the current number of processes of the first application can easily reach the limit. Once the limit is reached, the first application cannot create new processes. In some scenarios, the inability to create new processes may affect the normal operation of the first application. For instance, if the first application malfunctions and the current number of processes has reached the limit, preventing the creation of a dfx process for recording the exception, then the exception information log cannot be generated, affecting the maintenance and upgrade of the application.

[0099] To avoid this situation, in this embodiment of the application, certain processes (hereinafter referred to as preset processes) are not subject to the control of the maximum number of processes. In other words, even if the current number of processes running in the first application has reached the limit, if the first application wants to create a preset process, it can create it directly. For example, Figure 5 In case (a), the maximum number of processes in the first application's C group is 2, and the current number of processes within the first application's C group has already reached 2. In this situation, if the first application creates a pre-defined process (e.g., a pre-defined process is created by an existing process in the first application's C group), it is not subject to the process limit and can be created directly, such as... Figure 5 (b) in the middle.

[0100] For example, such as Figure 6A This is another flowchart illustrating a process control method provided in an embodiment of this application. Figure 6A The process includes:

[0101] S600 determines to create the first process, which is the process of the first application.

[0102] Optionally, the execution entity of S600 can be an incubator or the first application. One possible implementation of S600 is that it listens for a second process in the first application's C group calling the `fork` function to create a first process. The second process can be any existing process in the first application's C group. It should be noted that the second process calling the `fork` function to create the first process can include: incubating the first process, attaching the incubated first process to the first application's C group, and configuring the corresponding variables of the first application for the first process after it has been added to the first application's C group. This process will be discussed later. Figure 6B The Central Committee will provide a detailed explanation.

[0103] S601, determine whether the first process is a preset process. If it is, create the first process; otherwise, execute S602.

[0104] As mentioned earlier, creating the first process requires adding it to the C group of the first application. Therefore, S601 can occur before adding the first process to the C group of the first application. For example, if it is determined that the first process is a preset process, then the first process is added to the C group of the first application; if it is determined that the first process is not a preset process, then S602 is executed.

[0105] In this embodiment of the application, the preset process may satisfy one or more of the following:

[0106] (1) The default process is a system process. A system process can be understood as part of the operating system, for example, capable of performing tasks with higher privileges, such as accessing system resources (e.g., memory, CPU, etc.). There are multiple ways to determine whether the first process is a system process, including but not limited to Method 1 and Method 2 described below. Method 1: Determine whether the first process is a system process by querying a list. For example, the electronic device includes a list containing the process IDs of all system processes in the electronic device. Therefore, after the first process is created, it is determined whether the process ID of the first process exists in the list. If it exists, the first process is determined to be a system process; otherwise, the first process is determined not to be a system process. Method 2: Determine whether the first process is a system process by its file location. For example, the electronic device can check the location of the executable file corresponding to the first process. If it is located in a system folder (e.g., C:\Windows\ or C:\Windows\System32\, etc.), the first process is determined to be a system process; otherwise, the first process is determined not to be a system process. It is understood that the electronic device may include several system processes, and the default process may be one or more of these several system processes.

[0107] (2) The default process is an application process. Application processes differ from system processes. System processes are part of the operating system, while application processes are part of an application program; their levels / dimensions are different. There are multiple ways to determine whether the first process is an application process, including but not limited to Method 1 and Method 2 described below. Method 1: Determine whether the first process is an application process by querying a list. For example, an electronic device may contain a list (e.g., a list can be obtained from the application packages of various applications), which includes the process IDs of all application processes for each application. Therefore, after the first process is created, it is determined whether the process ID of the first process exists in the list. If it does, the first process is determined to be an application process; otherwise, it is determined not to be an application process. Method 2: Determine whether the first process is an application process by file location. For example, an electronic device can check the location of the executable file corresponding to the first process. If it is located in the application package of an application, the first process is determined to be an application process; otherwise, it is determined not to be an application process. It is understood that an application may include several application processes, and the default process may be one or more of these application processes.

[0108] (3) The default process is the default process. Taking the default process as a system process as an example, one possible scenario is that the default process is pre-configured after the electronic device leaves the factory. Taking the default process as an application process as an example, one possible scenario is that the default process is pre-configured when the application is released.

[0109] (4) The preset process is a user-specified process. One possible approach is that the electronic device provides an interface for specifying the preset process. Optionally, the interface may be an application settings interface within the electronic device or an interface of other applications, without limitation.

[0110] (5) The default process is a child process of the main process of the first application. That is to say, if the main process of the first application wants to create a child process, it is not limited by the limit on the number of processes, and the main process can create the child process directly.

[0111] (6) The default process is the System Service process. That is to say, when the first application needs to create a System Service process, it is not limited by the limit on the number of processes and can directly create the System Service process.

[0112] (7) A preset process is a process used to implement preset services. Optionally, preset services may include exception logging, application upgrades, etc. Taking exception logging as an example, that is, a preset process is a process used to log exceptions. For example, a preset process may be a design for x (dfx) process, where x represents a design for exception detection. In other words, the dfx process is used to log exceptions.

[0113] The above are some examples of preset processes. In practical applications, preset processes can also be other processes besides those listed above, which will not be listed one by one. In addition, the examples listed above can be used alone or in combination, without limitation.

[0114] In this embodiment, determining whether the first process is a preset process can include multiple methods. Method 1: The electronic device has a preset whitelist 1, which includes the process IDs of one or more processes. The processes corresponding to these process IDs are preset processes. Therefore, after the first process is created, the electronic device can determine whether the process ID of the first process exists in whitelist 1. If it does, the first process is determined to be a preset process; otherwise, it is determined not to be a preset process. Method 2: When the first application calls the incubation function to create the first process, the electronic device enters kernel mode from user mode. The return address used to return to user mode is recorded, and the return address is used to determine whether the first process is a preset process. For ease of understanding, the principle of Method 2 is explained using the example of the preset process being a dfx process. When the first application encounters a runtime exception, the first application can load the dfx dynamic shared library, which creates a dfx process to record exception information. In this embodiment, the dynamic shared library can create a dfx process in two ways. For example... Figure 6BThe first method involves the dynamic shared library first calling a function library (e.g., a C library storing standard functions), and then using that function library to call a system call (e.g., via a syscall function call) to create the dfx process. The second method involves the dynamic shared library directly calling a system call to create the dfx process. Taking the second method as an example, after the system call, the electronic device enters kernel mode from user mode and records the return address used to return to user mode. This return address can be understood as the address of the creator of the dfx process (i.e., the dfx dynamic shared library). The electronic device can determine whether the process to be created is a dfx process based on the return address. One possible approach is for the electronic device to determine the file to which the return address belongs (i.e., a file in the dfx dynamic shared library), and then determine whether the process to be created is a dfx process based on the filename, location, etc. For example, if the file is located in the dfx dynamic shared library and / or the filename contains dfx.so, then the process to be created is determined to be a dfx process. Another possible approach is that, after the electronic device determines the file to which the returned address belongs (i.e., a file in the DFX dynamic shared library), it checks whether the file's information is in whitelist 2 (e.g., whitelist 2 includes file information of one or more files that can create DFX processes). If so, it determines that the process to be created is a DFX process; otherwise, it determines that the process to be created is not a DFX process. Optionally, whitelist 2 can be pre-configured in the electronic device.

[0115] S602, determine whether the current number of processes of the first application has reached the process limit. If so, prohibit the creation of the first process; otherwise, create the first process.

[0116] As mentioned earlier, creating the first process requires adding it to the first application's C group. Therefore, before adding the first process to the first application's C group, it can be determined whether the first process is a preset process. If it is a preset process, then the first process is added to the first application's C group. If it is not a preset process, it is determined whether the current number of processes in the first application has reached the process limit. If so, adding the first process to the first application's C group is prohibited; otherwise, the first process is added to the first application's C group, completing the creation of the first process.

[0117] The following is passed Figure 6C and Figure 6D The creation process of the first process is described in detail.

[0118] like Figure 6C The creation of an electronic device involves three processes: incubation, pre-addition, and addition. For example... Figure 6CBefore pre-adding or adding, the incubator / first application determines whether the first process is a preset process. If so, a preset identifier is added to the first process. The preset identifier is a marker used to indicate the preset process. For example... Figure 6C After the addition process is complete, i.e., after the first process has been added to the C group of the first application, the incubator / first application determines whether the first process carries a preset identifier. If so, the process ends directly. If it does not carry a preset identifier, the process count counter of the first application's C group is incremented by 1. The incubator / first application then determines whether the count is greater than the maximum number of processes. If so, the first process is removed from the first application's C group or destroyed, and the count is decremented by 1, then the process ends. If the count is less than or equal to the maximum number of processes, the process ends directly. It should be understood that after the first process is added to the C group of the first application, the first application can configure corresponding variables for the first process to enable the first process to perform the functions of the first application.

[0119] like Figure 6D The creation of an electronic device involves three processes: incubation, pre-addition, and addition. For example... Figure 6D Before pre-adding or adding, the incubator / first application determines whether the first process is a preset process. If so, it adds a preset identifier to the first process. For example... Figure 6D Before adding a process, but after pre-adding, the incubator / first application checks if the first process carries a preset identifier. If so, the addition process is executed directly without checking the process count. If no preset identifier is carried, it checks if the current number of processes in the C group is less than the maximum number of processes. If not, the addition process is not executed, and the process ends directly. If so, the addition process is executed, adding the first process to the first application's C group. Then, the process count counter in the first application's C group is incremented by 1 to indicate that a process has been added to the first application's C group. This is understandable. Figure 6D In this context, the determination of the preset identifier and the number of processes can also be performed before pre-addition, based on the same principle, and will not be repeated here. It should be understood that after the first process is added to the first application's Cgroup, the first application can configure corresponding variables for the first process to enable it to perform the functions of the first application.

[0120] exist Figure 6C or Figure 6DIn the process, when the incubator / first application determines that the first process is a preset process, it adds a preset identifier to the first process. One possible way to add the preset identifier to the first process is to add a field to the first process's structure (struct) and add the preset identifier to that field. Optionally, the first process's structure can contain descriptive information about the first process, such as the process name, process ID, and application identifier of the first application. For example, the first process's structure can include function expressions for the first process; in the Android system, the first process's structure can be `struct task{}`.

[0121] In other embodiments, the electronic device can also control the number of preset processes. For example, the incubator can configure a preset process limit for the C group of the first application, and the number of preset processes in the C group of the first application shall not exceed this limit. In this way, the C group of the first application corresponds to two quantity limits. For ease of distinction, the preset process limit is called the "preset process limit," and the limit for the number of other processes besides the preset processes is called the "normal process limit." It is understood that before configuring the preset process limit for the C group of the first application, the incubator needs to obtain the preset process limit of the first application. The method of obtaining the preset process limit of the first application includes, but is not limited to:

[0122] (1) The maximum number of processes in the first application is pre-configured by the first application.

[0123] (2) The maximum number of processes for the first application is pre-configured by the operating system of the electronic device.

[0124] (3) The maximum number of processes in the first application is specified by the user.

[0125] (4) The maximum number of preset processes for the first application is determined based on the application type of the first application.

[0126] (5) The maximum number of preset processes for the first application is determined based on the current operating load of the electronic device.

[0127] (6) The maximum number of preset processes for the first application is determined based on the current remaining battery power of the electronic device.

[0128] For example, the implementation principles of (1) to (6) can be found in the six ways to obtain the upper limit of the number of ordinary processes mentioned above, which will not be repeated here.

[0129] (7) The maximum number of preset processes for the first application is determined based on the maximum number of ordinary processes for the first application.

[0130] For example, the preset process limit for the first application is N times the normal process limit for the first application, where N is a positive integer, which can be less than 1 or greater than or equal to 1, without limitation. The value of N can be determined in various ways, such as pre-configured by the first application or the operating system, or specified by the user. After obtaining the preset process limit, the incubator configures the preset process limit for the first application's Cgroup. The configuration process is the same as the configuration process for the normal process limit described earlier, and the principle is the same. For example, in the previous... Figure 3B In phase two or three, or between phase two and phase three, a preset maximum number of processes is configured for the Cgroup of the first application. For example, the process controller of the Cgroup of the first application (e.g., Figure 3C Add a field to the process controller, and the incubator will fill this field with a preset maximum number of processes. With the preset maximum number of processes configured, execution is possible. Figure 6A The process is as follows: if the judgment result of S601 is that the first process is a preset process, then it is determined whether the current number of preset processes of the first application has reached the upper limit of the number of preset processes. If not, the first process is created; otherwise, the creation of the first process is prohibited. If the judgment result of S601 is that the first process is not a preset process, then it is determined whether the current number of ordinary processes of the first application has reached the upper limit of the number of ordinary processes. If not, the first process is created; otherwise, the creation of the first process is prohibited.

[0131] In practical applications, a possible scenario exists: the first application may remain alive (or evade detection), meaning that after the first application exits, not all of its processes are destroyed. For example, processes may remain in the first application's C group. These remaining processes may continue to create new processes, resulting in a waste of system resources. To avoid this situation, in this embodiment, after the first application exits, all processes in the first application's C group are destroyed as much as possible, and the first application is prohibited from creating new processes. In this way, even if some processes remain undestroyed, it can be prevented from continuing to create new processes.

[0132] One possible approach is, such as Figure 7AThe first application's C group is configured with a flag that indicates whether the first application should be alive or its current state; therefore, this flag is also called the "application liveness flag." For example, the application liveness flag can be a binary number. A flag of 1 indicates that the application should be alive or is currently alive, while a flag of 0 indicates that the application should not be alive or is not currently alive. Understandably, when the first application starts normally, its application liveness flag defaults to 1, indicating that it should be alive or is currently alive. When the first application exits, its application liveness flag is configured to 0, indicating that it should not be alive or is not currently alive. When the application liveness flag is 0, the first application is prohibited from creating new processes, and the incubator will destroy all processes within the first application's C group. Even if some processes remain undestroyed, they cannot create new processes because the application liveness flag is 0. For ease of understanding, the following will continue to use... Figure 7A The following example will be used as an example. The following embodiment is divided into two parts. The first part is the parameter configuration process, that is, the process of configuring the application liveness flag for the C group of the first application. The second part is the parameter usage process, that is, the process of using the application liveness flag after configuring the application liveness flag for the C group of the first application.

[0133] The first part describes the process of configuring application liveness flags for the C group of the first application.

[0134] In this embodiment, the configuration process for applying the liveness marker can be performed by the incubator. The timing for configuring the application liveness marker for the first application's Cgroup will be explained below. For example, as... Figure 7B The incubator's main process for creating the first application consists of three phases, which can be found in the previous text. Figure 3B This will not be repeated here. The incubator can configure application liveness flags for the C group of the first application during phase two, phase three, or between phase two and phase three. For example, as... Figure 7B The incubator configures an application liveness flag for the C group of the first application between the configuration and enable processes in Phase Two. Alternatively, the incubator may configure the application liveness flag before configuration or after enable. Alternatively, it may be configured in Phase Three, for example, between the pre-migration and migration processes, or before pre-migration, or after migration. In summary, the embodiments of this application do not limit the timing of configuring the application liveness flag for the C group of the first application.

[0135] As mentioned earlier, the incubator configures an application liveness flag for the first application's C group. One possible approach is for the incubator to configure the application liveness flag in the process controller (PIDs controller) of the first application's C group. For example, the incubator could add a new field in the process controller and populate it with the application liveness flag. Figure 7C The process controller of the first application's C group includes field B, which contains the application liveness flag of the first application. Field B can be any one or more fields in the process controller other than field A.

[0136] The above embodiments illustrate the process of configuring an application liveness flag for the C group of the first application. The following describes the process of using the application liveness flag after it has been configured, which is the second part.

[0137] Part Two, the use of application liveness markers for the C group in the first application.

[0138] After configuring an application liveness flag in the C group of the first application, if the first application needs to create a new process, it can determine whether the first application should be alive based on the application liveness flag. If it is, a new process is created; otherwise, a new process cannot be created. For example, Figure 8A This is a flowchart illustrating a process control method provided in an embodiment of this application. Figure 8A The process includes:

[0139] S800 determines to create the first process, which is the process of the first application.

[0140] Optionally, the execution entity of S800 can be an incubator or a first application. One possible implementation of S800 is that it listens for a second process in the first application's C group calling the `fork` function to create a first process. The second process can be any existing process in the first application's C group. The second process calling the `fork` function to create the first process may include: incubating the first process, attaching the incubated first process to the first application's C group, and configuring the first process with the corresponding variables of the first application after it has been attached to the first application's C group. This process will be discussed later. Figure 8B The Central Committee will provide a detailed explanation.

[0141] S801 determines whether the first application should be alive. If so, execute S802; otherwise, prevent the creation of the first process.

[0142] As mentioned earlier, creating the first process requires adding it to the first application's C group. Therefore, S801 can occur before adding the first process to the first application's C group; for example, if it's determined that the first application should be alive, S802 is executed; otherwise, adding the first process to the first application's C group is prohibited. For example, the first application / incubator can be added through the process manager of the first application's C group (e.g., ...). Figure 7C The application liveness flag in the process manager (as shown) is used to determine whether the first application should be alive.

[0143] S802: Determine if the first process is a preset process. If so, create the first process; otherwise, execute S803.

[0144] S803: Determine whether the current number of processes running in the first application has reached the maximum number of processes. If so, prohibit the creation of the first process; otherwise, create the first process.

[0145] For details on the execution principle of S802, please refer to [link / reference]. Figure 6A For the execution principle of S601 and S803, please refer to [link / reference]. Figure 4A S401 in the diagram. It should be noted that S802 and S803 can be executed or not, so they are represented by dashed lines in the diagram. If they are not executed, that is, if the judgment result of S801 is yes (i.e., it is determined that the first application should be alive), the first process is created directly.

[0146] Therefore, the following text is passed through Figure 8B and Figure 8C The creation process of the first process is described in detail.

[0147] like Figure 8B The creation of an electronic device involves three processes: forking, pre-addition, and addition. For example... Figure 8B Before pre-adding or adding, the first application / incubator determines whether the first process is a preset process. If so, it adds a preset identifier to the first process. For example... Figure 8BAfter the addition process is completed, i.e., after the first process has been added to the first application's C group, the first application / incubator determines whether the first application should be alive. If it should not be alive, the first process is removed or destroyed, and the process ends. If the first application should be alive, it continues to determine whether the first process carries a preset identifier. If it does, the process ends directly; otherwise, the counter of the first application's C group is incremented by 1 to indicate that a new process has been added to the first application's C group. The incubator determines whether the count of the counter is greater than the maximum number of processes. If not, the process ends; if it is, the first process is removed from the first application's C group or destroyed, and the counter is decremented by 1, and the process ends.

[0148] like Figure 8C The creation of an electronic device involves three processes: forking, pre-addition, and addition. For example... Figure 8C Before pre-addition, the first application / incubator determines whether the first process is a preset process. If so, a preset identifier is added to the first process. For example... Figure 8C Between the pre-addition and addition processes, the first application / incubator determines whether the first application should be alive. If it should not be alive, the process ends directly without executing the addition process. If the first application should be alive, it continues to check if there is a preset flag in the first process. If so, the addition process is executed directly. If not, it checks if the current number of processes in the C group is less than the maximum number of processes. If not, the addition process is not needed, and the process ends directly. If so, the addition process is executed, adding the first process to the first application's C group. Then, the process count counter of the first application's C group is incremented by 1 to represent the addition of one process to the first application's C group. This is understandable. Figure 8C In addition, the determination of whether the application is alive or not, and the determination of the number of processes, can also be performed before pre-addition. The principle is the same, so I will not repeat it.

[0149] In the above embodiment, the application survival flag of the first application is set to 1, indicating that the first application should be alive. When the first application exits, the application survival flag is configured to 0, indicating that the first application should not be alive. For example, as... Figure 9 This is another flowchart illustrating the process control method used in the first application, such as... Figure 9 The process may include:

[0150] S900, the incubator has determined the first application to exit.

[0151] Optional, such as Figure 9 The S900 can be used in two ways.

[0152] The first approach involves the incubator monitoring the main process of the first application. If the main process exits, the incubator determines that the first application has exited. This approach is suitable for scenarios where the first application exits abnormally, such as when the first application crashes, causing its main process to exit, which is then detected by the incubator.

[0153] The second approach involves the incubator determining that the first application is exiting when it receives an exit instruction from the component management service. This component management service can be exemplified by AMS mentioned above. AMS needs to send the exit instruction to the incubator. An example scenario is that when a user exits the first application via multitasking, the electronic device detects an input event and identifies it as an event used to exit the first application. The device then sends this input event to AMS, which in turn sends the exit instruction to the incubator. Optionally, the exit instruction can carry the application identifier of the first application, such as the application package name. This approach is suitable for the normal exit scenario of the first application, i.e., when the user exits the first application via multitasking.

[0154] S901, the incubator configures the application survival flag of the first application to 0, which is used to indicate that the first application should not be alive or the first application is not in a live state.

[0155] For example, the incubator will use the C group process manager of the first application (e.g., Figure 7C The application liveness flag in the process manager shown is configured to 0.

[0156] S902, the incubator destroys the process in the C group of the first application.

[0157] It's important to note that when the application's liveness flag is 0, the application is prohibited from creating new processes. This ensures that no new processes are added to the application's C group. Furthermore, in practice, the incubator may not be able to destroy all processes in the application's C group, but because the application liveness flag is 0, even if some processes remain, they cannot create new processes.

[0158] In some embodiments, after S902, the incubator can also destroy the C group of the first application, and the process manager of the first application's C group is also destroyed accordingly. When the user restarts the first application, the C group of the first application and the corresponding process manager are rebuilt, and the process of the first application is controlled again.

[0159] Please see Figure 10This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device can be any of the terminal devices or servers listed above. For example... Figure 10 As shown, the electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0160] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, memory, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). Different processing units may be independent devices or integrated into one or more processors. The controller may serve as the nerve center and command center of the electronic device. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. Processor 110 may also include memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that processor 110 has just used or is recurring. If processor 110 needs to reuse an instruction or data, it can directly retrieve it from the memory. This avoids repeated access, reduces the waiting time of processor 110, and thus improves system efficiency.

[0161] The processor 110 can be used to execute the process management method provided in the embodiments of this application. For example, before creating the first process, the processor 110 determines whether a first condition is met. The first condition includes that the number of current processes in the electronic device is less than a first threshold, the first application in the electronic device should be alive, the number of current processes of the first application is less than a second threshold, the first process is at least one of the preset processes, and the first application is the application corresponding to the first process. If the first condition is met, the processor 110 creates the first process.

[0162] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include inter-integrated circuit (I2C) interfaces, inter-integrated circuit sound (I2S) interfaces, pulse code modulation (PCM) interfaces, universal asynchronous receiver / transmitter (UART) interfaces, mobile industry processor interfaces (MIPI), general-purpose input / output (GPIO) interfaces, subscriber identity module (SIM) interfaces, and / or universal serial bus (USB) interfaces, etc. It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0163] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in internal memory 121. For example, processor 110 implements the process management method provided in the embodiments of this application by running the instructions stored in internal memory 121.

[0164] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. These touch operations can be used to launch or exit a first application.

[0165] Understandable Figure 10 The components shown do not constitute a specific limitation on the electronic device. The electronic device in the embodiments of this application may include, but is not limited to, components that are... Figure 10 More or fewer parts. Furthermore, Figure 10 The combination / connection relationships between the components can also be adjusted and modified.

[0166] Please see Figure 11 This is a schematic diagram of another structure of an electronic device provided in one embodiment of this application. The electronic device can be any of the terminal devices or servers listed above. If... Figure 10 Understand it as the hardware structure of electronic devices. Figure 11 This can be understood as the software structure of an electronic device. For example... Figure 11 As shown, the software architecture of an electronic device can be a layered structure. This layered architecture divides the software of the electronic device into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. For example, as... Figure 11 The software structure of electronic devices, from top to bottom, consists of: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0167] like Figure 11 The application layer may include one or more applications, such as the first application. For more information about the first application, please refer to the previous description.

[0168] like Figure 11 The application framework layer includes Application Management System (AMS) and an incubator. AMS manages the application, such as its startup and shutdown. The incubator creates the main process for the application upon startup and, optionally, destroys the main process and other processes upon shutdown. It should be noted that... Figure 11 Taking the incubator located in the application framework layer as an example, optionally, the incubator may also be located in other layers, such as in the system library. In short, the location of the incubator is not limited in the embodiments of this application. Furthermore, it should be noted that although... Figure 11 It is not shown in the diagram, but the application framework layer may also include other modules, such as window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0169] like Figure 11 The system library can include multiple functional modules, such as: surface manager, media libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc.

[0170] like Figure 11 The kernel layer includes various drivers, such as display drivers and sensor drivers.

[0171] Understandable Figure 11 The software structure shown does not constitute a specific limitation on the software structure of electronic devices. In practical applications, the software structure of electronic devices can include more than... Figure 11 More or fewer modules, for example, than Figure 11 More or fewer layers, or, a layer containing more than Figure 11 More or fewer modules, etc. Furthermore, Figure 11 The combination / connection relationships between modules can also be adjusted and modified.

[0172] The following text combines Figure 10 and Figure 11 This describes the process management method provided in the embodiments of this application.

[0173] The touch sensor 180K in the electronic device detects a touch operation. The kernel layer reports the input event to the upper layer (e.g., the application framework layer). The input event includes information about the touch operation, such as the operation type, operation time, and coordinate position. The application framework layer can determine the target of the touch operation; for example, if it determines that the touch operation is directed at the application icon of the first application, it reports it to the first application in the application layer. In response to the trigger operation, the first application sends a launch command to the AMS. After receiving the launch command from the first application, the AMS sends a process creation request to the incubator, requesting the incubator to create the main process of the first application. For details on the process of the incubator creating the main process of the first application, please refer to the previous section. Figure 3B or Figure 7B After the incubator creates the main process of the first application, the first application runs the main process. For example, the first application calls the display driver to display the homepage (or main interface) of the first application.

[0174] For example, after the first application displays its homepage (or main interface), the touch sensor 180K in the electronic device detects a touch operation again. The kernel layer reports the input event to the upper layer (e.g., the application framework layer). The application framework layer determines the object targeted by the touch operation, for example, if it determines that the touch operation is targeted at a certain control on the homepage of the first application, it reports it to the first application in the application layer. The main process of the first application responds to the trigger operation and creates a first process, which is used to implement the function / task corresponding to the control. Before creating the first process, the first application will determine whether a first condition is met, such as whether the current number of processes in the electronic device is less than a first threshold, whether the first application should be alive, whether the current number of processes of the first application is less than a second threshold, whether the first process is a preset process, etc. If the first condition is met, the first process is created. For the determination of the first condition, please refer to the previous text, which will not be repeated here.

[0175] For example, when a user exits the first application via multitasking, the touch sensor 180K in the electronic device detects a touch operation again. The kernel layer reports the input event to the upper layer (e.g., the application framework layer). The application framework layer determines the target of the touch operation; for example, if it determines that the touch operation is an exit operation for the first application, it sends an exit command for the first application to the Application Management System (AMS). The AMS sends the exit command for the first application to the incubator, which configures the survival flag of the first application to 0 to indicate that the first application should not be alive. Furthermore, the incubator can also destroy the process of the first application. For details on this, please refer to the previous section and will not be repeated here.

[0176] Figure 12 This is a schematic diagram of the structure of the electronic device 1200 provided in an embodiment of this application. The electronic device 1200 can be any of the terminal devices or servers listed above. Figure 12 As shown, the electronic device 1200 may include: one or more processors 1201; one or more memories 1202; a communication interface 1203; and one or more computer programs 1204. These devices can be connected via one or more communication buses 1205. The one or more computer programs 1204 are stored in the memory 1202 and configured to be executed by the one or more processors 1201. The one or more computer programs 1204 include instructions. For example, when the electronic device 1200 is the electronic device described above, the instructions can be used to perform relevant steps of the electronic device as in the corresponding embodiments above, such as executing... Figures 1 to 9 The relevant steps of the electronic device. The communication interface 1203 is used to enable communication between the electronic device 1200 and other devices, such as a transceiver.

[0177] In the embodiments provided above, the methods provided by the embodiments of this application are described from the perspective of an electronic device (e.g., a terminal device or a server) as the executing entity. To implement the functions of the methods provided in the embodiments of this application above, the electronic device may include hardware structures and / or software modules, implementing the above functions in the form of hardware structures, software modules, or a combination of hardware structures and software modules. Whether a particular function is executed in the form of hardware structures, software modules, or a combination of hardware structures and software modules depends on the specific application and design constraints of the technical solution.

[0178] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)). Where there is no conflict, the solutions in the above embodiments can be combined.

[0179] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0180] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0181] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0182] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0183] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A process management method, characterized in that, Applied to electronic devices, the method includes: Before creating the first process of the first application, it is determined whether the electronic device meets the first condition. The first condition includes: the first application is in a live state, the total number of processes currently running in the first application is less than the maximum number of processes of the first application, and the first process is at least one of the preset processes. The first application being in a live state includes the first application's main process being in a normal running state. If the electronic device meets the first condition, the first process is created; or, If the electronic device does not meet the first condition, the creation of the first process is prohibited.

2. The method according to claim 1, characterized in that, The first condition includes the first application being in an active state, and determining whether the electronic device meets the first condition includes: The system determines whether the first application is alive based on the application liveness flag in the process manager of the first application. The process manager is used to manage the processes of the first application.

3. The method according to claim 2, characterized in that, The method further includes: Upon detecting that the first application has started, the application's liveness flag is configured as a first flag, which is used to indicate that the first application is in a live state; Upon detecting that the first application has exited, the application's liveness flag is configured as a second flag, which indicates that the first application is not in a live state.

4. The method according to claim 1, characterized in that, The first condition includes that the total number of processes currently running in the first application is less than the maximum number of processes in the first application. Before determining whether the electronic device meets the first condition, the method further includes: The maximum number of processes of the first application is read from the process manager of the first application, which is used to manage the processes of the first application.

5. The method according to claim 4, characterized in that, Before reading the first threshold from the process manager of the first application, the method further includes: In response to the launch command of the first application, the maximum number of processes of the first application is obtained, and the maximum number of processes of the first application is added to the process manager of the first application.

6. The method according to any one of claims 1-5, characterized in that, The maximum number of processes for the first application satisfies one or more of the following: The maximum number of processes for the first application is pre-configured by the first application; or, The maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, The maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, The maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device.

7. The method according to claim 1, characterized in that, The first condition includes that the first process is a preset process, and determining whether the first condition is met includes: Based on the structure of the first process, determine whether the first process is a preset process, wherein the structure includes descriptive information of the first process.

8. The method according to claim 7, characterized in that, The step of determining whether the first process is a preset process based on the structure of the first process includes: If the structure of the first process contains a third marker, the first process is determined to be a preset process; If the structure of the first process does not contain a third marker, it is determined that the first process is not a preset process, wherein the third marker is a marker used to indicate a preset process.

9. The method according to any one of claims 1-8, characterized in that, The first process is a preset process, including one or more of the following: The first process is a child process corresponding to the main process of the first application; or, The first process is a process used to log exceptions; or, The first process is a system service process.

10. The method according to any one of claims 1-9, characterized in that, The first process is a preset process, including: The first process is the dfx process, which is used to record exception information.

11. The method according to any one of claims 1-10, characterized in that, The first condition includes the first process being a preset process. If the first condition is met, the first process is created, including: If the first condition is met, and it is determined that the total number of preset processes currently running in the first application is less than the upper limit of the preset number of processes of the first application, the first process is created.

12. The method according to claim 11, characterized in that, The preset maximum number of processes for the first application satisfies one or more of the following: The preset maximum number of processes for the first application is pre-configured by the first application; or, The maximum number of processes for the first application is pre-configured by the operating system of the electronic device; or, The preset maximum number of processes for the first application is determined based on the current operating load of the electronic device; or, The maximum number of processes for the first application is determined based on the current remaining battery power of the electronic device.

13. The method according to any one of claims 1-12, characterized in that, Before creating the first process, it is determined whether the electronic device meets a first condition, including: The incubation function is invoked, which creates the first process via a system call; Before adding the first process to the control group of the first application, it is determined whether the electronic device meets the first condition; If the first condition is met, create a first process, including: If the first condition is met, the first process is added to the control group of the first application; If the first condition is not met, the creation of the first process shall be prohibited, including: If the first condition is not met, adding the first process to the control group of the first application is prohibited; wherein the control group of the first application includes one or more processes, which are used to implement the functions of the first application.

14. An electronic device, characterized in that, include: Processor, memory, and one or more programs; The one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the processor, cause the electronic device to perform the steps of the method as described in any one of claims 1-13.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 13.

16. A computer program product, characterized in that, Includes a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 13.