CN116028204B - Process management and control method and electronic equipment - Google Patents

Process management and control method and electronic equipment Download PDF

Info

Publication number
CN116028204B
CN116028204B CN202210590909.1A CN202210590909A CN116028204B CN 116028204 B CN116028204 B CN 116028204B CN 202210590909 A CN202210590909 A CN 202210590909A CN 116028204 B CN116028204 B CN 116028204B
Authority
CN
China
Prior art keywords
suspended
lock
load
background
electronic device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210590909.1A
Other languages
Chinese (zh)
Other versions
CN116028204A (en
Inventor
李勇
任书源
相超
陶有佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Publication of CN116028204A publication Critical patent/CN116028204A/en
Application granted granted Critical
Publication of CN116028204B publication Critical patent/CN116028204B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a process control method and electronic equipment, wherein the method comprises the following steps: acquiring at least one background three-party process running in the electronic equipment, wherein the background three-party process refers to a non-system process running in the background; under the condition that the system load of the electronic equipment is larger than a preset blocking threshold value, determining at least one to-be-suspended process of which the process load in at least one background three-way process meets a preset heavy load condition; if the first process to be suspended does not hold the lock, the first process to be suspended is suspended, wherein the first process to be suspended is any process in the at least one process to be suspended. The method provided by the embodiment of the application can improve the performance and fluency of the operating system of the electronic equipment.

Description

Process management and control method and electronic equipment
The present application claims priority from the national intellectual property agency, application number 202210530983.4, application name "process control method and electronic device" filed on day 16 of month 2022, the entire contents of which are incorporated herein by reference.
Technical Field
The application relates to the technical field of electronics, in particular to a process management and control method and electronic equipment.
Background
In general, in an Operating System (OS) of an electronic device, the activity of a process running in the background affects the performance and smoothness of the entire OS, so that the process running in the background in the system needs to be managed. Currently, the management and control modes of processes running in the background in a system mainly comprise process priority adjustment, process forced killing (kill), process freezing and the like.
Disclosure of Invention
The application provides a process control method, a process control device, electronic equipment, a chip, a computer readable storage medium and a computer program product, which can improve the performance and fluency of a system.
In a first aspect, the present application provides a process control method, the method being performed by an electronic device, the method comprising: acquiring at least one background three-party process running in the electronic equipment, wherein the background three-party process refers to a non-system process running in the background; under the condition that the system load of the electronic equipment is larger than a preset blocking threshold, determining at least one process to be suspended, wherein the process load of the process satisfies a preset heavy load condition, from at least one background three-party process; if the first process to be suspended does not hold the lock, the first process to be suspended is suspended, wherein the first process to be suspended is any process in the at least one process to be suspended.
Optionally, the electronic device may acquire at least one background process running in the electronic device through the background scanning probe, and determine a non-system process in the at least one background process, so as to obtain a background three-way process. Optionally, the electronic device may compare each background process with a preset three-party process list to determine a background three-party process, where the three-party process list includes information of all non-system processes that can run in the electronic device.
Alternatively, the electronic device may obtain the system load of the electronic device through the system load probe. The system load may be characterized by the utilization of the central processing unit (central processing unit, CPU) and/or the utilization of the graphics processor (graphics processing unit, GPU). A system load greater than a preset stuck threshold indicates that the current system load is greater and a stuck phenomenon may occur. In a specific embodiment, the system load is characterized by the CPU utilization, and the preset jam threshold may be, for example, 80%, that is, if the CPU utilization is greater than 80%, it is determined that the current system load is greater, and a jam phenomenon may occur.
Alternatively, the electronic device may acquire the process load through the process load probe. The process load may be characterized by the process 'occupancy of the CPU and/or the process' occupancy of the GPU. The process load meeting the preset heavy load condition indicates that the load of the process is larger. Alternatively, the preset heavy load condition may be, for example, that the process load is greater than a preset threshold.
Alternatively, the electronic device may determine whether the process to be suspended holds a lock by calling a second preset application programming interface (Application Programming Interface, API) according to a return value of the second preset API interface. The second preset API interface is used for inquiring whether the process holds the lock or not. For example, if the return value of the second preset API interface is true, it is indicated that the process to be suspended holds a lock; if the return value of the second preset API interface is false, the process to be suspended is indicated to have no lock.
Optionally, if the first process to be suspended does not hold the lock, the electronic device may call an associated interface in the process manager through the process suspension interface to suspend the first process to be suspended.
According to the process control method provided by the first aspect of the application, by acquiring at least one background three-way process, under the condition that the system load is larger than the preset katon threshold value, determining the process of which the process load meets the preset heavy load condition in the at least one background three-way process, namely determining the process of which the process load is larger, and obtaining at least one process to be suspended. And for each process to be suspended, if the process to be suspended does not hold a lock, suspending the process to be suspended. The suspended process does not occupy physical resources of the electronic equipment any more, so that the system load can be effectively reduced, the system operation efficiency is improved, the blocking is reduced, and the user experience is improved. Meanwhile, the method does not suspend the process to be suspended, so that the process with the lock can be prevented from continuously occupying shared resources, further other processes are prevented from being blocked and unable to run due to the waiting of the lock, system blocking is prevented, the background management and control effect is improved, and the system performance and fluency are improved.
In one possible implementation, after suspending the first process to be suspended, the method further includes: the first process to be suspended is marked as a suspended process.
Alternatively, the marking of the first process to be suspended as the suspended process may be achieved by recording the first process to be suspended to the process suspension list. Alternatively, the first process to be suspended may be marked as a suspended process by performing suspension marking on the first process to be suspended, that is, adding suspension marking information to the first process to be suspended.
In the implementation manner, after the first process to be suspended is suspended, the first process to be suspended is marked as the suspended process, so that the process to be suspended is conveniently known, and the suspended process is conveniently recovered.
In one possible implementation, marking a first process to be suspended as a suspended process includes: the suspension flag information is added for the first process to be suspended.
The suspension flag information is used to characterize that the process is suspended at the current time (i.e., the time at which the flag information is added, hereinafter referred to as the flag time). Alternatively, the suspend flag information may be a value in the suspend flag field of the process that characterizes the process suspension. For example, if a value of 1 in the suspend flag field in the data structure of the process indicates that the process is suspended, a value of 1 may be assigned to the suspend flag field of the first process to be suspended, and the first process to be suspended may be marked as the suspended process.
In the implementation mode, the suspension mark information is added for the first process to be suspended, so that the process can be suspended simply and rapidly, subsequent searching is facilitated, the algorithm running efficiency is improved, and the process management and control efficiency is further improved.
In one possible implementation, the method further includes: if the first process to be suspended holds the lock, the first process to be suspended is marked as the process holding the lock.
Alternatively, the marking of the first process to be suspended as the process holding the lock may be achieved by recording the first process to be suspended to the holding lock process list. Alternatively, the first process to be suspended may be marked as a process holding the lock by performing lock marking on the first process to be suspended, that is, adding lock marking information to the first process to be suspended.
In the implementation manner, under the condition that the first process to be suspended holds the lock, the first process to be suspended is not suspended, so that the process holding the lock can be prevented from continuously occupying the shared resource, further, other processes are prevented from being blocked and cannot operate due to the waiting of the lock, system blocking is prevented, and the background management and control effect is improved, namely, the system performance and fluency are improved. And under the condition that the first process to be suspended holds the lock, the first process to be suspended is marked as the process holding the lock, so that the subsequent monitoring of the process is facilitated, the process is suspended in time after the process releases the lock, and the system load is further reduced.
In one possible implementation, marking a first process to be suspended as a process holding a lock includes: lock flag information is added for the first process to be suspended.
The lock tag information is used to characterize that the process holds the lock at the current time (i.e., the tag time). Alternatively, the suspension flag information may hold a lock value for the process in the lock flag field of the process. For example, if the value of the lock flag field in the data structure of the process is 1, which indicates that the process holds the lock, a value of 1 may be assigned to the lock flag field of the first process to be suspended, and the first process to be suspended may be marked as the process holding the lock.
In the implementation mode, under the condition that the process holds the lock, lock mark information is added for the process, so that the process can be simply and rapidly marked with the lock, subsequent searching is convenient, the algorithm running efficiency is improved, and the process management and control efficiency is further improved.
In one possible implementation manner, under the condition that the system load of the electronic device is greater than a preset katon threshold, determining at least one process to be suspended, the process load of which meets a preset heavy load condition, from at least one background three-way process; previously, the method further comprises: if at least one history lock process exists in the at least one background three-way process, determining whether locks of all history lock processes are released, wherein the history lock process is a process with lock mark information; and if the lock of the first history lock process is released, suspending the first history lock process, wherein the first history lock process is any one process in the at least one history lock process.
Optionally, the electronic device may determine whether the process is a history lock process by calling a fourth preset API interface according to a return value of the fourth preset API interface. Optionally, the fourth preset API interface is configured to query whether the process has lock flag information. For example, the fourth preset API queries and returns the value of the process lock flag field, if the value of the returned lock flag field of the fourth preset API is 1, it indicates that the background three-party process has lock flag information, and determines the process as a history lock process; if the value of the returned lock flag field of the fourth preset API interface is 0, the background three-party process is indicated to have no lock flag information, and the process is not a history lock process.
In the implementation manner, under the condition that a history lock process exists in at least one background three-party process, a first history lock process without a lock is suspended, namely, a process with the lock is monitored, if the lock of the process with the lock is released, whether the process meets the preset heavy load condition or not, the process is suspended, so that the resources of the electronic equipment can be further released, the performance and fluency of the electronic equipment are improved, and further the user experience is improved.
In one possible implementation, after suspending the first history lock process, the method further includes: the first history lock process is marked as a suspended process.
In the implementation manner, after the first history lock process is suspended, the first history lock process is marked as the suspended process, so that the process which is suspended is convenient to know, and the suspended process is convenient to recover later.
In one possible implementation, marking a first history lock process as a suspended process includes: suspension flag information is added to the first history lock process. The suspend flag information is used to characterize that the process is suspended at the current time (i.e., the flag time).
In the implementation mode, the suspension mark information is added for the first history lock process, so that the process can be simply and rapidly suspended and marked, subsequent searching is convenient, the algorithm running efficiency is improved, and the process management and control efficiency is further improved.
In one possible implementation manner, the preset heavy load condition is that the process load is located in the first n bits of the sequence from big to small of the process load of at least one background three-way process, n is an integer greater than or equal to 1, the process to be suspended is a main process, and at least one process to be suspended, the process load of which meets the preset heavy load condition, is determined from the at least one background three-way process; comprising the following steps: respectively acquiring the process load of each background three-way process; sequencing at least one background three-way process according to the sequence from big to small of the process load, and acquiring the processes of the first n bits in the sequencing to obtain n target processes; and determining at least one process to be suspended according to the main process corresponding to the target process.
Alternatively, n may be 3, for example.
In the implementation manner, at least one background three-way process is ordered according to the sequence of the process load from large to small, the processes of the first n bits in the ordering are obtained to obtain n target processes, and the processes to be suspended are determined based on the n target processes, so that the process occupying the most resources in the system can be screened out, the process occupying the most resources can be suspended when the process is suspended, the system load is further effectively reduced, the system operation efficiency is improved, the blocking is reduced, and the user experience is improved. In addition, the to-be-suspended process is the main process, and the system load can be effectively lightened by suspending the main process, so that the system operation efficiency is further improved, the blocking is reduced, and the user experience is improved.
In one possible implementation manner, determining at least one process to be suspended according to a main process corresponding to the target process includes: if the first target process is a main process, determining the first target process as a process to be suspended, wherein the first target process is any one process in n target processes; and if the first target process is a sub-process, determining the main process corresponding to the first target process as a process to be suspended.
Optionally, the electronic device may determine, by calling a first preset API interface, a main process corresponding to the process according to return information of the first preset API interface.
In one possible implementation, the method further includes: and under the condition that the system load of the electronic equipment is smaller than or equal to a preset blocking threshold value, if the suspended process exists in at least one background three-party process, recovering the suspended process.
In the implementation mode, under the condition that the system load is smaller than or equal to a preset blocking threshold value, the suspended process in the background three-way process is recovered, so that the process can be prevented from being suspended for a long time to influence APP operation, and the influence on normal use of a user can be reduced as much as possible while the background process is controlled, and the user experience is further improved.
In one possible implementation, the suspended process is a process with suspension flag information.
In one possible implementation, if there is a suspended process in the at least one background three-party process, recovering the suspended process includes: determining whether a process with suspension mark information exists in at least one background three-party process; if yes, suspending the process with the suspending mark information.
Optionally, the electronic device may determine, by calling a third preset API interface, whether the background three-party process has the suspension flag information according to a return value of the third preset API interface. The third preset API interface is used for inquiring the value of the suspension mark field of the background three-party process. Specifically, a process identification number (process identification, PID) of the background three-way process is input into a third preset API interface, and the third preset API interface returns the value of the suspend flag field of the process. And determining whether the background three-party process has a suspension mark according to the value of the suspension mark field. For example, if the value of the suspend flag field is 1, it indicates that the process has suspend flag information, which is a suspended process; if the value of the suspend flag field is 0, it indicates that the process does not have suspend flag information and is not a suspended process.
In the implementation mode, the suspended process can be simply and rapidly determined through the suspended mark information, so that the operation efficiency of an algorithm is improved, and the process management and control efficiency is further improved.
In a second aspect, the present application provides an apparatus, which is included in an electronic device, the apparatus having a function of implementing the above first aspect and the behavior of the electronic device in the possible implementation manners of the above first aspect. The functions may be realized by hardware, or may be realized by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the functions described above. Such as a receiving module or unit, a processing module or unit, etc.
In a third aspect, the present application provides an electronic device, including: a processor, a memory, and an interface; the processor, the memory and the interface cooperate with each other such that the electronic device performs any one of the methods of the technical solutions of the first aspect.
In a fourth aspect, the present application provides a chip comprising a processor. The processor is configured to read and execute a computer program stored in the memory to perform the method of the first aspect and any possible implementation thereof.
Optionally, the chip further comprises a memory, and the memory is connected with the processor through a circuit or a wire.
Further optionally, the chip further comprises a communication interface.
In a fifth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored, which when executed by a processor causes the processor to perform any one of the methods of the first aspect.
In a sixth aspect, the application provides a computer program product comprising: computer program code which, when run on an electronic device, causes the electronic device to perform any one of the methods of the solutions of the first aspect.
Drawings
FIG. 1 is a schematic diagram of an exemplary process state according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present application;
FIG. 3 is a block diagram illustrating a software architecture of an exemplary electronic device 100 according to an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating a workflow of software and hardware for controlling a process by the electronic device 100 according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating an exemplary process control method according to an embodiment of the present application;
FIG. 6 is a flowchart of another process control method according to an embodiment of the present application;
FIG. 7 is a schematic diagram illustrating module interactions of an exemplary process control method according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an exemplary chip system according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. Wherein, in the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" means two or more than two.
The terms "first," "second," "third," and the like, are used below for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", or a third "may explicitly or implicitly include one or more such feature.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
For a better understanding of embodiments of the present application, terms or concepts that may be referred to in the embodiments are explained below.
1. Lock with locking mechanism
Process/thread sharing resources is a common way of inter-process communication. In the process of sharing resources by processes/threads, in order to ensure the consistency of data operations and the safety of the shared resources, and also in order to prevent unpredictable errors and results of process operation, a locking mechanism is introduced into an operating system. Locks are one way to synchronize processes/threads. Common locks include a synchronous lock, a mutual exclusive lock, a semaphore, and the like. Wherein, locks used by processes may be referred to as process locks, and locks used by threads may be referred to as thread locks.
Alternatively, the shared resources may include memory, code, data, buses, handles, and the like. These shared resources may be accessed by multiple processes and/or threads, and protection of the shared resources is achieved by locks in order to avoid multiple processes and/or threads accessing the shared resources at the same time. Taking the process lock a as an example to protect the resource a, only the process holding the lock a can access the resource a in multiple processes, and once the process acquires the lock a, other processes can not hold the lock a any more, i.e. the lock a can only be held by one process at the same time. Only after the process holding lock a releases lock a, the other processes get hold opportunities for lock a.
After the lock is created, a corresponding handle is generated, the related information of the lock can be acquired through the handle between multiple processes, and the handle can be maintained and saved by an operating system. In general, the process-to-process lock operation flow may be as follows:
(1) the process opens the process lock and obtains the handle.
(2) If the handle is empty, the process creates a process lock.
(3) The process acquires a process lock; if the process lock is held by other processes, the process lock can be acquired after the other processes release the lock, the processes are in a blocking state, the CPU resources can be occupied by the other processes, and only after the process lock is reached, the processes start to schedule the CPU resources to run.
(4) The process acquires the corresponding service processed after the process lock.
(5) And releasing the process lock after the process finishes processing the corresponding service.
2. Progress and state of progress
A process is a dynamic execution of a program.
The lifecycle of a process involves three processes: creation of a process, execution of a process, and extinction of a process (otherwise known as destruction or revocation). Referring to fig. 1, the states involved in the life cycle of a process mainly include: ready state, running state, terminating state, suspended state, blocking state, etc.
Ready state: it means that the process has running conditions. After the process is in the ready state, the running state can be entered only by scheduling CPU resources.
Operating state: also referred to as an execution state, refers to a process occupying CPU resources and running. And if a certain service is executed overtime in the process of running the process, entering a ready state.
Termination state: refers to the ending of the process, i.e. the imminent death.
Blocking state: the running process (i.e. the running process) cannot continue to execute temporarily due to the occurrence of a resistance event (such as an I/O request, waiting for an event or applying for a buffer failure, etc.), at this time, the operating system allocates CPU resources to another process in a ready state, and lets the process that cannot continue to execute temporarily suspend running, which is generally referred to as process blocking, and the state after the process blocking is referred to as blocking state. The process in the blocked state enters the ready state after the drag event is released (e.g., the I/O request is completed, a waiting event occurs or the application of the buffer is successful, etc.).
Suspension state: the process is suspended since the operating system and/or user needs introduce a process-suspended operation. When the process is suspended, if the process is in an operation state, the process is suspended; if the process is in a ready state, the process temporarily does not accept scheduling at this time. After the process is suspended, the process still exists, but cannot continue running. The suspended state corresponds to a stationary state. A process in a suspended state may be defined in the operating system as a process that is temporarily obsolete from memory. From a resource perspective, the virtual resource corresponding to the process in the suspended state still exists, but the operating system no longer allocates physical resources for that process. For example, a process in a suspended state cannot schedule resources of the CPU, and cannot get a time slice of the CPU. In short, after the process is suspended, the system resources can be released, and the system load is reduced.
The process in the suspended state may be re-entered into the ready state by activation (i.e., restoration).
In both the blocked and suspended states, the process is suspended, but the two are substantially different:
1) Different occupation of system resources: although the CPU resource is released by the process blocking and the process suspending, the process in the blocking state is still in the memory, and the process in the suspending state is swapped out to the external memory (disk) through the swap technology, so that the memory resource is not occupied.
2) The occurrence time is different: process blocking generally occurs when a process waits for resources (I/O resources, buffer resources, semaphores, etc.); while the process is suspended due to operating system and/or user requirements, for example, the end user needs to pause the program to study the program execution or make modifications to the program, etc.
3) The recovery opportunities are different: a process in a blocked state needs to enter a ready state after a resistance event is released (e.g., waiting resources are satisfied, etc.); while the process in the suspended state needs to be actively activated by the object (e.g., user, operating system) that suspended it when the opportunity is met (e.g., debug ended, scheduled process selected to need to be re-executed, etc.).
The following describes a process control method provided by an embodiment of the present application.
With the improvement of the performance of electronic devices, applications (APP) installed in the electronic devices are increasing, and background loads of the electronic devices are increasing. For example, when a user opens more APPs in an electronic device, or some APPs are automatically started after the electronic device is started by acquiring user rights, background load of the electronic device is overlarge, and then the electronic device is blocked.
In the related art, under the condition of overlarge background load, the processes running in the background in the system are generally managed and controlled by adjusting the priority of the processes, the strong killing (kill) of the processes, the freezing of the processes and the like, so as to solve the problem of blocking.
The embodiment of the application provides a process control method, which can suspend the process with overlarge load in a background process in a suspending mode, release system resources and solve the problem of blocking.
The process management and control method provided by the embodiment of the application can be applied to electronic equipment such as notebook computers, ultra-mobile personal computer (UMPC), netbooks, personal digital assistants (personal digital assistant, PDA), mobile phones, tablet computers, wearable equipment, vehicle-mounted equipment, augmented reality (augmented reality, AR)/Virtual Reality (VR) equipment and the like, and Application (APP) can be installed, and the embodiment of the application does not limit the specific type of the electronic equipment.
Fig. 2 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present application. As shown in fig. 2, the electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, universal serial bus (universal serial bus, USB) interface 130, charge management module 140, power management module 141, battery 142, wireless communication module 150, display screen 160, etc.
It is to be understood that the structure illustrated in the present embodiment does not constitute a specific limitation on the electronic apparatus 100. In other embodiments, electronic device 100 may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a GPU, an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller may be a neural hub and command center of the electronic device 100. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an I2C interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a USB interface, among others.
It should be understood that the connection relationship between the modules illustrated in this embodiment is only illustrative, and does not limit the structure of the electronic device 100. In other embodiments, the electronic device 100 may also employ different interfaces in the above embodiments, or a combination of interfaces.
The charge management module 140 is configured to receive a charge input from a charger. The charger can be a wireless charger or a wired charger. The charging management module 140 may also supply power to the electronic device through the power management module 141 while charging the battery 142.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display screen 160, the wireless communication module 150, and the like. In some embodiments, the power management module 141 and the charge management module 140 may also be provided in the same device.
The wireless communication module 150 may provide solutions for wireless communication including WLAN (e.g., wi-Fi), bluetooth, global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., applied to the electronic device 100. For example, in the embodiment of the present application, the electronic device 100 may establish a bluetooth connection with a terminal device (such as a wireless headset) through the wireless communication module 150.
The wireless communication module 150 may be one or more devices that integrate at least one communication processing module. The wireless communication module 150 receives electromagnetic waves via an antenna, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 150 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via an antenna.
The electronic device 100 implements display functions through a GPU, a display screen 160, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 160 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 160 is used to display images, videos, and the like. The display 160 includes a display panel.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store computer executable program code including instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 may include a storage program area and a storage data area by executing instructions stored in the internal memory 121.
The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The software system of the electronic device 100 may employ a layered architecture, an event driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application exemplifies a Windows system of a layered architecture, and illustrates a software structure of the electronic device 100.
Fig. 3 is a block diagram illustrating a software architecture of an electronic device 100 according to an embodiment of the present application.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, windows systems are classified into a user mode and a kernel mode. The user mode comprises an application layer and a subsystem dynamic link library. The kernel mode is divided into a firmware layer, a hardware abstraction layer (hardware abstraction layer, HAL), a kernel and a driving layer and an executing body from bottom to top.
As shown in FIG. 3, the application layer includes applications for music, video, games, office, social, etc. The application layer also includes an environment subsystem, a system probe module, a scheduling engine, and the like. Wherein only a part of application programs are shown in the figure, the application layer can also comprise other application programs, such as shopping application, browser and the like, and the application is not limited.
The environment subsystem may expose certain subsets of the basic executive services to the application in a particular modality, providing an execution environment for the application.
The system probe module may acquire the operating state of the electronic device 100. For example, the system probe module may include a background process scan probe, a system load probe, a process load probe, a power state probe, a peripheral state probe, an audio video state probe, a system event probe, and the like. The details of the system probe module are described below and are not described herein.
The scheduling engine may obtain the load condition of the electronic device 100 and determine a process control policy in combination with the load condition of the electronic device 100.
The subsystem dynamic link library comprises an API module comprising Windows API, windows native API, etc. The Windows APIs, which can provide system call entry and internal function support for the application program, are different in that they are Windows system native APIs. For example, windows APIs may include user. Dll, kernel. Dll, and Windows native APIs may include ntdll. The user. Dll is a Windows user interface, and can be used for performing operations such as creating a window, sending a message, and the like. kernel. Dll is used to provide an interface for applications to access the kernel. ntdll.dll is an important Windows NT kernel-level file that describes the interface of the Windows local NTAPI. When Windows is started, ntdll.dll resides in a particular write protect region of memory, which prevents other programs from occupying that memory region.
The executives include a process manager, a virtual memory manager, a secure reference monitor, an I/O manager, windows management specifications (Windows management instrumentation, WMI), a power manager, and a system event driven (operating system event driver, oseeventdriver) node, among others.
The process manager is used to create and suspend processes and threads, including suspended processes.
The virtual memory manager implements "virtual memory". The virtual memory manager also provides basic support for the cache manager.
The security reference monitor may execute a security policy on the local computer that protects operating system resources, performs protection and monitoring of runtime objects.
The I/O manager performs device independent input/output and further processes call the appropriate device drivers.
The power manager may manage power state changes for all devices that support power state changes.
The system event driven node may interact with the kernel and the driving layer, for example, interact with a graphics card driver, and report the GPU video decoding event to the system probe module after determining that the GPU video decoding event exists.
The kernel and driver layer includes a kernel and a device driver.
The kernel is an abstraction of the processor architecture, separates the difference between the executable and the processor architecture, and ensures the portability of the system. The kernel may perform thread scheduling and scheduling, trap handling and exception scheduling, interrupt handling and scheduling, etc.
The device driver operates in kernel mode as an interface between the I/O system and the associated hardware. The device drivers may include graphics card drivers, intel DTT drivers, mouse drivers, audio video drivers, camera drivers, keyboard drivers, and the like. For example, the graphics driver may drive the GPU to run and the Intel DTT driver may drive the CPU to run.
The HAL is a core state module, which can hide various details related to hardware, such as an I/O interface, an interrupt controller, a multiprocessor communication mechanism and the like, provide uniform service interfaces for different hardware platforms running Windows, and realize portability on various hardware platforms. It should be noted that, in order to maintain portability of Windows, the Windows internal components and the device driver written by the user do not directly access the hardware, but rather by calling the routine in the HAL.
The firmware layer may include a basic input output system (basic input output system, BIOS), which is a set of programs that are embedded in a Read Only Memory (ROM) chip on the motherboard of the computer, which holds the most important basic input output programs, post-boot self-test programs, and system self-start programs of the computer, and which reads and writes specific information of the system settings from and to the complementary metal oxide semiconductor (complementary metal oxide semiconductor, CMOS). Its main function is to provide the lowest, most direct hardware setup and control for the computer. The Intel DTT driver may send instructions to the CPU via the BIOS.
It should be noted that, in the embodiment of the present application, only a Windows system is used as an example, and in other operating systems (such as an android system, an IOS system, etc.), the scheme of the present application can be implemented as long as the functions implemented by the respective functional modules are similar to those of the embodiment of the present application.
Fig. 4 shows a schematic workflow diagram of software and hardware for the electronic device 100 to manage processes.
As shown in fig. 4, the system probe module may acquire an operational state of the electronic device 100. Specifically, the system probe module can subscribe various information to the kernel mode through a corresponding interface in the API module, and acquire information (i.e. information callback) according to callback functions of the various information fed back by the kernel mode.
Alternatively, the system probe module may include a background process scanning probe, a process load probe, a system load probe, and the like. In addition, in some embodiments, the system probe module may further include a power status probe, a peripheral status probe, an audio/video status probe, a system event probe, etc. (not shown).
The background process scanning probe can subscribe the background running process (hereinafter or called background process) to the kernel state, and determine the background running process at the current moment according to the callback function fed back by the kernel state.
The process load probe can subscribe the process load to the kernel state, and determine the process load according to the callback function fed back by the kernel state. Alternatively, the process load may be characterized by the process 'occupancy rate of the CPU and/or the process' occupancy rate of the GPU.
The system load probe can subscribe the system load to the kernel state, and the system load is determined according to a callback function fed back by the kernel state. Alternatively, the system load may be characterized by CPU utilization and/or GPU utilization. That is, the system load probe may subscribe to the kernel state for CPU utilization and/or GPU utilization, and determine the CPU utilization and/or GPU utilization according to the callback function fed back by the kernel state.
The power state probe may subscribe to a kernel state for a power state event, determine a power state according to a callback function fed back by the kernel state, where the power state includes a battery (remaining) amount, a power mode, and the like, and the power mode may include an alternating current (alternating current, AC) and a Direct Current (DC) power. For example, the power state probe may send a request to the oseeventdriver node of the executive layer to subscribe to a power state event, which is forwarded by the oseeventdriver node to the power manager of the executive layer. The power manager may feed back a callback function to the power state probe through the oseeventdriver node.
The peripheral state probe can subscribe a peripheral event to the kernel state, and the peripheral event is determined according to a callback function fed back by the kernel state. Peripheral events include mouse wheel slide events, mouse click events, keyboard input events, microphone input events, camera input events, and the like.
The audio and video status probe may subscribe to the kernel mode for audio and video events, and determine the audio and video events currently existing in the electronic device 100 according to the callback function fed back by the kernel mode. The audio video events may include GPU decoding events, and the like. For example, the audio/video status probe may send a request to the oseeventdriver node of the executive layer to subscribe to the GPU decoding event, and the oseeventdriver node forwards the request to the graphics card driver of the kernel and driver layer. The display card driver can monitor the state of the GPU, and after the GPU is monitored to perform decoding operation, callback functions are fed back to the audio and video state probes through the OsEventDriver node.
The system event probe can subscribe system events or information to the kernel state, and the system events or information are determined according to a callback function fed back by the kernel state. The system events may include window change events, process creation events, thread creation events, and the like. For example, the system event probe may send a request to the oseeventdriver node of the executive layer to subscribe to a process creation event, which is forwarded by the oseeventdriver node to the process manager. The process manager can feed back a callback function to the system event probe through the OsEventDriver node after the process is created. For another example, the system event probe may send information such as background process information, system load, or process load to the API module, where the API module may monitor a background process, system load, or process load of the electronic device 100, and when these information changes, or according to a preset period, feedback a callback function to the system event probe.
It can be seen that the system probe module subscribes to various events of the electronic device 100 from the kernel mode, and then determines a background process, a system load, a process load, and the like of the electronic device 100 according to the callback function fed back by the kernel mode, thereby obtaining a probe state.
As shown in fig. 4, the scheduler engine is configured to obtain a probe status from the system probe module, and determine a process control policy according to the probe status. Alternatively, the scheduler engine may request the system probe module for probe status as needed, and the system probe module may feed back the probe status to the scheduler engine in response to the scheduler engine's request. Alternatively, the scheduling engine may acquire the probe status from the system probe module by subscribing. In the following embodiments, the scheduling engine acquires the probe status from the system probe module by subscription.
The scheduling engine may include a load manager and a scheduling executor. The load controller can subscribe the probe state to the system probe module, and acquire the probe state according to a callback function fed back by the system probe module. Specifically, the load controller scans the background process and subscribes to the background process from the background process scanning probe, and obtains the running process of the background (namely, background process callback) according to the callback function fed back by the background process scanning probe. The load controller subscribes the system load to the system load probe, and obtains the system load (i.e. system load callback) according to the callback function fed back by the system load probe. The load controller subscribes the process load to the process load probe, and obtains the load of the process (namely, the process load callback) according to the callback function fed back by the process load probe.
After the load controller receives the probe state, a process control strategy can be determined according to the probe state. Alternatively, the process control policy may include a process suspension policy, a process recovery policy, and the like. The process suspension policy is used to indicate suspension of a process. The process restoration policy is used to indicate that the suspended process is activated, etc. Alternatively, the load manager may generate the process control policy according to a pre-designed process suspension determination logic. The load manager sends the process control policy to the schedule executor. The scheduling executor performs process control based on the process control strategy.
As shown in fig. 4, the schedule executor may include a process suspension interface. The process suspension interface is used for executing a process control strategy, suspending the corresponding process or activating the corresponding process. Alternatively, the process suspension interface may suspend the process by calling a corresponding interface in the process manager. In some other embodiments, the schedule executor may also include a process kill interface, a process priority interface, a process kill interface, and the like (not shown).
For easy understanding, the following embodiments of the present application will take an electronic device having the structure shown in fig. 2, fig. 3, and fig. 4 as an example, to specifically describe a process control method provided by the embodiments of the present application.
Fig. 5 is a schematic flow chart of an exemplary process control method according to an embodiment of the present application. The present embodiment relates generally to process control policy generation logic. The main execution body of the method provided by the embodiment is the electronic equipment. It should be noted that, the flow of the method in the following embodiments may be performed periodically, for example, according to a preset period (e.g., 5 s), where each period triggers the following flow to be performed once; or after the execution of the following flow is completed, returning to the first step for repeated execution, so as to continuously control the process. Fig. 5 illustrates a flow of the method according to a preset cycle.
As shown in fig. 5, the method includes:
s101, acquiring a system load.
Alternatively, the electronic device may acquire the system load through a system load probe. The system load may be characterized by CPU utilization and/or GPU utilization.
S102, acquiring a background process.
Alternatively, the electronic device may acquire a background run by scanning the probe through a background process.
Optionally, the electronic device may generate a background process list after acquiring the background process, where the background process list may include a process identifier of each process running in the background. The process identifier is a unique identity identifier of the process, and the process identifier may be, for example, a name or PID of the process, etc.
S103, determining a background three-way process according to the background process, wherein the background three-way process refers to a non-system process in the background process.
Optionally, the electronic device may determine the background three-party process through the load management module. Specifically, the load management and control module may determine a background three-party process according to the background process list and a pre-established process list, and generate a background three-party process list.
In one embodiment, the load management and control module may compare the background process list with a pre-established three-party process list, determine a process belonging to the three-party process list in the background process list as a background three-party process, and generate a background three-party process list. The list of the three-party processes stores all the three-party processes (non-system processes) which can be operated in the system of the electronic device.
In another embodiment, the load management and control module may also compare the background process list with a system process list established in advance, delete a process belonging to the system process list in the background process list, and generate a background three-party process list. The system process list stores all the system processes which can run in the system of the electronic equipment.
S104, judging whether the system load exceeds a preset clamping threshold value; if yes, go to step S105; if not, step S111 is performed.
Optionally, the electronic device may determine, through the load controller, whether the system load exceeds a preset katon threshold. In a specific embodiment, in the case that the system load is represented by the CPU utilization, the preset katon threshold may be, for example, 80%, and if the CPU utilization is greater than 80%, step S105 is executed; if the CPU utilization is less than or equal to 80%, step S111 is performed.
S105, obtaining the process load of each background three-way process.
Alternatively, the electronic device may acquire the system load through a process load probe. Alternatively, the process load may be characterized by the process 'occupancy of the CPU and/or the process' occupancy of the GPU.
S106, sequencing all the background three-way processes according to the sequence of the process load from large to small, and determining the process of the first n bits in the sequencing as a target process, wherein n is an integer greater than or equal to 1.
In a specific embodiment, n may be 3.
S107, determining a main process corresponding to each target process to obtain a process to be suspended.
It will be appreciated that the target process may be a main process or a sub-process. Wherein the master process is also called parent process. One or more sub-processes may be created under the main process. The method provided by the embodiment mainly suspends the main process, so that the main process corresponding to the target process needs to be determined, and the process to be suspended is obtained. Specifically, if the target process is a main process, the main process corresponding to the target process is the target process itself, and if the target process is a sub-process, the main process corresponding to the target process is the main process to which the sub-process belongs.
In one embodiment, for each target process, the electronic device may determine the process to be suspended according to the following procedure: determining whether the target process is a main process; if the target process is the main process, the target process is determined to be a process to be suspended; if the target process is a sub-process, determining a main process corresponding to the target process, and determining the main process corresponding to the target process as a process to be suspended.
Alternatively, the electronic device may confirm whether the target process is the master process by comparing the root processes of the target process and the target process. Specifically, the electronic device queries the PID of the root process to which the target process belongs according to the PID of the target process, if the PID of the target process is consistent with the PID of the root process, the target process is determined to be the main process, otherwise, the target process is determined not to be the main process.
Optionally, in the case that the target process is a sub-process, the electronic device may determine a main process corresponding to the target process, that is, determine a main process to which the target process belongs, by calling a first preset API interface. Specifically, the PID of the target process is input into a first preset API interface, and the API interface returns the PID of the main process to which the target process belongs. The first preset API interface is used for inquiring the main process to which the process belongs. Optionally, the first preset API interface may determine the host process to which the process belongs by querying a linked list of processes, which is not limited in the embodiment of the present application.
In another embodiment, when determining the process to be suspended, it is also possible to determine the main process corresponding to the target process directly by calling the first preset API interface without determining whether the target process is the main process, where only if the target process is the main process, the PID of the main process to which the target process returned by the first preset AIP interface belongs is the same as the PID of the target process itself.
After determining that the master process corresponding to each target process obtains the process to be suspended, for any process to be suspended a (i.e., the first process to be suspended), the following steps S108 to S110 are executed:
s108, judging whether the process a to be suspended holds a lock or not; if not, executing step S109; if yes, go to step S110.
Optionally, the electronic device may determine, through the load manager, whether the process holds the lock by calling a second preset API interface. The second preset API interface is used for inquiring whether the process holds the lock or not. The load controller may determine whether the process a to be suspended holds a lock according to the return value of the second preset API interface. For example, if the return value of the second preset API interface is true, it is indicated that the process to be suspended a holds a lock; if the return value of the second preset API interface is false, the process a to be suspended is indicated to have no lock.
S109, suspending the process a to be suspended, and marking the suspension of the process a to be suspended, and then executing step S110.
If step S108 determines that the process to be suspended does not hold the lock, the process is determined to be the process to be suspended finally, the electronic device may generate a process suspension policy according to the PID of the process a to be suspended through the load controller, and send the process suspension policy to the process suspension interface, where the process suspension interface executes suspension of the process. The process is in a suspended state after being suspended.
Meanwhile, the electronic device can carry out the suspension mark on the process through the suspension interface, namely, a suspension mark (also called suspension mark information) is added to the process, so that a system can know which processes are suspended, and the suspended processes can be recovered at a later stage. Optionally, a suspend flag (flag) field may be added to the data structure of the process and assigned, for example, if the process is suspended, the suspend flag field is assigned a value of 1, otherwise, the suspend flag field defaults to 0 or is null.
Alternatively, in another embodiment, the suspended process may be recorded in the process suspended list, so that the system can learn which processes are suspended, and the suspended processes are convenient to recover later.
S110, judging whether all processes to be suspended execute the step S108; if yes, finishing the execution of the flow in the execution period, and ending the flow; if not, the next process to be suspended is taken as a process to be suspended a, and the step S108 is executed.
That is, if step S108 determines that the process to be suspended holds the lock, the process is not suspended, and the next process to be suspended continues to determine whether the next process to be suspended holds the lock until all the processes to be suspended are traversed.
S111, determining whether a suspended process exists in the three-way background process; if yes, go to step S112; if not, the process in the execution period is completed, and the process is ended.
That is, if it is determined in step S104 that the system load does not exceed the preset threshold, the electronic device determines whether there is a process suspended in the previous execution period in the three-way background process.
Alternatively, the electronic device may determine whether a suspended process exists by querying the state of the background three-way process, and if the state of the process is the suspended state, the process is the suspended process.
Optionally, in the case that there is a process suspended list, the electronic device may also determine whether there is a suspended process by querying the process suspended list, and determine the process existing in the suspended list as the suspended process.
Optionally, the electronic device may also determine whether a suspended process exists by determining whether a process with a suspension flag exists in the background three-way process. In a specific embodiment, the electronic device may determine whether the process has a process with a suspend flag by calling a third preset API interface. The third preset API interface is used for inquiring the value of the suspension mark field of the background three-party process. And inputting the PID of the background three-party process into a third preset API interface, and returning the value of the suspension mark field of the process by the third preset API interface. And determining whether the background three-party process has a suspension mark according to the value of the suspension mark field. For example, if the value of the suspend flag field is 1, it indicates that the process has a suspend flag, which is a suspended process; if the value of the suspend flag field is 0, it indicates that the process does not have a suspend flag and is not a suspended process. In the implementation mode, whether the suspended process exists or not can be rapidly and accurately determined by determining whether the process with the suspension mark exists in the three-party background process, so that the operation efficiency of an algorithm is improved, and further, the process management and control efficiency is improved.
S112, recovering the suspended process in the background three-way process, and ending the flow.
Specifically, if the system load does not exceed the preset blocking threshold, which indicates that the system load is reduced, the suspended process may be activated. After the process is activated, the state of the process changes to a ready state.
Optionally, the electronic device may generate a process recovery policy by using the load controller according to the PID of the suspended process, and send the process recovery policy to the process suspension interface, where the process suspension interface performs activation of the process.
In this embodiment, under the condition that the system load exceeds a preset blocking threshold, a target process with a larger load in a background three-way process is obtained, a process to be suspended is determined based on the target process, and a process which does not hold a lock in the process to be suspended is suspended. The suspended process does not occupy physical resources of the electronic equipment any more, so that the system load can be effectively reduced, the system operation efficiency is improved, the blocking is reduced, and the user experience is improved. Meanwhile, the process with the lock in the process to be suspended is not suspended, so that the process with the lock can be prevented from continuously occupying shared resources, further, other processes are prevented from being blocked and unable to operate due to waiting for the lock, system blocking is prevented, the background management and control effect is improved, and the system performance and fluency are improved. In addition, under the condition that the system load does not exceed the preset blocking threshold, the suspended process in the background three-way process is recovered, so that the process can be prevented from being suspended for a long time to influence APP operation, and the influence on normal use of a user can be reduced as much as possible while the background process is controlled, and the user experience is further improved.
Alternatively, in other embodiments, the above process may be repeatedly executed after the execution of the above step flow is finished and then returned to step S101, so as to continuously control the process. Specifically, when the result of step S110, determining whether all the processes to be suspended execute step S108 is yes, returning to execute step S101; and when the result of determining whether the suspended process exists in the three-way background process in the step S111 is no, returning to the step S101; after the process suspended in the three-way background process is resumed in step S112, the process returns to step S101.
Fig. 6 is a schematic flow chart of a process control method according to another embodiment. Based on the embodiment shown in fig. 5, the method provided in this embodiment may further monitor the process with the lock, and after determining that the process with the lock releases the lock, suspend the process (see the content in the dashed line box in fig. 6), that is, as long as the process with the lock in the previous execution period releases the lock, whether the current process belongs to the target process or not, suspend the process, so as to further release the resource of the electronic device, improve the performance and fluency of the electronic device, and further improve the user experience.
As shown in fig. 6, in the present embodiment, if the determination result of step S108 is yes, step S201 is further included before step S110:
s201, locking and marking the process a to be suspended.
Specifically, in step S108, when it is determined that the process to be suspended a holds a lock, the process to be suspended a may be marked with a lock, that is, a lock mark (also referred to as lock mark information) is added to the process to be suspended a, so as to monitor the process subsequently. Optionally, a lock flag field may be added to the data structure of the process a to be suspended, and the lock flag field is assigned, for example, if the process holds a lock, the lock flag field is assigned to 1, the process does not hold the lock, and the lock flag field is assigned to 0 or null.
In addition, in the case where the determination result of step S104 is yes, the method further includes the following steps (the following steps are performed as an example before step S201 in fig. 6):
s202, determining whether a history lock process exists in the background three-party process, if so, executing a step S203, and if not, executing a step S105; history lock processes refer to processes with lock flags.
Optionally, the electronic device may determine whether the process is a history lock process by calling a fourth preset API interface. Specifically, the fourth preset API interface is configured to query whether the process has a lock flag. The load controller inputs the PID of each process in the three-way background process into a fourth preset API interface, and the fourth preset API interface returns the value of the lock mark field of the process. And determining whether the process holds the lock according to the value of the lock mark field. For example, if the value of the lock flag field is 1, then the process is indicated as having a lock flag, and the process is determined to be a history lock process; if the value of the lock flag field is 0 or null, it indicates that the process does not have a lock flag, and the process is not a history lock process.
It will be appreciated that there may be 1 history lock process, and there may be multiple history lock processes. The following steps S203 to S205 are performed for any one history lock process b (i.e., the first history lock process):
s203, judging whether the history lock process b holds a lock or not; if not, executing step S204; if yes, go to step S205.
The process of the electronic device determining whether the history lock process b holds the lock may refer to step S108, which is not described herein.
If the history lock process b does not hold the lock, it indicates that the lock held by the process has been released, and step S204 is performed. If the history lock process b holds the lock, it indicates that the lock held by the process has not been released, and step S205 is performed.
S204, suspending the history lock process b, and performing suspending marking on the history lock process b, and then executing step S205.
The specific process of this step may be referred to above in step S109, and will not be described herein.
S205, judging whether all history lock processes execute the step S203; if yes, go to step S105; if not, the next history lock process is taken as a history lock process b, and the step S203 is executed again.
The following describes a module interaction procedure of the process control method provided in this embodiment, taking an example in which an electronic device has the module structure of fig. 3.
As described in the embodiment shown in fig. 3, the system probe module may send, in advance, a request to the API module to subscribe to information such as a background process, a system load, and a process load. And the API module calls a related interface to detect related information in response to the request, obtains a probe state, and reports the probe state to the system probe module. Optionally, the API module may report the probe status to the system probe module according to a reporting period required in the callback function of the system probe module. Meanwhile, the load controller can send a request for subscribing the probe state to the corresponding probe in the system probe module in advance, and the system probe module reports the probe state to the load management module after receiving the probe state reported by the API module. Optionally, the system probe module may report the probe state according to a reporting period required in the callback function of the load management module.
It will be appreciated that the above information subscription process need not be repeated. Therefore, in the following embodiments, the process control method provided in the embodiments of the present application will be described by taking a pre-completed information subscription process as an example, and the subscription process will not be described in detail.
Fig. 7 is a schematic block diagram illustrating an exemplary process management method according to an embodiment of the present application. As shown in fig. 7, the method includes:
S301, reporting a background process, a system load and a process load to the system probe module by the API module.
S302, the system probe module reports the background process, the system load and the process load to a load controller in the scheduling engine.
S303, the load controller determines a background three-way process according to the background process.
S304, the load controller judges whether the system load exceeds a preset clamping threshold; if yes, step S305 is executed, and if no, step S319 is executed.
S305, the load controller determines whether a history lock process exists in the three-way background process, if yes, the step S306 is executed, and if not, the step S311 is executed; history lock processes refer to processes with lock flags.
S306, the load controller judges whether each history lock process holds a lock or not; if not, step S307 is executed, and if yes, step S311 is executed.
S307, the load controller generates a first process suspension strategy according to the PID of the history lock process.
And S308, the load controller sends the first process suspension strategy to a process suspension interface in the scheduling executor.
S309, the process suspension interface calls an interface in the process manager to suspend the corresponding process according to the first process suspension strategy.
S310, the load controller marks the suspension of the history lock process.
S311, the load controller orders all the background three-way processes according to the sequence of the process load from large to small, and determines the top n-bit process in the order as the target process.
S312, the load controller determines a main process corresponding to each target process to obtain a process to be suspended.
S313, the load controller judges whether each process to be suspended has a lock or not; if not, step S314 is executed, and if yes, step S318 is executed.
S314, the load controller generates a second process suspension strategy according to the PID of the process to be suspended.
And S315, the load controller sends the second process suspension strategy to a process suspension interface in the scheduling executor.
S316, the process suspension interface calls an interface in the process manager to suspend the corresponding process according to the second process suspension strategy.
S317, the load controller carries out suspension marking on the process to be suspended.
S318, the load controller carries out lock marking on the process to be suspended.
S319, the load controller determines whether a process with a suspension identifier exists in the three-party background process; if yes, go to step S320.
S320, the load controller generates a process recovery strategy according to the PID of the process with the suspension mark.
S321, the load controller sends the process recovery strategy to a process suspension interface in the scheduling executor.
S322, the process suspension interface calls an interface in the process manager to activate the corresponding process according to the process recovery strategy.
It will be appreciated that in other embodiments, the load manager may also actively acquire probe status from the system probe module as desired. For example, before executing step S303, the load manager sends a request to acquire a background process to a background scanning probe in the system probe module, and the background process scanning probe sends the background process to the load manager in response to the request. For another example, the load manager sends a request to acquire a system load to a system load probe in the system probe module, and the system load probe sends the system load to the load manager in response to the request, before executing step S304. For another example, before executing step S311, the load manager sends a request for acquiring a process load to a process load probe in the system probe module, and the process load probe sends the process load to the load manager in response to the request. The embodiment of the application does not limit the specific mode of acquiring the probe state by the system load management, and can be selected according to actual requirements.
The above describes in detail an example of a process control method provided by an embodiment of the present application. It will be appreciated that the electronic device, in order to achieve the above-described functions, includes corresponding hardware and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application can divide the functional modules of the electronic device according to the method example, for example, each function can be divided into each functional module, for example, a detection unit, a processing unit, a display unit, and the like, and two or more functions can be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
It should be noted that, all relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein.
The electronic device provided in this embodiment is configured to execute the process control method, so that the same effects as those of the implementation method can be achieved.
In case an integrated unit is employed, the electronic device may further comprise a processing module, a storage module and a communication module. The processing module can be used for controlling and managing the actions of the electronic equipment. The memory module may be used to support the electronic device to execute stored program code, data, etc. And the communication module can be used for supporting the communication between the electronic device and other devices.
Wherein the processing module may be a processor or a controller. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. A processor may also be a combination that performs computing functions, e.g., including one or more microprocessors, digital signal processing (digital signal processing, DSP) and microprocessor combinations, and the like. The memory module may be a memory. The communication module can be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip and other equipment which interact with other electronic equipment.
In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device according to this embodiment may be a device having the structure shown in fig. 2.
The embodiment of the application also provides a chip system, as shown in fig. 8, which comprises at least one processor 801 and at least one interface circuit 802. The processor 801 and the interface circuit 802 may be interconnected by wires. For example, interface circuit 802 may be used to receive signals from other devices (e.g., a memory of an electronic apparatus). For another example, interface circuit 802 may be used to send signals to other devices (e.g., processor 801). The interface circuit 802 may, for example, read instructions stored in a memory and send the instructions to the processor 801. The instructions, when executed by the processor 801, may cause the electronic device to perform the various steps of the embodiments described above. Of course, the system-on-chip may also include other discrete devices, which are not particularly limited in accordance with embodiments of the present application.
The embodiment of the application also provides a computer readable storage medium, in which a computer program is stored, which when executed by a processor, causes the processor to execute the process control method of any of the above embodiments.
The embodiment of the application also provides a computer program product, which when run on a computer, causes the computer to execute the related steps to realize the process control method in the embodiment.
In addition, embodiments of the present application also provide an apparatus, which may be embodied as a chip, component or module, which may include a processor and a memory coupled to each other; the memory is used for storing computer-executed instructions, and when the device is running, the processor can execute the computer-executed instructions stored in the memory, so that the chip executes the process control method in each method embodiment.
The electronic device, the computer readable storage medium, the computer program product or the chip provided in this embodiment are used to execute the corresponding method provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding method provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (13)

1. A process control method performed by an electronic device, the method comprising:
acquiring at least one background three-party process running in the electronic equipment, wherein the background three-party process refers to a non-system process running in the background;
if the system load of the electronic equipment is larger than a preset blocking threshold, determining whether locks of all the history lock processes are released or not if at least one history lock process exists in the at least one background three-way process, wherein the history lock process is a process with lock mark information, and the lock mark information is marked when the process load meets a preset heavy load condition and the process holds locks;
if the lock of the first history lock process is released, suspending the first history lock process, wherein the first history lock process is any one process in the at least one history lock process;
determining at least one process to be suspended, wherein the process load of the process satisfies the preset heavy load condition, from the at least one background three-way process;
and if the first process to be suspended does not hold the lock, suspending the first process to be suspended, wherein the first process to be suspended is any process in the at least one process to be suspended.
2. The method of claim 1, wherein after suspending the first process to be suspended, the method further comprises:
and marking the first process to be suspended as a suspended process.
3. The method of claim 2, wherein the marking the first process to be suspended as a suspended process comprises:
and adding suspension mark information for the first process to be suspended.
4. The method according to claim 1, wherein the method further comprises:
and if the first process to be suspended holds a lock, marking the first process to be suspended as a process holding the lock.
5. The method of claim 4, wherein the marking the first process to be suspended as a process holding a lock comprises:
and adding lock mark information for the first process to be suspended.
6. The method of claim 1, wherein after suspending the first history lock process, the method further comprises:
the first history lock process is marked as a suspended process.
7. The method of claim 6, wherein the marking the first history lock process as a suspended process comprises:
And adding suspension mark information for the first history lock process.
8. The method of claim 1, wherein the predetermined heavy load condition is: the process load is positioned in the first n bits of the at least one background three-way process in the sequence from big to small, and the process to be suspended is a main process, wherein n is an integer greater than or equal to 1; the determining, from the at least one background three-party process, that the process load meets the at least one process to be suspended under the preset heavy load condition includes:
respectively acquiring the process load of each background three-way process;
sequencing the at least one background three-way process according to the sequence from big to small of the process load, and acquiring the processes of the first n bits in the sequencing to obtain n target processes;
and determining the at least one process to be suspended according to the main process corresponding to the target process.
9. The method of claim 8, wherein the determining the at least one process to be suspended according to the master process corresponding to the target process comprises:
if the first target process is a main process, determining the first target process as the process to be suspended, wherein the first target process is any one process in the n target processes;
And if the first target process is a sub-process, determining the main process corresponding to the first target process as the process to be suspended.
10. The method according to any one of claims 1 to 9, further comprising:
and if the suspended process exists in the at least one background three-party process under the condition that the system load of the electronic equipment is smaller than or equal to the preset blocking threshold value, recovering the suspended process.
11. The method of claim 10, wherein the suspended process is a process having suspension flag information.
12. An electronic device, comprising: a processor, a memory, and an interface;
the processor, the memory and the interface cooperate to cause the electronic device to perform the method of any one of claims 1 to 11.
13. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when executed by a processor, causes the processor to perform the method of any of claims 1 to 11.
CN202210590909.1A 2022-05-16 2022-05-27 Process management and control method and electronic equipment Active CN116028204B (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2022105309834 2022-05-16
CN202210530983 2022-05-16

Publications (2)

Publication Number Publication Date
CN116028204A CN116028204A (en) 2023-04-28
CN116028204B true CN116028204B (en) 2023-10-20

Family

ID=86080138

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210590909.1A Active CN116028204B (en) 2022-05-16 2022-05-27 Process management and control method and electronic equipment

Country Status (1)

Country Link
CN (1) CN116028204B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7484131B2 (en) * 2005-09-13 2009-01-27 International Business Machines Corporation System and method for recovering from a hang condition in a data processing system
CN109117256A (en) * 2018-07-12 2019-01-01 维沃移动通信有限公司 A kind of management method and terminal of background application
CN109992370A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Applied program processing method and device, electronic equipment, computer readable storage medium
CN110286961A (en) * 2019-06-27 2019-09-27 深圳市网心科技有限公司 Process based on physical host processor hangs up method and relevant device
CN111984428A (en) * 2020-07-20 2020-11-24 上海金仕达软件科技有限公司 Method, device and equipment for realizing spin lock during resource access
CN113448701A (en) * 2021-05-26 2021-09-28 北京声智科技有限公司 Multi-process outbound control method, system, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7484131B2 (en) * 2005-09-13 2009-01-27 International Business Machines Corporation System and method for recovering from a hang condition in a data processing system
CN109992370A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Applied program processing method and device, electronic equipment, computer readable storage medium
CN109117256A (en) * 2018-07-12 2019-01-01 维沃移动通信有限公司 A kind of management method and terminal of background application
CN110286961A (en) * 2019-06-27 2019-09-27 深圳市网心科技有限公司 Process based on physical host processor hangs up method and relevant device
CN111984428A (en) * 2020-07-20 2020-11-24 上海金仕达软件科技有限公司 Method, device and equipment for realizing spin lock during resource access
CN113448701A (en) * 2021-05-26 2021-09-28 北京声智科技有限公司 Multi-process outbound control method, system, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN116028204A (en) 2023-04-28

Similar Documents

Publication Publication Date Title
CN115599513B (en) Resource scheduling method and electronic equipment
US20210103470A1 (en) Method and Apparatus for Implementing Multiprocessing on Trusted Execution Environment (TEE), and System
CN110489213B (en) Task processing method and processing device and computer system
US20020004810A1 (en) System and method for synchronizing disparate processing modes and for controlling access to shared resources
CN104838360A (en) Quota-based resource management
TW201346766A (en) Hardware control method and apparatus
US20140026143A1 (en) Exclusive access control method and computer product
US20130298143A1 (en) Wait on address synchronization interface
US20230147786A1 (en) Thread Management Method and Apparatus
CN109840151B (en) Load balancing method and device for multi-core processor
CN116028204B (en) Process management and control method and electronic equipment
CN113342554A (en) IO multiplexing method, medium, device and operating system
CN105677481A (en) Method and system for processing data and electronic equipment
CN111831436A (en) Scheduling method and device of IO (input/output) request, storage medium and electronic equipment
CN116028210B (en) Resource scheduling method, electronic equipment and storage medium
CN111831432A (en) Scheduling method and device of IO (input/output) request, storage medium and electronic equipment
CN110825536A (en) Communication method and device between tasks in embedded real-time operating system
CN116027879B (en) Method for determining parameters, electronic device and computer readable storage medium
CN116027880A (en) Resource scheduling method and electronic equipment
CN116027878B (en) Power consumption adjustment method and electronic equipment
CN116055443B (en) Method for identifying social scene, electronic equipment and computer readable storage medium
CN116028211B (en) Display card scheduling method, electronic equipment and computer readable storage medium
CN116089055B (en) Resource scheduling method and device
CN116028209B (en) Resource scheduling method, electronic equipment and storage medium
WO2023202406A1 (en) Display method and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant