Process management method, electronic device and readable storage medium
By introducing a low-level foreground process group into electronic devices and overloading some foreground processes, the problem of insufficient processor resources for foreground applications when load is high is solved, and the effect of avoiding application lag and slow system response is achieved.
Patent Information
- Application Number
- CN202310793375.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2043-06-29
AI Technical Summary
Under high load, foreground applications do not easily obtain more processor resources, resulting in application lag and slow system response.
By introducing low-level foreground process groups into electronic devices and reloading some foreground processes from foreground process groups to low-level foreground process groups, fewer processor resources are allocated to avoid these processes preempting processor resources with foreground applications.
It effectively avoids the problems of slow system response and application lag, and improves the stability of the system.
Smart Images

Figure CN117707719B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a process management method, an electronic device, and a readable storage medium. Background Art
[0002] A process is a program running on a certain data set in an electronic device, and is the basic unit for resource allocation and scheduling in the system. An application can usually include one or more processes. During the operation of the application, as the running state of the application changes, the importance level of some processes of the application may decrease. Since these processes are still in the running state, they may occupy the processor resources required by the foreground application. Especially under high load conditions, it is not easy for the foreground application to obtain more processor resources, resulting in application freezes and slow system response. Summary of the invention
[0003] The present application provides a process management method, an electronic device and a readable storage medium, which can solve the problem in the related art that the foreground application cannot easily obtain more processor resources under high load, resulting in application freeze and slow system response. The technical solution is as follows:
[0004] In a first aspect, a process management method is provided, which is applied to an electronic device, and the method includes:
[0005] Starting a first application in the electronic device;
[0006] During the operation of the first application, in the process of calculating the priority of the process of the first application, the grouping status of the process of the first application is updated, so that the grouping status of some processes of the first application is overloaded from the foreground process group to the low-level foreground process group, and some of the processes are currently not executing user-perceivable events, wherein the processor resources available to the low-level foreground process group are less than the processor resources available to the foreground process group and greater than the processor resources available to the background process group.
[0007] In this way, by adding a low-level foreground process group, and then grouping some processes in the foreground process group into the low-level foreground process group and allocating fewer processor resources to it, it is possible to avoid these processes and foreground applications from competing for processor resources, thereby avoiding problems such as slow system response and application freezes.
[0008] As an example of the present application, during the running of the first application, in the process of calculating the priority of the process of the first application, updating the grouping state of the process of the first application includes:
[0009] During the running of the first application, in the process of calculating the priority of the process of the first application, determining the grouping state of the current process to be grouped of the first application;
[0010] In the case where the current process group is the foreground process group, determining whether the current process can be overloaded from the foreground process group to the low-level foreground process group;
[0011] In the case where the current process can be reloaded as the low-level foreground process group, querying whether the first application is executing a user-perceivable event;
[0012] If the first application does not execute a user-perceivable event, the grouping state of the current process is updated to the low-level foreground process group.
[0013] In this way, without modifying the calculation logic of Android's native process group grouping rules, after the current process is grouped into the foreground process group, it is further determined whether the current process can be overloaded into a low-level foreground process group, and the grouping status of the current process is updated when it is determined that it can be overloaded. While reducing the modification of the native logic, it can avoid some unimportant processes and the foreground process from occupying processor resources, thereby improving the stability of the system.
[0014] As an example of the present application, in the case where the current process is grouped as the foreground process group, determining whether the current process can be overloaded by the foreground process group to the low-level foreground process group includes:
[0015] In the case where the current process is a process that is receiving a foreground broadcast, or is a process that is providing services to a client process of a foreground process group, if the current process is a third-party application process, and the current process is not a TOP application process or a process associated with a TOP application process, then according to the level of the client process associated with the current process, it is determined whether the current process can be overloaded by the foreground process group to the low-level foreground process group, wherein the client process associated with the current process is a client process that sends a foreground broadcast to the current process, or a client process that requests the foreground process to provide services and belongs to the foreground process group;
[0016] In the case where it is determined according to the level of the client process associated with the current process that the current process can be reloaded into the low-level foreground process group, determining whether the current process can be reloaded into the low-level foreground process group according to the process state of the current process;
[0017] In the case where it is determined according to the process state of the current process that the current process can be overloaded into the low-level foreground process group, it is determined whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider.
[0018] In this way, when the current process is grouped into the foreground process group according to the native process grouping rules of Android, it is further judged whether the current process can be overloaded into a low-level foreground process group according to the level of the client process associated with the current process, the process status of the current process and the grouping status of the client process associated with the current process, thereby effectively screening out unimportant processes and overloading them into a low-level foreground process group, thereby preventing unimportant processes from occupying the processor resources of the foreground application.
[0019] As an example of the present application, the current process is a process that is receiving a foreground broadcast;
[0020] The step of determining, according to the level of the client process associated with the current process, whether the current process can be overloaded from the foreground process group to the low-level foreground process group comprises:
[0021] If the level of the client process associated with the current process satisfies the first overload condition, and the foreground broadcast queue of the current process includes only the three-party foreground broadcast queue, it is determined that the current process can be overloaded from the foreground process group to the low-level foreground process group, and the foreground broadcast queue is used to store all foreground broadcasts received by the current process. The first overload condition includes:
[0022] The client processes that are sending foreground broadcasts to the current process are all third-party application processes, and the client processes that are sending foreground broadcasts to the current process do not include resident processes, and are not TOP application processes or processes associated with TOP application processes.
[0023] In this way, when the importance of the client process associated with the current process is low, it is determined that the current process can be reloaded as a low-level foreground process group, so that unimportant processes can be screened out.
[0024] As an example of the present application, the current process is a process that is providing services to a client process of the foreground process group;
[0025] The step of determining, according to the level of the client process associated with the current process, whether the current process can be overloaded from the foreground process group to the low-level foreground process group comprises:
[0026] In the case where the level of the client process associated with the current process satisfies the second overloading condition, determining that the current process can be overloaded from the foreground process group to the low-level foreground process group, wherein the second overloading condition includes:
[0027] All client processes that request the current process to provide services are third-party application processes, and all client processes do not include resident processes, and all client processes are not TOP application processes and processes associated with TOP application processes.
[0028] In this way, when the importance of the client process associated with the current process is low, it is determined that the current process can be reloaded as a low-level foreground process group, so that unimportant processes can be screened out.
[0029] As an example of the present application, in the case where it is determined according to the level of the client process associated with the current process that the current process can be reloaded as the low-level foreground process group, determining whether the current process can be reloaded as the low-level foreground process group according to the process state of the current process includes:
[0030] When the current process includes a floating window, and / or the current process includes a foreground service and a floating window, and / or the current process includes an activity in a visible state or a paused state, the current process is determined as being unable to be reloaded as the low-level foreground process group.
[0031] In this way, when the process state of the current process is perceptible to the user, it is determined that the current process cannot be reloaded as a low-level foreground process group to avoid the current process being unable to respond to the user's touch operation in a timely manner due to resource compression, thereby avoiding giving the user a poor experience.
[0032] As an example of the present application, the current process is a process that provides a service or content provider;
[0033] In the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider, comprises:
[0034] In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, if the number of client processes requesting the current process to provide a service or content provider is one, then when the client process requesting the current process to provide a service or content provider can be reloaded as the foreground process group, it is determined that the current process can be reloaded as the low-level foreground process group;
[0035] If there are multiple client processes requesting the current process to provide services or content providers, then when multiple client processes can be reloaded into the foreground process group, it is determined that the current process can be reloaded into the low-level foreground process group.
[0036] In this way, according to the grouping status of the client processes associated with the current process, it is determined whether the current process can be reloaded as a low-level foreground process group, so that unimportant processes can be effectively screened out.
[0037] As an example of the present application, the current process is a process that provides services and content providers;
[0038] In the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider, comprises:
[0039] In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, determining whether the current process can be reloaded as the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service;
[0040] When it is determined that the current process can be reloaded as the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service, traverse the client process requesting the current process to provide a content provider;
[0041] According to the grouping status of the traversed client processes, it is determined whether the current process can be reloaded as the low-level foreground process group.
[0042] In this way, since the native calculation logic of Android first calculates the service association and then calculates the provider association, in the embodiment of the present application, without modifying the calculation logic, determining whether the current process can be grouped into a low-level foreground process group can reduce the modification of the native logic.
[0043] As an example of the present application, in the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider includes:
[0044] In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, if the client processes requesting the current process to provide services and / or requesting the current process to provide content providers only include desktop applications, and the desktop application is not currently a TOP application process, it is determined that the current process can be reloaded as the low-level foreground process group;
[0045] If the client processes requesting the current process to provide services and / or requesting the current process to provide content providers include desktop applications and other client processes, then when, except for the desktop application, the other client processes can be reloaded into the low-level foreground process group, it is determined that the current process can be reloaded into the low-level foreground process group.
[0046] In this way, when the first application exits the desktop, the grouping state of the first application's process is reloaded to a low-level foreground process group to prevent the first application from competing with the desktop application for processor resources, thereby avoiding frame loss and the like during the playback of the desktop exit animation.
[0047] As an example of the present application, the electronic device includes a priority calculation module, a priority application module and a perception module, wherein the perception module is used to monitor whether a task executed by an application in the electronic device is perceptible to a user;
[0048] The determining, during the running of the first application, in the process of calculating the priority of the process of the first application, the grouping state of the current process to be grouped of the first application includes:
[0049] During the operation of the first application, in the process of calculating the priority of the process of the first application, the priority calculation module determines the grouping state of the current process;
[0050] In the case where the current process group is the foreground process group, determining whether the current process can be overloaded from the foreground process group to the low-level foreground process group includes:
[0051] In the case where the current process is grouped as the foreground process group, the priority calculation module determines whether the current process can be overloaded as the low-level foreground process group;
[0052] In the case of determining that the current process can be reloaded as the low-level foreground process group, the priority calculation module sends the determination result to the priority application module;
[0053] The querying whether the first application is executing a user-perceivable event when the current process can be overloaded as the low-level foreground process group includes:
[0054] After receiving the judgment result, the priority application module determines whether the first application is executing a user-perceivable event according to application status indication information, wherein the application status indication information is used to indicate the working status of the first application, and the application status indication information is sent by the perception module after monitoring a change in the working status of the first application;
[0055] If the first application does not execute the user-perceivable event, updating the grouping state of the current process to the low-level foreground process group includes:
[0056] In a case where it is determined according to the application status indication information that the current process does not execute a user-perceivable event, the priority application module updates the grouping status of the current process to the low-level foreground process group.
[0057] In this way, when the perception module detects that the working status of the first application has changed, it notifies the priority application module, so that the priority application module can update the grouping status of the current process based on the grouping calculation result of the current process by the priority calculation module and the working status of the first application, and when it is determined that the events executed by the current process are imperceptible to the user, to avoid affecting the user experience of the electronic device after re-grouping.
[0058] In a second aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the process management method described in the first aspect when executing the computer program.
[0059] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the process management method described in the first aspect.
[0060] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the process management method described in the first aspect.
[0061] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 is a block diagram of a software system of an electronic device according to an exemplary embodiment;
[0063] Figure 2 is a flowchart of a process management method according to an exemplary embodiment;
[0064] Figure 3 It is a schematic diagram of a framework of a method for managing a process according to an exemplary embodiment;
[0065] Figure 4 is a schematic diagram showing a visible Activity according to an exemplary embodiment;
[0066] Figure 5 is a schematic diagram of an Activity in a paused state according to an exemplary embodiment;
[0067] Figure 6 is a schematic diagram showing the relationship between a process and a client process according to an exemplary embodiment;
[0068] Figure 7 is a schematic diagram showing a running state of a process according to an exemplary embodiment;
[0069] Figure 8 is a schematic diagram of a framework of a method for managing a process according to another exemplary embodiment;
[0070] Fig. 9 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0071] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0072] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.
[0073] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0074] To facilitate understanding, the terms involved in the embodiments of the present application are first introduced.
[0075] Core binding: is to set the affinity between a process and a core of a processor (central processing unit, CPU). After setting, the scheduler will schedule the process to run on the bound core.
[0076] Application process: generally refers to the process in the application. According to the priority, the application process can generally be divided into the foreground process (also known as the TOP application process), visible process, service process and background process. The foreground process is the process necessary for the user's current operation. It provides an interface that can be seen by the user at the forefront of the screen and has focus, that is, the user can interact with it, such as the user can click a button on the interface. The visible process is a process that does not have any foreground components but still affects what the user sees on the screen. The service process is not directly related to the content seen by the user, but usually performs some operations that the user cares about (such as downloading data from the network). The background process is a process that has no impact on the user experience. The system may terminate the background process at any time to reclaim memory for the foreground process, visible process and service process. In the case that the application process is a service process, the process that requests the application process to provide services is called the client process of the application process. In this case, the client process can be said to be associated with the application process. Among them, the client process may be a system process or a third-party application process.
[0077] Instrumentation: It is a test application that can be used for automated script testing. Through instrumentation, you can simulate events such as key presses, releases, screen clicks, and scrolling.
[0078] Activity: It is one of the four major components of the Android system. It is a carrier of an interface, used to display a visual interface to the user, and can receive input information processed by the user, so as to interact with the user. Activity can be composed of various controls. In an example, Activity can be used to open a browser, open a text message interface, open an album interface, open a dial interface, and so on. The life cycle of Activity includes three states, namely resumed (activated) state, paused (paused) state, and stopped (stopped) state. The resumed state means that the Activity is at the forefront of the screen. At this time, the Activity is fully displayed in the user interface, can obtain focus, and can respond to various touch operations of the user. The paused state means that the Activity is partially blocked by other Activities, that is, it is still partially visible. In the case of the paused state, the Activity will still update the interface, but it cannot obtain focus, that is, it will not respond to the user's touch operation. The stopped state means that the current Activity is completely blocked by another Activity. The stopped state does not mean that the Activity stops running, but can be understood as running in the background.
[0079] Content provider: can be used to support multiple applications to store and read data, equivalent to a database.
[0080] Service: It is one of the four major components of the Android system and is used to handle background operations associated with applications. It is usually used to perform tasks that do not require user interaction and require long-term operation. The operation of Service does not depend on any user interface. Even if the application is switched to the background and the user opens another application, the Service can still run normally.
[0081] Toast: A visual component that usually appears from the bottom of the screen in the form of a window and disappears automatically after being displayed on the screen for a period of time.
[0082] In some embodiments, in the process of managing the process of the electronic device, the processes are usually managed in groups. For example, please refer to Table 1, and the processes are grouped according to Rule 1 (i.e., the Android native process group grouping rule), that is, the processes are divided into a foreground process group (or foregroup group, abbreviated as fg), a background process group (or backgroup group, abbreviated as bg), and a TOP process group. Among them, the priority of the TOP process group is higher than the priority of the foreground process group, and the priority of the foreground process group is higher than the priority of the background process group, so when allocating resources, the available processor resources allocated to the TOP process group are generally greater than the available processor resources of the foreground process group, and the available processor resources allocated to the foreground process group are greater than the available processor resources of the background process group.
[0083] Table 1
[0084] Rule One Group Description Foreground process (fg) Resident process, including Activity in visible state, etc. Background process group (bg) Background application processes TOP process group (top-app) The foreground focus application process (i.e. the TOP application process)
[0085] However, the division of the foreground process group in the above process grouping method is not fine enough, and when the load is high, it is not easy for the foreground application to obtain processor resources, which will lead to problems such as slow system response and application jamming. To this end, an embodiment of the present application provides a process management method, which further refines the foreground process group so that the processor resources that can be used by some unimportant processes in the foreground process group are less than the processor resources that can be used by more important processes, thereby effectively solving the problems of slow system response and application jamming.
[0086] Before introducing the process management method provided by the embodiment of the present application, the execution subject of the embodiment of the present application is first introduced. The process management method provided by the embodiment of the application can be applied to electronic devices, which can be but not limited to mobile phones, sports cameras (GoPro), digital cameras, tablet computers, desktops, laptops, handheld computers, notebook computers, vehicle-mounted devices, ultra-mobile personal computers (ultra-mobile personal computers, UMPC), netbooks, cellular phones, personal digital assistants (personal digital assistants, PDA), augmented reality (augmentedreality, AR) / virtual reality (virtual reality, VR) devices, etc., and the embodiment of the present application does not limit this.
[0087] Please refer to Figure 1 , Figure 1 is a block diagram of a software system of an electronic device according to an exemplary embodiment. Figure 1 The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system layer, and the kernel layer.
[0088] The application layer can include a series of application packages. Figure 1 As shown, the application package may include multimedia, navigation, health, card, recorder, video, screen recording, camera, gallery, call, Bluetooth, music, video, short message and other applications.
[0089] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. As an example of the present application, the application framework layer includes a perception module and an activity management service (AMS) module. Among them, the perception module can be used to perceive the working status of the application, and report to the AMS module when it is determined that the working status of the application has changed. The AMS module is an important part of the operating system and is mainly responsible for the scheduling and management of processes. For example, the AMS module can be used to uniformly schedule the activities of various applications, and the AMS module can also be used for memory management, etc. In one example, Figure 1As shown, the AMS module includes a priority calculation module, a priority application module and a group setting module. The priority calculation module is used to calculate the priority of the current process when the life cycle of the process changes, that is, to calculate the ADJ of the process, and to determine whether the process can be reloaded as a low-level foreground process group (referred to as low-fg). For example, it can be determined whether the process can be reloaded as low-fg according to the preset low-fg reloading rules, wherein low-fg is a group separated from the foreground process group, and its level is higher than the background process group and lower than the foreground process group. Optionally, the priority calculation module can also determine whether the process can be reloaded as low-fg according to the preset low-fg reloading rules, combined with the working status of the application reported by the perception module. The priority application module is used to manage the process according to the ADJ of the process calculated by the priority calculation module, such as determining the order of killing the process, etc. The priority application module is also used to update the grouping of the process. The setting module is used to set the grouping of the process.
[0090] In addition, the application framework layer can also include window managers, content providers, view systems, phone managers, resource managers, notification managers, etc. ( Figure 1 (not shown in the figure). The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make these data accessible to applications. These data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the display interface of the application. The display interface can be composed of one or more views, for example, including a view for displaying a text message notification icon, including a view for displaying text, and including a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices, such as management of call status (including connected, hung up, etc.). The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of an icon or scroll bar text, such as a notification of an application running in the background. The notification manager can also be a notification that appears on the screen in the form of a dialog window, such as a text message in the status bar, a reminder sound, a vibration of an electronic device, a flashing indicator light, etc.
[0091] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library contains two parts: one is the function that the Java language needs to call, and the other is the Android core library. As an example of this application, Figure 1 As shown, the core library includes a scheduling module (such as the scheduler described above), which can allocate processor resources to processes according to the grouping of processes set by the AMS module, and perform scheduling according to the allocated processor resources, such as binding cores. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection and other functions.
[0092] The system library can include multiple functional modules, such as: surface manager, media library, 3D graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL), etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0093] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0094] The following is an example of the software and hardware workflow of the electronic device in conjunction with capturing a photo scene.
[0095] When the touch sensor receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into raw input events (including touch coordinates, timestamp of the touch operation, and other information). The raw input events are stored in the kernel layer. The application framework layer obtains the raw input events from the kernel layer and identifies the controls corresponding to the raw input events. For example, if the touch operation is a single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then calls the kernel layer to start the camera driver to capture static images or videos through the camera.
[0096] exist Figure 1Based on the electronic device shown in FIG. 1 , the process management method provided by the embodiment of the present application is introduced below. Figure 2 , Figure 2 This is a flowchart of a process management method according to an exemplary embodiment. As an example but not a limitation, the method is applied to the above electronic device, and the electronic device is implemented by the interaction of the above multiple modules. The method may include some or all of the following contents:
[0097] Step 201: The AMS module starts the first application.
[0098] The first application may be any application in the electronic device. For example, the first application may be a system application or a third-party application. In the case where the first application is a third-party application, the AMS module starts the first application in response to the user's start-up operation on the first application, that is, the first application is triggered to start by the user.
[0099] Step 202: During the operation of the first application, the perception module reports the working status of the first application to the priority application module.
[0100] The working state of the first application is related to the function of the first application. For example, if the first application is a multimedia application, the working state of the first application includes playing videos, playing music, switching to the background, etc. For another example, if the first application is a navigation application, the working state of the first application includes navigating, switching to the background, and only displaying the application interface.
[0101] In one possible case, the first application is a third-party application. In this case, the working status of the first application is perceptible to the user. For example, please refer to Table 2. Table 2 shows several user-perceptible working statuses of applications according to an exemplary embodiment. For instance, taking the first application as a multimedia application, when the multimedia application is in a state of playing music or playing videos, the user can perceive it. Taking the first application as a navigation application, when the navigation application is in a state of location navigation, the user can also perceive it.
[0102] Table 2
[0103]
[0104] As an example of this application, please refer to Figure 3 When the perception module detects that the working state of the first application has changed, it can report the changed working state to the priority application module. For example, the application state indication information can be sent to the priority application module, and the application state indication information is used to indicate the application state of the first application.
[0105] It should be noted that the embodiment of the present application is described by taking the example that the perception module reports the changed working state to the priority application module when detecting that the working state of the first application has changed. In another example, the perception module can also report periodically, and the periodic duration is relatively short, which can be understood as real-time reporting, and the embodiment of the present application is not limited to this.
[0106] It should also be noted that the application status that the perception module shown in Table 2 above can perceive is only exemplary. In another example, the perception module can also perceive the application status of more types of applications in the electronic device, which is not limited in the embodiments of the present application.
[0107] Step 203: During the ADJ calculation process, the priority calculation module determines whether the current process of the first application to be grouped can be grouped as low-fg.
[0108] Among them, low-fg is a newly added process group in the embodiment of the present application, which can be understood as low-fg being a process group separated from the foreground process group. As described above, the level of low-fg is higher than the level of the background process group and the level of low-fg is lower than the level of the foreground process group, so the available processor resources allocated by the electronic device to low-fg are generally less than the available processor resources allocated to the foreground process group, and the available processor resources allocated to low-fg are more than the available processor resources allocated to the background process group. As an example, please refer to Table 3, taking the processor of the electronic device including 8 cores as an example, the available processor resources allocated to low-fg can include 0-5 cores, and the available processor resources allocated to the foreground process group can include 0-7 cores, that is, the process grouped as low-fg can only be scheduled to run on 0-5 cores, and can no longer be scheduled to run on 6 cores and 7 cores. The preemptive ability of the process grouped as low-fg to processor resources is also lower than the preemptive ability of the process group of the foreground process to processor resources.
[0109] Table 3
[0110] Grouping Binding Core Original group binding core low-fg 0-5 0-7 fg 0-7 0-7
[0111] During the operation of the first application, when the life cycle of the process of the first application changes, such as when the first application switches from the foreground to the background, or from the background to the foreground, the priority calculation module calculates the ADJ of the process of the first application, that is, executes the computeOomAdj operation. In the process of computeOomAdj, the priority calculation module can determine whether the current process to be grouped of the first application can be grouped as low-fg.
[0112] As an example of the present application, the specific implementation of the priority calculation module determining whether the current process to be grouped of the first application can be grouped as low-fg may include: in the computeOomAdj process, the priority calculation module determines the grouping state of the current process according to the Android native process grouping rule. When the current process is grouped as a foreground process group, further determining whether the current process can be overloaded by the foreground process group to low-fg.
[0113] That is, in order to minimize the modification of the implementation logic of the Android native process group grouping rules, in the process of determining the grouping status of the current process to be grouped of the first application, the priority calculation module can first group the current process according to the Android native process group grouping rules. On this basis, the priority calculation module further determines whether the current process can be overloaded to low-fg according to the preset low-fg overload rules.
[0114] Determining the grouping status of the current process to be grouped of the first application generally includes multiple stages. As an example of the present application, after the current process is grouped according to the Android native process grouping rule, it can be further determined whether the current process can be reloaded to low-fg based on the current grouping result at each stage. Specifically, it can include the following stages:
[0115] In the first stage: when the current process is a process that is receiving a foreground broadcast or a process that is providing services to a client process of the foreground process group, if the current process is a third-party application process and the current process is not a TOP application process or a process associated with the TOP application process, then based on the level of the client process associated with the current process, determine whether the current process can be overloaded from the foreground process group to a low-level foreground process group, wherein the client process associated with the current process is a client process that sends a foreground broadcast to the current process or a client process that requests the foreground process to provide services and belongs to the foreground process group.
[0116] When grouping according to the Android native process group grouping rules, the resident process and the single process running Activity, service (service), broadcast or instrumentation are usually calculated as fg. After the calculation of the single process is completed, the grouping result of the current process will be further grouped and reloaded based on other attributes of the current process, so that the grouping result of the current process may change, for example, the current process may be promoted from the background process group to the foreground process group. In an example, please refer to Table 4. When grouping according to the Android native process group grouping rules, a group reloading rule is that if the ADJ of the current process is less than 0 (indicating that it is a resident process) or the current process is a process running instrumentation, the grouping state of the current process is reloaded to fg. In addition, when the current process is a process receiving a broadcast, if the current process receives a foreground broadcast, that is, a broadcast sent by the foreground process, the grouping state of the current process is reloaded to fg, and if the current process receives a background broadcast, that is, a broadcast sent by the background process, the grouping state of the current process is reloaded to bg. In addition, when the current process is a process that is providing services, if the process requesting the current process to provide services is a process of the foreground process group, the grouping status of the current process is overloaded to fg; if the process requesting the current process to provide services is a process of the background process group, the grouping status of the current process is overloaded to bg.
[0117] As an example of the present application, based on the above grouping, if the current process is a process that is receiving a broadcast or providing a service, after the current process is grouped into fg according to the Android native process grouping rules, it is possible to further determine whether the current process can be reloaded from fg to low-fg. Specifically, there are two possible situations:
[0118] In the first case, the current process is a process that is receiving foreground broadcasts, that is, the current process is grouped as fg according to the Android native process grouping rules. In this case, if the current process is a third-party application process, and the current process is not a TOP application process or a process associated with a TOP application process, if the level of the client process associated with the current process meets the first overload condition, and the foreground broadcast queue of the current process only includes a three-party foreground broadcast queue, then it is determined that the current process can be overloaded from fg to low-fg, wherein the foreground broadcast queue is used to store all foreground broadcasts received by the current process, and the first overload condition includes: the client processes that are sending foreground broadcasts to the current process are all third-party application processes, and the client processes that are sending foreground broadcasts to the current process do not include resident processes, and are not TOP application processes or processes associated with TOP application processes.
[0119] That is, in the first stage, see Table 4, when the current process is a process that is receiving a broadcast, and the current process is overloaded to fg according to the Android native process group grouping rule (that is, the current process is receiving a foreground broadcast), if the current process meets the following three conditions, it is determined that the current process can be overloaded to low-fg, where the three conditions include: 1. The current process is a third-party application process, and the current process is not a TOP application process, nor a process associated with a TOP application process; 2. The foreground broadcast queue of the current process only includes a three-party foreground broadcast queue, that is, it does not include a system foreground broadcast queue, where the three-party foreground broadcast queue is used to store foreground broadcasts sent by third-party application processes, and the system foreground broadcast queue is used to store foreground broadcasts sent by system processes; 3. The client processes (that is, broadcast senders) that are sending foreground broadcasts to the current process are all third-party application processes, and the broadcast senders do not include resident processes, and the broadcast senders are not TOP application processes and processes associated with TOP application processes.
[0120] It should be noted that, when the current process is a third-party application process, and the current process is not a TOP application process, nor is it a process associated with a TOP application process, it means that the level of the current process itself is relatively low. In addition, if the foreground broadcast queue of the current process only includes the third-party foreground broadcast queue, and does not include the system foreground broadcast queue, it means that the foreground broadcasts to be processed in the foreground broadcast queue are not important broadcasts. At this time, it can be said that the level of the sender of the foreground broadcast in the foreground broadcast queue is also relatively low. In addition, if all client processes that are sending foreground broadcasts to the current process are third-party application processes, and all client processes do not include resident processes, and all client processes are not TOP application processes, nor are they processes associated with TOP application processes, it means that the level of the broadcast sender of the foreground broadcast that the current process is receiving is also relatively low, which means that the importance of the foreground broadcast that the current process is receiving is relatively low. Therefore, if the above three conditions are met, it can be determined that the current process can be grouped as low-fg.
[0121] In the second case, when the current process is a process that is providing services to the client process of the foreground process group, if the current process is a third-party application process, and the current process is not a TOP application process or a process associated with the TOP application process, if the level of the client process associated with the current process meets the second overloading condition, it is determined that the current process can be overloaded from the foreground process group to a low-level foreground process group, wherein the second overloading condition includes: all client processes requesting the current process to provide services are third-party application processes, and all client processes do not contain resident processes, and all client processes are not TOP application processes or processes associated with the TOP application process.
[0122] That is, in the first stage, please continue to refer to Table 4. When the current process is a process that is providing services, and the current process is overloaded to fg according to the Android native process grouping rules (that is, the current process is providing services to the client process of the foreground process group), if the current process meets the following two conditions, it is determined that the current process can be overloaded to low-fg, where the two conditions include: 1. The current process is a third-party application process, and the current process is not a TOP application process, nor a process associated with a TOP application process; 2. Traverse all client processes that request the current process to provide services, if all traversed client processes are third-party application processes, and all client processes do not contain resident processes, and all clients are not TOP application processes, nor are they processes associated with TOP application processes. These client processes may request the current process to provide services through the start method or the bind method.
[0123] It should be noted that if the current process is a third-party application process, and the current process is not a TOP application process, nor is it a process associated with a TOP application process, it means that the level of the current process itself is relatively low. In addition, if all client processes requesting services from the current process are third-party application processes, and these client processes do not include resident processes, and these client processes are not TOP application processes, nor are they processes associated with a TOP application process, it means that the levels of the various client processes requesting services are also relatively low, and thus the importance of the services requested by these client processes is also relatively low. Therefore, if the above two conditions are met, it can be determined that the current process can be overloaded as low-fg.
[0124] In one example, when the current process is a process that is receiving a broadcast or a process that is providing a service, the client process can carry a client identifier when sending a broadcast to the current process or requesting the current process to provide a service. The client identifier is used to indicate whether the corresponding client process is a third-party application process or a system process. In this way, in the above-mentioned process of determining the level of the client process, the priority calculation module can determine the level of the corresponding client process based on the client identifier associated with the current process, that is, determine whether the corresponding client process is a third-party application process.
[0125] Table 4
[0126]
[0127]
[0128] It should be noted that since resident processes and processes running instrumentation are usually more important processes in electronic devices, the embodiments of the present application do not overload such processes as low-fg. That is, if the current process is a resident process or a process running instrumentation, the grouping state after grouping according to the Android native process grouping rules is maintained at this stage.
[0129] In the second stage: when it is determined that the current process can be reloaded into a low-level foreground process group according to the level of the client process associated with the current process, it is determined whether the current process can be reloaded into a low-level foreground process group according to the process state of the current process.
[0130] Please refer to Table 5. In this process, when the scene is reloaded according to the Android native process grouping rules, if the current process contains a foreground service, the current process is reloaded to bg by default, where the foreground service refers to the corresponding window included in the notification bar. For example, when the first application plays music in the background, the notification bar includes a window for indicating that the first application is playing music in the background. At this time, the process of the first application contains a foreground service. In addition, if the current process contains overlayui, the current process will also be reloaded to fg. If the current process is an import process or a toast process, the current process is reloaded to fg, where the import process is usually used to restore some data to the database. If the current process contains a visible Activity or a paused Activity, the current process will also be reloaded to fg.
[0131] As an example of this application, if the current process contains a foreground service, has an overlayui, or contains a visible Activity or a suspended Activity, the events executed by the current process are perceptible to the user, and the level of the current process is high. If it is determined in the first stage that the current process can be reloaded as low-fg, then the current process needs to be re-marked as fg in this process, that is, the grouping state of the current process is restored. Specifically, please refer to Table 5, which may include at least one of the following situations:
[0132] In the first case, when the current process includes a foreground service and an overlayui (floating window), the group of the current process is determined to be fg.
[0133] Please refer to Table 5. In the second stage, if it is determined that the current process contains a foreground service, the current process will be grouped as bg when calculated according to the Android native process grouping rules. In this way, during subsequent resource allocation and scheduling, the current process can only be allocated fewer processor resources. In one possible case, the overlayui cannot slide or the sliding is stuck due to resource compression. Therefore, in order to avoid affecting the user experience, in this case, the current process is grouped as fg in the second stage, that is, the current process is determined to be non-reloadable as low-fg.
[0134] In the second case, when the current process contains overlayui, if it is determined in the first stage that the current process can be grouped as low-fg, the grouping of the current process is restored to fg.
[0135] Similarly, when the current process contains overlayui, it means that the events executed by the current process are perceptible to the user. In this case, if it is determined in the first stage that the current process can be overloaded to low-fg, in order not to affect the user experience, the grouping of the current process is restored to fg in the second stage, that is, it is determined that the current process cannot be overloaded to low-fg.
[0136] In the third case, when the current process contains a visible Activity or a paused Activity, if it is determined in the first stage that the current process can be grouped as low-fg, the grouping of the current process is restored to fg.
[0137] If the current process includes a visible Activity, it means that the current process affects what the user sees on the screen. For example, see Figure 4 , Figure 4 40 in the figure is a schematic diagram of a visible Activity. If it is determined in the first stage that the current process can be grouped as low-fg, then during subsequent resource allocation and scheduling, the current process can only be allocated with fewer processor resources. In one possible case, the visible Activity cannot be slid or the sliding is stuck due to resource compression. Therefore, in order to avoid affecting the user experience, in the second stage, the grouping state of the current process is restored to fg, that is, it is determined that the current process cannot be reloaded as low-fg.
[0138] Similarly, if the current process includes a paused Activity, it means that the current process will affect what the user sees on the screen. For example, see Figure 5 , Figure 551 in the figure is a schematic diagram of a paused Activity, in which Activity 51 is partially blocked by another Activity 50. Although the paused Activity does not have focus, it is perceptible to the user, and the user may switch the paused Activity to a non-pause Activity at any time. Therefore, if it is determined in the first stage that the current process can be grouped as low-fg, then in the second stage, the grouping state of the current process is restored to fg, that is, it is determined that the current process cannot be reloaded as low-fg to avoid affecting the user experience.
[0139] Table 5
[0140]
[0141] It should be noted that if the current process is an import process or a process that contains a toast, the importance of the current process is relatively low. For example, when the current process is an import process, the current process generally takes a long time, so the real-time requirement is relatively low. In addition, when the current process is a process that pops up a toast, the popped toast may be an unimportant window such as an advertisement. Therefore, in an optional implementation, for this scenario, even if the current process is reloaded to low-fg, it may not be restored to fg.
[0142] In the third stage: after determining that the current process can be grouped into a low-level foreground process group based on the process status of the current process, determine whether the current process can be grouped into a low-level foreground process group based on the grouping status of each client process of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider.
[0143] In one possible case, the current process is a process that provides a service. In another possible case, the current process is a process that provides a content provider. In another possible case, the current process is a process that provides both services and content providers. In any of the above possible cases, the current process may be called by one client process or by multiple client processes at the same time. For example, Figure 6As shown, the first application includes process 1, process 2, process 3, process 4, process 5, process 6 and process 7. Assume that process 1 is the client process of process 2, process 2 is the client process of process 3, process 4 and process 5, process 6 is the client process of process 5, and process 7 is the client process of process 5. If the current process is process 5, the current process is called by process 2, process 6 and process 7 at the same time, that is, there are 3 client processes associated with the current process. In this case, the grouping state of the current process can be improved by the grouping state of at least one client process associated with it.
[0144] For the first possible situation, that is, when the current process is a process that provides services, please refer to Table 6. In the native process grouping rules, if the client process that requests the current process to provide services includes a resident process, that is, the client process associated with the current process includes a resident process, then the current process can be directly promoted to fg, that is, the current process is overloaded to fg. In the case that the client process that requests the current process to provide services does not contain the BIND_WAIVE_PRIORITY, BIND_NOT_FOREGROUND, and BIND_IMPORTANT_BACKGROUND flags, the current process is promoted to fg or promoted to be consistent with the process group of the associated client process, wherein, when the client process associated with the current process contains the BIND_WAIVE_PRIORITY flag, it means giving up the priority of the current process; when the associated client process contains the BIND_NOT_FOREGROUND flag, it means not allowing the current process to be promoted to the foreground scheduling priority; when the associated client process contains the BIND_IMPORTANT_BACKGROUND flag, the current process is treated as the current background task. In addition, when the client process requesting the current process to provide a service includes a visible Activity, the grouping state of the current process is upgraded to fg or BTOP (ie, a process associated with the TOP application process).
[0145] As an example of the present application, based on the grouping of the first possible situation described above, the overload situation of the client process that promotes the current process to fg can be further determined, and according to the overload situation of these client processes, it is determined whether the current process can be overloaded to low-fg. For example, please refer to Table 6. In one possible situation, if there is only one client process that promotes the current process to fg, if this client process can be overloaded to low-fg, then it is determined that the current process can be overloaded to low-fg, otherwise, if this client process cannot be overloaded to low-fg, then it is determined that the current process cannot be overloaded to low-fg. In another possible situation, there are multiple client processes that promote the current process to fg. In this case, if these multiple client processes can all be overloaded to low-fg, then it is determined that the current process can also be overloaded to low-fg, otherwise, as long as there is one client process in these multiple client segment processes that cannot be overloaded to low-fg, then it is determined that the current process cannot be overloaded to low-fg.
[0146] For the second possible situation mentioned above, that is, when the current process is the process that provides the provider, please refer to Table 6. In the native process group grouping rules, if the level of the process group of the client process that requests the current process to provide the provider is higher than the level of the process group of the current process, for example, the process group of the client process that requests the current process to provide the provider is the foreground process group, and the process group of the current process is the background process group, then the current process group is promoted to fg.
[0147] As an example of the present application, based on the grouping of the second possible situation described above, the overload situation of the client process that promotes the current process to fg can be further judged, and whether the current process can be overloaded to low-fg can be determined according to the restart situation of these client processes. For example, please refer to Table 6. In one possible situation, there is only one client process that promotes the current process to fg. At this time, if this client process can be overloaded to low-fg, it is determined that the current process can be overloaded to low-fg. Otherwise, if this client process cannot be overloaded to low-fg, it is determined that the current process cannot be overloaded to low-fg. In another possible situation, there are multiple client processes that promote the current process to fg. At this time, if these multiple client processes can all be overloaded to low-fg, it is determined that the current process can be overloaded to low-fg. Otherwise, as long as there is one client process among these multiple client processes that cannot be overloaded to low-fg, it is determined that the current process cannot be overloaded to low-fg.
[0148] For the third possible situation mentioned above, that is, when the current process is both a process providing a service and a process providing a provider, please refer to Table 6. The client processes associated with the current process include processes requesting the provision of a service and processes requesting the provision of a provider. In this case, first, according to the overloading situation of the client process requesting the provision of the service, it can be judged whether the current process can be overloaded to low-fg according to the judgment method of the first item of the low-fg overloading rule in Table 6. Then, according to the overloading situation of the client process requesting the provision of the provider, it can be judged whether the current process can be overloaded to low-fg according to the judgment method of the first item of the low-fg overloading rule in Table 6. Finally, the calculation result of the provider association shall be used to determine whether the current process can be overloaded to low-fg. That is, if it is determined that the current process can be overloaded as low-fg according to the overload situation of the client process that requests the current process to provide the provider, then it is determined that the current process can be grouped as low-fg; otherwise, if it is determined that the current process cannot be overloaded as low-fg according to the overload situation of the client process that requests the current process to provide the provider, then it is determined that the current process cannot be grouped as low-fg.
[0149] As an example of the present application, when it is determined that the current process can be reloaded as a low-level foreground process group based on the process state of the current process, if the client processes requesting the current process to provide services and / or requesting the current process to provide content providers only include desktop applications, and the desktop application is not currently a TOP application process, then it is determined that the current process can be reloaded as low-fg. If the client processes requesting the current process to provide services and / or requesting the current process to provide content providers include desktop applications and other client processes, then when all other client processes except the desktop application can be reloaded as a low-level foreground process group, it is determined that the current process can be reloaded as low-fg.
[0150] As an example of the present application, when a desktop application runs in the background, it is grouped as fg.
[0151] In an exemplary application scenario, when the application interface of the first application is displayed on the desktop application, if the user slides up from the bottom of the electronic device, in response to the user's sliding operation, the electronic device switches the first application to the background and returns to the desktop application. Currently, after the first application is exited, it is necessary to wait until the exit desktop animation is finished before the first application can be grouped as bg. Please refer to Figure 7, after the first application exits, it takes about 803.2ms to switch to bg, that is, the focus can only be switched after the exit desktop animation is finished, which may cause the first application to compete with the desktop application for processor resources, and may cause frame loss during the exit desktop animation. To avoid this situation, when the first application exits the desktop, the grouping state of the first application's process can be reloaded to low-fg. Furthermore, when the exit desktop animation starts to play from the desktop application, the grouping state of the first application's process can be reloaded to low-fg to avoid the first application competing with the desktop application for processor resources after exiting the background, so that the desktop application can have sufficient processor resources.
[0152] It is worth noting that, since the native calculation logic of Android first calculates the service association and then calculates the provider association, in the embodiment of the present application, without modifying the calculation logic, determining whether the current process can be grouped as low-fg can reduce the modification of the native logic.
[0153] Table 6
[0154]
[0155] It should be noted that the embodiment of the present application is described by taking the current process as a process that provides services and / or content providers as an example. In another example, if the current process is not a process that provides services, nor is it a process that provides content providers, the calculation result of the second stage is the result of determining whether the current process can be reloaded as low-fg.
[0156] Step 204: The priority calculation module sends the determination result to the priority application module.
[0157] In an optional implementation, when the priority calculation module determines that the current process can be grouped as low-fg, the priority calculation module sends a judgment result to the priority application module. At this time, the judgment result is used to indicate that the current process can be grouped as low-fg. When it is determined that the current process cannot be grouped as low-fg, the judgment result is not sent to the priority application module. In this case, the grouping situation of the current process does not change, and the grouping result of the process of Android native process group grouping rule is maintained.
[0158] In another optional implementation, after the priority calculation module determines whether the current process can be grouped as low-fg, regardless of whether the current process can be grouped as low-fg, the priority calculation module sends the judgment result to the priority application module, and the priority application module performs further analysis based on the judgment result.
[0159] Step 205: When the judgment result indicates that the current process can be grouped as low-fg, the priority application module queries whether the first application executes a user-perceivable event.
[0160] In one possible scenario, the first application is executing a user-perceivable event, for example, the first application is a multimedia application and is playing a video. In this case, if the process of the first application is overloaded as low-fg, it may affect the normal operation of the first application. Therefore, when the judgment result indicates that the current process can be grouped as low-fg, the priority application module also queries whether the first application executes a user-perceivable event.
[0161] During implementation, since the perception module reports the application status indication information of the first application to the priority application module, the priority application module can determine whether the first application is executing a user-perceivable event based on the application status indication information most recently reported by the perception module. For example, if the application status indication information indicates that the first application is playing a video, it is determined that the first application is executing a user-perceivable event.
[0162] Of course, it should be noted that the embodiment of the present application is described by taking the judgment result indicating that the current process can be grouped as low-fg as an example. In another example, if the judgment result indicates that the current process cannot be grouped as low-fg, that is, indicates that the current process cannot be overloaded, the priority application module does not need to query whether the first application executes a user-perceivable event, and can directly use the grouping result of the Android native process group grouping rule.
[0163] Step 206: When the first application does not execute a user-perceivable event, the priority application module updates the grouping of the current process to low-fg.
[0164] In an example, a specific implementation of the priority application module updating the group of the current process to low-fg may be that the priority application module may add a group identifier to the current process, and the group identifier is low-fg.
[0165] Of course, in the case where the first application executes a user-perceivable event, the priority application module does not update the grouping of the current process to low-fg, that is, maintains the grouping of the current process to fg.
[0166] It should be noted that the embodiment of the present application is described by taking the priority calculation module to determine whether the current process can be reloaded to low-fg, and then the priority application module determines whether to update the grouping status of the current process in combination with the application status indication information reported by the perception module. In another example, please refer to Figure 8, the perception module can also report the application status indication information of the first application to the priority calculation module. In this case, when the priority calculation module determines whether the current process can be reloaded as low-fg at each stage, it can first determine whether the current process can be reloaded as low-fg according to the preset low-fg rule. If it is determined that the current process can be reloaded as low-fg according to the preset low-fg rule, further judgment is made in combination with the application status indication information reported by the perception module. If it is determined that the first application has not executed a user-perceivable event according to the application status indication information, it is determined that the current process can be reloaded as low-fg. Otherwise, if it is determined that the first application is executing a user-perceivable event according to the application status indication information, it is determined that the current process cannot be reloaded as low-fg. After the judgment of the third stage, the final judgment result is sent to the priority application module. If the judgment result indicates that the current process can be grouped as low-fg, the priority application module updates the grouping of the current process. Otherwise, if the judgment result indicates that the current process cannot be grouped as low-fg, the priority application module does not modify the grouping status of the current process.
[0167] Step 207: The priority application module sends a grouping indication to the grouping setting module, where the grouping indication includes the process identifier and the group identifier of the current process.
[0168] In one example, the grouping instruction includes the process identifier and the group identifier of the current process, so that the grouping setting module can know which process group the current process is grouped in. For example, the priority application module can send a setProcessgroup instruction to the grouping setting module.
[0169] Step 208: The group setting module sends a setting instruction to the scheduling module according to the group indication, and the setting instruction carries the process identifier and the group identifier of the current process.
[0170] In one example, the group setting module may send a setting instruction to the scheduling module, where the setting instruction carries the process identifier and the group identifier of the current process, so that the scheduling module can know into which process group the current process is grouped.
[0171] Step 209: The scheduling module allocates processor resources to the processes grouped as low-fg according to the setting instructions.
[0172] In one example, the scheduling module can bind the core to the current process according to the process ID and group ID carried in the setting instruction, and then schedule it to run on the corresponding core. For example, if the current process is grouped into low-fg, the current process is scheduled to run on a core among cores 0-5. For another example, if the current process is grouped into fg, the current process is scheduled to run on a core among cores 0-7.
[0173] In the above manner, each process in the first application can be grouped, and the current process can be scheduled and managed according to the grouped processes. In this way, some processes with lower importance levels than the foreground application can be grouped as low-fg, so that less processor resources are allocated to these processes during process scheduling, avoiding these processes from competing for resources with the foreground application.
[0174] In an embodiment of the present application, after starting the first application, during the operation of the first application, in the process of calculating the priority of the process of the first application, the grouping state of the process of the first application is updated, so that part of the process grouping of the first application is reloaded from the foreground process group to the low-level foreground process group, and each process in the part of the process is not currently executing a user-perceivable event, wherein the processor resources available to the low-level foreground process group are less than the processor resources available to the foreground process group and greater than the processor resources available to the background process group. In this way, by adding a low-level foreground process group, and then grouping some processes in the foreground process group into the low-level foreground process group, and allocating less processor resources to it, it is possible to avoid these processes from competing with the foreground application for processor resources, thereby avoiding problems such as slow system response and application freezes.
[0175] Fig. 9 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig. 9 The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0176] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0177] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0178] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0179] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0180] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0181] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0182] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device 100 through the power management module 141.
[0183] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0184] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0185] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating the target communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0186] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).
[0187] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0188] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.
[0189] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0190] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0191] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for the target function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as a target disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0192] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.
[0193] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with a target microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0194] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor 180K can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0195] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).
[0196] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.
Claims
1. A process management method, characterized in that: Applied in an electronic device, the method comprises: Starting a first application in the electronic device; During the running of the first application, in the process of calculating the priority of the process of the first application, determining the grouping state of the current process to be grouped of the first application; In the case where the current process group is a foreground process group, determining whether the current process can be overloaded by the foreground process group to a low-level foreground process group; In the case where the current process can be reloaded as the low-level foreground process group, querying whether the first application is executing a user-perceivable event; If the first application does not execute a user-perceivable event, updating the grouping state of the current process to the low-level foreground process group, so that the grouping state of some processes of the first application is overloaded from the foreground process group to the low-level foreground process group, and the processor resources available to the low-level foreground process group are less than the processor resources available to the foreground process group and greater than the processor resources available to the background process group; Wherein, in the case where the current process group is the foreground process group, determining whether the current process can be overloaded from the foreground process group to the low-level foreground process group includes: In the case where the current process is a process that is receiving a foreground broadcast, or is a process that is providing services to a client process of a foreground process group, if the current process is a third-party application process, and the current process is not a TOP application process or a process associated with a TOP application process, then, according to the level of the client process associated with the current process, it is determined whether the current process can be overloaded by the foreground process group to the low-level foreground process group, wherein the client process associated with the current process is a client process that sends a foreground broadcast to the current process, or is a client process that requests the foreground process to provide services and belongs to the foreground process group; In the case where it is determined according to the level of the client process associated with the current process that the current process can be reloaded into the low-level foreground process group, determining whether the current process can be reloaded into the low-level foreground process group according to the process state of the current process; In the case where it is determined according to the process state of the current process that the current process can be overloaded into the low-level foreground process group, it is determined whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider.
2. The method according to claim 1, characterized in that The current process is the process that is receiving the foreground broadcast; The step of determining, according to the level of the client process associated with the current process, whether the current process can be overloaded from the foreground process group to the low-level foreground process group comprises: If the level of the client process associated with the current process satisfies the first overload condition, and the foreground broadcast queue of the current process includes only the three-party foreground broadcast queue, it is determined that the current process can be overloaded from the foreground process group to the low-level foreground process group, and the foreground broadcast queue is used to store all foreground broadcasts received by the current process. The first overload condition includes: The client processes that are sending foreground broadcasts to the current process are all third-party application processes, and the client processes that are sending foreground broadcasts to the current process do not include resident processes, and are not TOP application processes or processes associated with TOP application processes.
3. The method according to claim 1, characterized in that The current process is a process that is providing services to the client process of the foreground process group; The step of determining, according to the level of the client process associated with the current process, whether the current process can be overloaded from the foreground process group to the low-level foreground process group comprises: In the case where the level of the client process associated with the current process satisfies the second overloading condition, determining that the current process can be overloaded from the foreground process group to the low-level foreground process group, wherein the second overloading condition includes: All client processes that request the current process to provide services are third-party application processes, and all client processes do not include resident processes, and all client processes are not TOP application processes and processes associated with TOP application processes.
4. The method according to any one of claims 1 to 3, characterized in that The step of determining whether the current process can be reloaded as the low-level foreground process group according to the process state of the current process, when it is determined according to the level of the client process associated with the current process that the current process can be reloaded as the low-level foreground process group, includes: When the current process includes a floating window, and / or the current process includes a foreground service and a floating window, and / or the current process includes an activity in a visible state or a paused state, the current process is determined as being unable to be reloaded as the low-level foreground process group.
5. The method according to any one of claims 1 to 3, characterized in that The current process is a process that provides services or content providers; In the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider, comprises: In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, if the number of client processes requesting the current process to provide a service or content provider is one, then when the client process requesting the current process to provide a service or content provider can be reloaded as the foreground process group, it is determined that the current process can be reloaded as the low-level foreground process group; If there are multiple client processes requesting the current process to provide services or content providers, then when multiple client processes can be reloaded into the foreground process group, it is determined that the current process can be reloaded into the low-level foreground process group.
6. The method according to any one of claims 1 to 3, characterized in that The current process is a process that provides services and content providers; In the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider, comprises: In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, determining whether the current process can be reloaded as the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service; When it is determined that the current process can be reloaded as the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service, traverse the client process requesting the current process to provide a content provider; According to the grouping status of the traversed client processes, it is determined whether the current process can be reloaded as the low-level foreground process group.
7. The method according to any one of claims 1 to 3, characterized in that In the case where it is determined according to the process state of the current process that the current process can be overloaded as the low-level foreground process group, determining whether the current process can be grouped into the low-level foreground process group according to the grouping state of the client process requesting the current process to provide a service and / or the client process requesting the current process to provide a content provider, comprises: In the case where it is determined according to the process state of the current process that the current process can be reloaded as the low-level foreground process group, if the client processes requesting the current process to provide services and / or requesting the current process to provide content providers only include desktop applications, and the desktop application is not currently a TOP application process, it is determined that the current process can be reloaded as the low-level foreground process group; If the client processes requesting the current process to provide services and / or requesting the current process to provide content providers include desktop applications and other client processes, then when, except for the desktop application, the other client processes can be reloaded into the low-level foreground process group, it is determined that the current process can be reloaded into the low-level foreground process group.
8. The method according to any one of claims 1 to 3, characterized in that The electronic device comprises a priority calculation module, a priority application module and a perception module, wherein the perception module is used to monitor whether a task executed by an application in the electronic device is perceptible to a user; The determining, during the running of the first application, in the process of calculating the priority of the process of the first application, the grouping state of the current process to be grouped of the first application includes: During the operation of the first application, in the process of calculating the priority of the process of the first application, the priority calculation module determines the grouping state of the current process; In the case where the current process group is the foreground process group, determining whether the current process can be overloaded from the foreground process group to the low-level foreground process group includes: In the case where the current process is grouped as the foreground process group, the priority calculation module determines whether the current process can be overloaded as the low-level foreground process group; In the case of determining that the current process can be reloaded as the low-level foreground process group, the priority calculation module sends the determination result to the priority application module; The querying whether the first application is executing a user-perceivable event when the current process can be overloaded as the low-level foreground process group includes: After receiving the judgment result, the priority application module determines whether the first application is executing a user-perceivable event according to application status indication information, wherein the application status indication information is used to indicate the working status of the first application, and the application status indication information is sent by the perception module after monitoring a change in the working status of the first application; If the first application does not execute the user-perceivable event, updating the grouping state of the current process to the low-level foreground process group includes: In a case where it is determined according to the application status indication information that the current process does not execute a user-perceivable event, the priority application module updates the grouping status of the current process to the low-level foreground process group.
9. An electronic device, characterized in that: The electronic device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Resource distribution method and mobile terminal
CN106569898A
Dual system-based memory management method and apparatus
CN107766145A
Application process management method and terminal device
CN107807847A