WO2019128588A1 - 进程处理方法和装置、电子设备、计算机可读存储介质 - Google Patents
进程处理方法和装置、电子设备、计算机可读存储介质 Download PDFInfo
- Publication number
- WO2019128588A1 WO2019128588A1 PCT/CN2018/117459 CN2018117459W WO2019128588A1 WO 2019128588 A1 WO2019128588 A1 WO 2019128588A1 CN 2018117459 W CN2018117459 W CN 2018117459W WO 2019128588 A1 WO2019128588 A1 WO 2019128588A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- priority
- dependent
- background
- electronic device
- resource
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/48—Indexing scheme relating to G06F9/48
- G06F2209/484—Precedence
Definitions
- the present application relates to the field of data processing, and in particular, to a process processing method and apparatus, an electronic device, and a computer readable storage medium.
- mobile operating systems provide a method for resource limitation of application processes.
- the process of the foreground application that is, the first process
- the process of the application running in the background that is, the background process
- the limitation is to provide more resources for the process of the foreground application to improve the operational efficiency of the foreground application.
- the embodiment of the present application provides a process processing method and device, an electronic device, and a computer readable storage medium.
- a process processing method including:
- the second process being a background process that is dependent on the first process
- the priority of the second process is adjusted to match the priority of the first process.
- a process processing device comprising:
- a first process acquiring module configured to acquire a first process that is running in an foreground of the electronic device
- a second process obtaining module configured to acquire a second process, where the second process is a background process that is dependent on the first process
- an adjustment module configured to adjust a priority of the second process to match a priority of the first process.
- An electronic device comprising a memory and a processor, wherein the memory stores a computer program, the computer program being executed by the processor, causing the processor to perform an operation of a process processing method in various embodiments of the present application .
- a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements operations of a process processing method in various embodiments of the present application.
- the process processing method and device, the electronic device, and the computer readable storage medium provided by the embodiment of the present application by acquiring the background process that is dependent on the first process, and adjusting the priority of the background process that is dependent on the first process to The priority that matches the first process. Since the first process has the highest priority and the background process has the lower priority, the priority of the background process that is dependent on the first process is adjusted, and the priority is adjusted to the priority matching the foreground priority.
- the second process can be prevented from being lower in priority and slow in processing, thereby affecting the foreground application, thereby improving the processing efficiency of the process running in the foreground.
- FIG. 1 is a schematic diagram showing the internal structure of an electronic device in an embodiment.
- FIG. 2 is a partial block diagram of a system in an electronic device in an embodiment.
- FIG. 3 is a flow chart of a process processing method in an embodiment.
- FIG. 4 is a flow chart of a process processing method in another embodiment.
- Figure 5 is a block diagram showing the structure of a process processing apparatus in an embodiment.
- Figure 6 is a block diagram showing the structure of a process processing apparatus in another embodiment.
- Figure 7 is a block diagram showing a portion of the structure of a handset in an embodiment.
- first may be referred to as a second process without departing from the scope of the invention, and similarly, a second process may be referred to as a first process. Both the first process and the second process are processes, but they are not the same process.
- an internal structure diagram of an electronic device includes a processor, memory, and display screen connected by a system bus.
- the processor is used to provide computing and control capabilities to support the operation of the entire electronic device.
- the memory is used to store data, programs, and/or instruction codes, etc., and the memory stores at least one computer program, which can be executed by the processor to implement the process processing method applicable to the electronic device provided in the embodiments of the present application.
- the memory may include a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random storage memory (Random-Access-Memory, RAM).
- the memory includes a non-volatile storage medium and an internal memory.
- Non-volatile storage media stores operating systems, databases, and computer programs.
- the database stores data related to a process processing method provided by the above various embodiments, such as information such as the name of each process or application.
- the computer program can be executed by a processor for implementing a process processing method provided by various embodiments of the present application.
- the internal memory provides a cached operating environment for operating systems, databases, and computer programs in non-volatile storage media.
- the display screen can be a touch screen, such as a capacitive screen or an electronic screen, for displaying interface information of an application corresponding to the first process, and can also be used for detecting a touch operation applied to the display screen, and generating corresponding instructions, such as before execution. Switching instructions for background applications, etc.
- the structure shown in FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied.
- the specific electronic device may be It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
- the electronic device further includes a network interface connected through a system bus, and the network interface may be an Ethernet card or a wireless network card, etc., for communicating with an external electronic device, for example, for communicating with a server.
- the network interface may be an Ethernet card or a wireless network card, etc.
- the external electronic device for example, for communicating with a server.
- a partial architectural diagram of an electronic device is provided.
- the architecture of the electronic device includes a JAVA spatial layer 210, a local framework layer 220, and a kernel space layer 230.
- the JAVA spatial layer 210 can include a freeze management application 212 through which the electronic device can implement a freeze policy for each application and freeze and thaw the related applications of the background power consumption.
- the resource priority and restriction management module 222 and the platform freeze management module 224 are included in the local framework layer 220.
- the electronic device can maintain different applications in different priorities and different resource organizations through the resource priority and limit management module 222, and adjust the resource group of the application according to the requirements of the upper layer to achieve optimized performance and save power. effect.
- the electronic device can allocate the tasks that can be frozen in the background to the frozen layer corresponding to the preset different levels according to the length of the entering freeze time through the platform freeze management module 224.
- the frozen layer can include three, respectively: the CPU Limit sleep mode, CPU freeze sleep mode, process deep freeze mode.
- the CPU restricts the sleep mode to limit the CPU resources occupied by the related processes, so that the related processes occupy less CPU resources, and the free CPU resources are tilted to other unfrozen processes, thereby limiting the occupation of CPU resources.
- the kernel space layer 230 includes a UID management module 231, a Cgroup module 232, a Binder management module 233, a process memory recovery module 234, and a freeze timeout exit module 235.
- the UID management module 231 is configured to implement an application-based User Identifier (UID) to manage resources of a third-party application or freeze. Compared with the Process Identifier (PID) for process management and control, it is easier to uniformly manage the resources of a user's application through UID.
- the Cgroup module 232 is used to provide a complete set of Central Processing Unit (CPU), CPUSET, memory, input/output (I/O), and Net related resource restriction mechanisms.
- the Binder management module 233 is used to implement the priority control of the background binder communication.
- the interface module of the local framework layer 220 includes a binder interface developed to the upper layer, and the upper layer framework or application sends a resource restriction or frozen instruction to the resource priority and restriction management module 222 and the platform freeze management module 224 through the provided binder interface.
- the process memory recovery module 234 is configured to implement the process deep freeze mode, so that when a third-party application is in a frozen state for a long time, the file area of the process is mainly released, thereby saving the memory module and speeding up the application next time. The speed at startup.
- the freeze timeout exit module 235 is configured to resolve an exception generated by the freeze timeout scenario.
- a process processing method is provided.
- the embodiment is applied to the electronic device shown in FIG. 1 as an example for description.
- the method includes:
- Operation 302 Acquire a first process that is running in the foreground of the electronic device.
- the first process represents a process that is running in the foreground.
- the process is a basic operation of a program on a certain data set in a computer. It is the basic unit for resource allocation and scheduling, and is the basis of the operating system structure.
- the operation of an application (APP) is usually reflected by the operation of multiple related processes.
- the process involved in the foreground application runtime is the first process
- the process involved in the background application runtime is the background process.
- the electronic device can obtain the first process when the foreground application is running.
- Each process can be executed as a task.
- the task formed by the first process is the foreground task
- the task formed by the background process is the background task.
- the electronic device For each process running in the front and back, the electronic device is set to have different priorities, and different priorities correspond to different resource limits. The higher the priority, the lower the limit on the resources available to it.
- the first process corresponds to being set to the highest priority and relatively higher than the priority of the background process.
- the same process when running in the foreground and running in the background, does not have the same priority.
- the priority in different states is not necessarily the same. For example, when the background process is unified, the priority of the background process is not necessarily the same at different times or when the first process is different.
- the electronic device may acquire the first process according to a preset frequency or according to the detected user operation instruction.
- the process identifier of the first process is obtained, and the process identifier is used to uniquely identify the corresponding process, and may be formed by a combination of one or more of a preset number of digits, a letter, or other characters.
- the process ID "0001" may be used to indicate the process A
- the "1234" may be the process B or the like.
- the electronic device can update the process running in the foreground and the process running in the background in real time according to its own running state.
- the first process pool of the corresponding first process and the background process pool of the background process can be set. Add the process ID of the first process to the first process pool, add the process ID of the background process to the background process pool, and update the first process pool and when it detects that the process running in the background is changed.
- the process ID in the background process pool For example, when it is detected that the process B changes from the background process to the first process, the process ID "1234" of the process B can be moved from the background process pool into the first process pool.
- the electronic device may set a corresponding foreground tag or background tag for each process, determine the process with the foreground tag as the first process, or determine the process with the background tag as the background process.
- the acquisition of the first process is achieved by obtaining a process with a foreground tag.
- Operation 304 Acquire a second process, where the second process is a background process that is dependent on the first process.
- a dependency representation indicates that a process needs to utilize data from one or more processes in order to successfully implement the relationship to the execution of that process.
- the two processes that have dependencies are the dependent process and the dependent process, and the electronic device will detect the background process that will be dependent on the first process as the second process.
- the electronic device may set a corresponding dependency flag to the detected background process that is dependent on the first process, and obtain a background process with the dependency mark from the background process pool, and use the background process as the second process.
- process A depends on process B, or process B is dependent on process A, that is, process A needs to utilize the data of process B to implement execution of process A.
- process A is a dependent process
- process B is the second process.
- the dependent process may also be the first process
- the second process may be a background process.
- the electronic device can detect from the background process collection to query whether there is a background process that is dependent on the first process.
- the method before the operation 304, the method further includes: detecting, in the background process set, whether there is a background process that is dependent on the first process, and if yes, using the background process as the second process.
- a background process collection refers to a collection formed by a background process that contains processes running in the background.
- the electronic device can traverse all the background processes and detect whether there is a background process that is dependent on the first process to improve the comprehensiveness of the detection of the background process.
- the electronic device can record dependencies between processes for all processes and record between dependent processes, which are dependent parties, and which are dependent parties.
- the dependent party of the first process that is, the background process that the first process depends on, may be queried according to a pre-established dependency relationship.
- Operation 306 adjusting the priority of the second process to match the priority of the first process.
- the electronic device may adjust its priority such that the adjusted priority matches the priority of the first process.
- the electronic device can set a matching relationship between the priority of the second process and the foreground priority. According to the matching relationship, the corresponding priority applied to the second process is obtained, and the priority of the second process is adjusted to the priority, and the resource limitation of the second process is reduced, so that the second process can be used.
- the degree of resource limitation matches the degree of restriction of the first process.
- the foreground priority indicates the priority of the first process.
- the priority that matches the priority of the first process may be the same priority as the priority of the first process. That is, the electronic device can adjust the priority of the second process to the same priority as the priority of the first process, so that the degree of restriction on the resources that can be used by the second process is the same as the limitation of the first process.
- the foregoing process processing method adjusts the priority of the background process that the first process depends on to the priority matched with the first process by acquiring the background process that is dependent on the first process. Since the priority of the first process is usually the highest, the limit of the resources that can be used is the lowest, and the priority of the background process is low, so as to prevent the background process from occupying too many resources, which affects the foreground application. However, there are situations in the background process that are dependent on the first process. When the background process is dependent on the execution efficiency, it will also affect the first process.
- the embodiment of the present application adjusts the priority of the second process to the priority matched with the foreground priority, thereby reducing the degree of limitation of resources that can be used by the second process, thereby improving the processing efficiency of the second process. Since the processing efficiency of the second process is improved, the processing efficiency of the first process depending on the second process is also improved.
- the method further includes: when the first process ends the dependency on the second process, restoring the priority of the second process to the pre-adjustment priority.
- the electronic device can detect whether the first process ends the dependency on the second process, and if so, restores the priority of the second process to the pre-adjustment priority.
- the first process does not always maintain a reliance on the second process.
- the dependency of the first process on the second process ends.
- the electronic device may detect the dependency between the first process and the second process in real time according to a preset frequency to detect whether the first process ends the dependence on the second process.
- the priority of the second process may be resumed, that is, the priority of the second process is restored to the pre-adjustment priority.
- the priority of the second process is restored, and the use limit of the available resources of the dependent resource that terminates the dependency is increased, thereby allowing more resources to be reserved for the first process.
- the use of the process further improves the processing efficiency of the first process.
- the electronic device can set priority 1 to priority 5 according to the priority, and the priority is 5 levels, and the higher the priority, the lower the limit on the resources that can be used.
- the electronic device may adjust the priority of the second process A from the priority 4 to the priority 1, so that the second process A has The highest priority is processed to improve the processing efficiency of the second process A, so that the first process can improve the efficiency of using the data of the second process A to improve the processing efficiency of the first process; when detecting that the first process has been When the dependency on the second process A is ended, since the first process is not dependent on the second process A, the priority of the second process A is restored, and the priority of the second process A is determined by the priority 1. Adjust to priority 4 to reserve more available resources for use by the first process, further improving the efficiency of the first process.
- the method before the operation 304, the method further includes: when there is a communication mechanism between the background process and the first process, the background process having the communication mechanism is used as the second process.
- the electronic device can detect, in the background process set, whether there is a background process having a communication mechanism with the first process, and determine the background process having the communication mechanism as the background process that is dependent on the first process.
- the interaction mechanism between processes is mainly divided into a synchronization mechanism and a communication mechanism.
- the communication mechanism includes socket, binder, shared memory and so on.
- the two programs on the network exchange data through a two-way communication connection.
- One end of the connection is called a socket.
- Binder is an interprocess communication mechanism that provides remote procedure call functionality.
- Shared memory allows two unrelated processes to access the same logical memory. Shared memory is a very efficient way to share and transfer data between two running processes. The memory shared between different processes is usually arranged as The same piece of physical memory.
- the electronic device may detect, by any one or several of the following methods, whether there is a background process that has a communication mechanism with the first process:
- the electronic device may traverse the background process to detect whether there is a background process with socket and/or binder communication with the first process, and if so, the detected background process is regarded as the second process. It is also possible to detect whether there is a background process for memory sharing with the first process, and if so, the detected background process is also used as the second process.
- the electronic device may set a detection mechanism for whether there is a Binder communication between the first process and the background process in the Binder driver, and invoke a detection mechanism set in the Binder driver to detect the presence of the first process.
- the background process of the Binder communication will detect the background process as the second process.
- the electronic device can detect individual lock resources, including thread locks, file handles, signals, and the like. For each lock resource, it can be detected whether a lock wait occurs, that is, the lock resource waits. When it is detected that a lock wait is generated, it may be further detected whether the behavior of the occurrence of the wait occurs on the first process. If so, all the background processes waiting for the lock resource are traversed, and the detected background processes waiting on the lock resource are regarded as the second process.
- the electronic device may set a lock resource monitoring module and a priority adjustment module in a kernel space of the operating system, and embed the lock resource monitoring module into the kernel's native waiting interface.
- the lock resource monitoring module detecting thread locks, file handles, signals, etc. lock various lock resources, whether a wait occurs, whether the waiting behavior occurs on the first process, and if it occurs on the foreground task, it will detect
- the incoming message is sent to the priority adjustment module.
- This background process is used as the second process by traversing all the background threads waiting for the lock resource through the priority adjustment. And the priority of the second process is adjusted to the matching priority by the priority adjustment module.
- the method before the operation 304, the method further includes: when there is a synchronization mechanism between the background process and the first process, the background process having the synchronization mechanism is used as the second process.
- the electronic device may also detect, by calling the futex system call, whether there is a background process having a synchronization mechanism with the first process in the background process set, and determine the background process having the synchronization mechanism as the background process that is dependent on the first process.
- the user mode synchronization mechanism can be implemented by calling the futex system call.
- the user state refers to the non-privileged state.
- Synchronization mechanisms include semaphores, mutex locks, and more.
- the detected background process having the communication mechanism and/or the synchronization mechanism with the first process is used as the second process. Improve the efficiency of detection of the second process.
- the method before operation 306, the method further includes: detecting whether a resource required when the second process is executed is greater than a maximum allowed resource corresponding to a current priority of the second process, and if yes, performing operation 306, otherwise, maintaining The priority of the second process is unchanged.
- the electronic device may further detect that resources required by the second process when being executed are sufficient.
- the required resources represent the largest resources that the process needs to occupy at various times when it is executed.
- the electronic device sets a corresponding resource limitation degree, and the maximum allowed resources of different resource limitation levels are different. That is, different priorities correspond to different maximum allowed resources.
- the maximum allowed resource represents the maximum resource that the process is allowed to use at various times.
- the foregoing resources may include a CPU, an I/O file resource, and the like.
- the electronic device can detect that the second process is at a corresponding priority, and the maximum allowed resource that is limited is greater than the resource that is required to be executed. If yes, the resource required for executing the second process is sufficient, and the Its priority is adjusted. When any of the resources required by the second process is less than the maximum allowed resource of the corresponding category, the above operation 306 is performed.
- the resource as the memory as an example, when the memory required for the execution of the second process is 20 Mb, and the maximum allowable memory corresponding to the priority of the second process is 15 Mb, it is determined that the second process is required to be executed.
- the resource is smaller than the corresponding maximum allowed resource, so that operation 306 is continued, and the priority of the second process is adjusted, thereby implementing adjustment of the corresponding maximum allowed resource.
- the second process when the second process is in a frozen state, or the CPU usage limit of the second process is less than the CPU usage limit of the first process, performing the adjustment of the priority of the second process to the priority of the first process The level matches the priority.
- the electronic device may detect whether the second process is in a frozen state; and/or detect that the CPU usage limit of the second process is less than the CPU usage limit of the first process.
- the electronic device For each process, the electronic device also records the corresponding process state, and the process state includes a frozen state and an operational state.
- the frozen state indicates that the process is still there, but it is not allowed to run and occupy resources such as memory.
- the runnable state is the state that allows the process to run.
- operation 306 is performed.
- the CPU usage limit of the second process may be further detected, and the CPU usage limit of the second process is compared with the CPU usage limit of the first process, when the second detection is detected. If the CPU usage limit of the process is less than the CPU usage limit of the first process, the same resource is determined to be greater than the maximum allowed resource, and operation 306 is performed.
- the second process is detected when the resource required for the second process is greater than the maximum allowed resource corresponding to the current priority of the second process, and when the required resource is greater than the corresponding maximum allowed resource.
- the priority is adjusted to the priority that matches the priority of the first process. If the required resources are sufficient, the priority adjustment is not necessary, and the operation of the electronic device can be reduced.
- the second process includes a first dependent process and a second dependent process; the second dependent process is directly dependent on the first dependent process, and the first dependent process is directly or indirectly dependent by the first process .
- the method further includes: when the first dependent process is awakened, determining that the first process ends the dependency on the second dependent process.
- the electronic device can detect whether the first dependent process is woken up, and if so, restore the priority of the second dependent process to the pre-adjustment priority.
- dependencies between processes include direct dependencies and indirect dependencies.
- Process A is directly dependent on the data of process B.
- Process B is directly dependent on the data of process C, and process C is also directly dependent on the data of process D. That is, the dependency between processes A to D is a chained dependency.
- the dependencies between adjacent processes on the chain dependency are direct dependencies, while the dependencies between adjacent processes are indirect dependencies. That is, process A is directly dependent on process B, process B is directly dependent on process C, and process C is directly dependent on process B.
- Process A is indirectly dependent on process C and process D, while process B is also indirectly dependent on process D.
- the electronic device can acquire all background processes that are directly and indirectly dependent on the first process.
- a certain second process directly depends on another second process
- the certain second process may be recorded as the first dependent process
- a second process can be recorded as the second dependent process.
- the first dependent process is directly dependent on the second dependent process
- the first dependent process is definitely indirectly dependent on the first process
- the second dependent process may be directly processed by the first process.
- Dependencies may also be indirectly dependent on the first process.
- the electronic device may sequentially wake up in a dependent order for all processes that have a chain-dependent relationship, so that when a certain second process completes execution, the process directly depends on the second process. And execute.
- the above processes A to D can wake up the process D first, and when the process D is completed, the process C is awakened and executed.
- the electronic device can detect whether the first dependent process is awakened. When the first dependent process is woken up, it indicates that the second dependent process directly dependent on the first dependent process has been executed, or the second is dependent. The resources occupied by the process have been released, that is, the first dependent process has no need to rely on the second dependent process. Similarly, the first process will no longer depend on the second dependent process, and the foreground thread can be determined to be The dependency of the dependent process is terminated. Therefore, the priority of the second dependent process can be restored to the original priority.
- FIG. 4 another process processing method is provided, the method comprising:
- Operation 402 Acquire a first process that is running in the foreground of the electronic device.
- the electronic device may record a process identifier that is switched to a process running in the foreground, and obtain a corresponding first process according to the process identifier.
- the first process may include multiple.
- the electronic device may send a priority adjustment instruction to the first process to the resource priority and restriction management module 222 through the Binder interface through the freeze management application 212 in FIG. 2, the resource priority And the restriction management module 222 adjusts the priority of the first process to the highest level priority by the received priority adjustment instruction, so that the resource restriction degree of the first process is the lowest.
- Operation 404 obtaining a second process, the second process being a background process that is dependent on the first process.
- the electronic device can detect, in the background process set, whether there is a background process that is dependent on the first process, and the background process that is to be used by the first process is the second process.
- the resource priority and limit management module 222 can query from all the background processes to detect whether there is a background process that is dependent on the first process, and the queried process that is queried is used as the second process.
- the first process may be detected whether the first process has an interaction mechanism such as a synchronization mechanism or a communication mechanism with one or more background processes, and if so, the one or more background processes are regarded as the second process.
- the detection of the synchronization mechanism it can be realized by calling the futex system call; for the detection of the communication mechanism, the detection can be performed by the binder driver.
- Operation 406 detecting whether the resource required when the second process is executed is greater than the maximum allowed resource corresponding to the current priority of the second process, and if so, performing operation 408; otherwise, performing operation 414.
- the electronic device may set a plurality of different priorities through the resource priority and restriction management module 222 and the Cgroup module 232, and a resource limitation level corresponding to each priority.
- Restricted resources may include resources such as CPU, CPUSET, memory, I/O, and Net.
- the different priorities can be different for the maximum resources that can be occupied. The lower the priority of the resource, the lower the resource limit, and the larger the maximum resources allowed. Different background processes are not necessarily in the same priority, and the resources required are not necessarily the same.
- the electronic device may compare the required resources that are dependent on the background and the corresponding maximum allowed resources. When any of the required resources is greater than the maximum allowed resource of the corresponding item, the operation 408 is performed, when the required resources of each phase are smaller than the corresponding resources. When the maximum allowed resource of the item is performed, operation 410 is performed.
- Operation 408 adjusting the priority of the second process to be the same as the priority of the first process.
- the electronic device may send a priority adjustment instruction to the second process to the resource priority and limit management module 222 through the Binder interface, where the second process is a background process that determines that the process priority adjustment is needed. Understandably, not all of the second processes require process priority adjustments, and some of them can be adjusted.
- the resource priority and restriction management module 222 adjusts the priority of the corresponding second process to be the same as the foreground priority, and reduces the resource limitation thereof, so that the second process can be executed as soon as possible. Prevent the front-end application from getting stuck.
- Operation 410 detecting if the first dependent process is awakened, and if so, performing operation 412, otherwise, performing operation 414.
- Operation 412 restores the priority of the second dependent process to the pre-adjustment priority.
- the second process may include multiple, and the plurality of second processes include a background process directly dependent on the foreground, and may also include a background process that is indirectly dependent on the first process, that is, the second process may be The first dependent process and the second dependent process are included. The first dependent process is directly dependent on the second dependent process.
- the second dependent process When the second dependent process completes the operation of the dependent lock resource required by the first dependent process, it will sequentially wake up all the second processes (including the first dependent process) that are waiting on the lock resource. ) and in turn perform the second process of waking up.
- the dependent process execution speed is very fast, so that the lock resources held by itself can be quickly released to make the dependency
- the process of the lock resource is successfully executed, and then the wake-up foreground task is quickly started to perform the next normal execution operation.
- the second dependent process has released the lock resource, and the first dependent process waiting for the lock resource terminates the dependency on the process and is woken up, and the priority of the second dependent process can be performed. reduction.
- the priority of the second process is not adjusted to remain unchanged. After the second process has not been executed, it can be kept at the same priority as the first process until the process is executed. The executed process still maintains the original low priority operation, and does not always acquire high priority and does not release, thus affecting the performance of the system.
- FIGS. 3 and 4 are sequentially displayed as indicated by the arrows, these operations are not necessarily performed in the order indicated by the arrows. Except as expressly set forth herein, there is no strict ordering for the performance of these operations, and these operations can be performed in other orders. Moreover, at least some of the operations in FIGS. 3 and 4 may include multiple sub-operations or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, or The order of execution of the stages is also not necessarily sequential, but may be performed alternately or alternately with at least a portion of the sub-operations or stages of other operations or other operations.
- a process processing apparatus comprising:
- the first process obtaining module 502 is configured to acquire a first process that is running in the foreground of the electronic device.
- the second process obtaining module 504 is configured to obtain a second process, where the second process is a background process that is dependent on the first process.
- the adjusting module 506 is configured to adjust the priority of the second process to match the priority of the first process.
- the adjustment module 506 is further configured to restore the priority of the second process to the pre-adjustment priority when the first process ends the dependency on the second process.
- FIG. 6 another process processing apparatus is provided, the apparatus further comprising:
- the process detection module 608 is configured to use a background process having a communication mechanism as the second process when a communication mechanism exists between the background process and the first process.
- the process detection module 608 is further configured to determine that there is a communication mechanism between the background process and the first process when there is socket communication, binder communication, memory sharing, or lock waiting between the background process and the first process.
- the process detection module 608 is further configured to use a background process having a synchronization mechanism as the second process when there is a synchronization mechanism between the background process and the first process.
- the adjusting module 506 is further configured to detect whether a resource required when the second process is executed is greater than a maximum allowed resource corresponding to a current priority of the second process; if yes, adjust a priority of the second process to The priority that matches the priority of the first process; otherwise, the priority of the second process remains unchanged.
- the adjusting module 506 is further configured to: when the second process is in a frozen state, or the CPU usage limit of the second process is less than the CPU usage limit of the first process, perform the adjustment of the priority of the second process to The priority that matches the priority of the first process.
- the second process includes a first dependent process and a second dependent process; the second dependent process is directly dependent on the first dependent process, and the first dependent process is directly or indirectly dependent by the first process .
- the adjustment module 506 is further configured to determine that the first process ends the dependency on the second dependent process when the first dependent process is woken up.
- the adjustment module 506 is further configured to adjust the priority of the second process to be the same as the priority of the first process.
- the process processing apparatus described above adjusts the priority of the background process that the first process depends on to the priority matched with the first process by acquiring the background process that is dependent on the first process. Since the priority of the first process is usually the highest, the limit of the resources that can be used is the lowest, and the priority of the background process is low, so as to prevent the background process from occupying too many resources, which affects the foreground application. However, there are situations in the background process that are dependent on the first process. When the background process is dependent on the execution efficiency, it will also affect the first process.
- the application adjusts the priority of the second process to the priority matching the foreground priority, so that the limitation of the resources that can be used by the second process can be reduced, thereby improving the processing efficiency of the second process. Since the processing efficiency of the second process is improved, the processing efficiency of the first process depending on the second process is also improved.
- each module in the above process processing device is for illustrative purposes only. In other embodiments, the process processing device may be divided into different modules as needed to complete all or part of the functions of the process processing device.
- process processing device For the specific definition of the process processing device, reference may be made to the limitation of the process processing method in the above, and details are not described herein again.
- Each of the above-described process processing devices may be implemented in whole or in part by software, hardware, and combinations thereof.
- Each of the above modules may be embedded in or independent of the processor in the electronic device, or may be stored in a memory in the electronic device in a software format, so that the processor calls to perform operations corresponding to the above modules.
- each module in the process processing apparatus may be in the form of a computer program.
- the computer program can run on an electronic device such as a terminal or a server.
- the program module of the computer program can be stored on a memory of the electronic device.
- the computer program is executed by the processor, the operation of the process processing method described in the embodiment of the present application is implemented.
- an electronic device including a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor performing the process processing provided by the foregoing embodiments when executing the computer program The operation of the method.
- a computer readable storage medium having stored thereon a computer program for performing process processing as described in various embodiments of the present application when executed by a processor The operation of the method.
- a computer program product comprising instructions, when executed on a computer, causes the computer to perform the process processing methods described in the various embodiments of the present application.
- the embodiment of the present application also provides a computer device. As shown in FIG. 7 , for the convenience of description, only the parts related to the embodiments of the present application are shown. If the specific technical details are not disclosed, please refer to the method part of the embodiment of the present application.
- the computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, a wearable device, and the like, taking a computer device as a mobile phone as an example. :
- FIG. 7 is a block diagram showing a part of a structure of a mobile phone related to a computer device according to an embodiment of the present application.
- the mobile phone includes: a radio frequency (RF) circuit 710, a memory 720, an input unit 730, a display unit 740, a sensor 750, an audio circuit 760, a wireless fidelity (WiFi) module 770, and a processor 780. And power supply 790 and other components.
- RF radio frequency
- the RF circuit 710 can be used for receiving and transmitting signals during the transmission and reception of information or during a call.
- the downlink information of the base station can be received and processed by the processor 780.
- the uplink data can also be sent to the base station.
- RF circuits include, but are not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
- LNA Low Noise Amplifier
- RF circuitry 710 can also communicate with the network and other devices via wireless communication.
- the above wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (Code Division). Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
- GSM Global System of Mobile communication
- GPRS General
- the memory 720 can be used to store software programs and modules, and the processor 780 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 720.
- the memory 720 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.);
- the data storage area can store data (such as audio data, address book, etc.) created according to the use of the mobile phone.
- memory 720 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
- the input unit 730 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function controls of the handset 700.
- the input unit 730 may include a touch panel 731 and other input devices 732.
- the touch panel 731 also referred to as a touch screen, can collect touch operations on or near the user (such as the user using a finger, a stylus, or the like on the touch panel 731 or near the touch panel 731. Operation) and drive the corresponding connection device according to a preset program.
- the touch panel 731 can include two portions of a touch detection device and a touch controller.
- the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
- the processor 780 is provided and can receive commands from the processor 780 and execute them.
- the touch panel 731 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
- the input unit 730 may also include other input devices 732.
- other input devices 732 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
- the display unit 740 can be used to display information input by the user or information provided to the user as well as various menus of the mobile phone.
- the display unit 740 can include a display panel 741.
- the display panel 741 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
- the touch panel 731 can cover the display panel 741. When the touch panel 731 detects a touch operation on or near it, the touch panel 731 transmits to the processor 780 to determine the type of the touch event, and then the processor 780 is The type of touch event provides a corresponding visual output on display panel 741.
- touch panel 731 and the display panel 741 are used as two independent components to implement the input and input functions of the mobile phone in FIG. 7, in some embodiments, the touch panel 731 can be integrated with the display panel 741. Realize the input and output functions of the phone.
- the handset 700 can also include at least one type of sensor 750, such as a light sensor, motion sensor, and other sensors.
- the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 741 according to the brightness of the ambient light, and the proximity sensor may close the display panel 741 and/or when the mobile phone moves to the ear. Or backlight.
- the motion sensor may include an acceleration sensor, and the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
- the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
- Audio circuitry 760, speaker 761, and microphone 762 can provide an audio interface between the user and the handset.
- the audio circuit 760 can transmit the converted electrical data of the received audio data to the speaker 761 for conversion to the sound signal output by the speaker 761; on the other hand, the microphone 762 converts the collected sound signal into an electrical signal by the audio circuit 760. After receiving, it is converted into audio data, and then processed by the audio data output processor 780, transmitted to another mobile phone via the RF circuit 710, or outputted to the memory 720 for subsequent processing.
- WiFi is a short-range wireless transmission technology
- the mobile phone can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 770, which provides users with wireless broadband Internet access.
- FIG. 7 shows the WiFi module 770, it can be understood that it does not belong to the essential configuration of the mobile phone 700 and can be omitted as needed.
- the processor 780 is the control center of the handset, which connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 720, and invoking data stored in the memory 720, The phone's various functions and processing data, so that the overall monitoring of the phone.
- processor 780 can include one or more processing units.
- the processor 780 can integrate an application processor and a modem, wherein the application processor primarily processes an operating system, a user interface, an application, etc.; the modem primarily processes wireless communications. It will be appreciated that the above described modem may also not be integrated into the processor 780.
- the processor 780 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem.
- the handset 700 also includes a power source 790 (such as a battery) that supplies power to the various components.
- the power source can be logically coupled to the processor 780 via a power management system to manage functions such as charging, discharging, and power management through the power management system.
- the handset 700 can also include a camera, a Bluetooth module, and the like.
- the processor included in the mobile phone implements the process processing method described above when executing a computer program stored in the memory.
- Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
- Volatile memory can include random access memory (RAM), which acts as an external cache.
- RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronization.
- SRAM static RAM
- DRAM dynamic RAM
- SDRAM synchronous DRAM
- DDR SDRAM dual data rate SDRAM
- ESDRAM enhanced SDRAM
- synchronization Link (Synchlink) DRAM (SLDRAM), Memory Bus (Rambus) Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM).
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Computer And Data Communications (AREA)
- Information Transfer Between Computers (AREA)
Abstract
一种进程处理方法包括:获取处于电子设备前台运行的第一进程;获取第二进程,所述第二进程为被所述第一进程所依赖的后台进程;将所述第二进程的优先级调整至与所述第一进程的优先级相匹配。
Description
相关申请的交叉引用
本申请要求于2017年12月29日提交中国专利局、申请号为201711488926X、发明名称为“进程处理方法和装置、电子设备、计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及数据处理领域,特别是涉及一种进程处理方法和装置、电子设备、计算机可读存储介质。
随着移动通信技术的发展,移动操作系统中都提供了对应用的进程进行资源限制的方法。传统的操作系统中,前台应用的进程(即第一进程)通常是不会进行资源限制的,而对于后台运行的应用的进程(即后台进程)则通过降低其优先级,来加以对资源使用的限制,以提供更多的资源给前台应用的进程使用,提高前台应用的操作效率。
然而,传统方法中,通常都是对所有后台进程进行资源限制,使资源全部向前台应用倾斜。然而现实情况是,当有部分进入到后台的进程的优先级较低,导致被限制资源以后,也会对第一进程也造成一定的影响,造成前台应用的响应速度变慢。因此,传统的进程处理方法中,前台应用的响应效率还有待提高。
发明内容
本申请实施例提供一种进程处理方法和装置、电子设备、计算机可读存储介质。
一种进程处理方法,包括:
获取处于电子设备前台运行的第一进程;
获取第二进程,所述第二进程为被所述第一进程所依赖的后台进程;及
将所述第二进程的优先级调整至与所述第一进程的优先级相匹配。
一种进程处理装置,所述装置包括:
第一进程获取模块,用于获取处于电子设备前台运行的第一进程;
第二进程获取模块,用于获取第二进程,所述第二进程为被所述第一进程所依赖的后台进程;及
调整模块,用于将所述第二进程的优先级调整至与所述第一进程的优先级相匹配。
一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行本申请各个实施例中的进程处理方法的操作。
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现本申请各个实施例中的进程处理方法的操作。
本申请实施例提供的进程处理方法和装置、电子设备、计算机可读存储介质,通过获取被第一进程的所依赖的后台进程,并将被第一进程所依赖的后台进程的优先级调整至与第一进程相配的优先级。由于通常第一进程的优先级最高,而后台进程的优先级较低,通过调整被第一进程依赖的后台进程的优先级,并将该优先级调整至与前台优先级相匹配的优先级,可防止第二进程的优先级较低而处理缓慢,对前台应用造成影响,因而提高了前台运行的进程的处理效率。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中电子设备的内部结构示意图。
图2为一个实施例中电子设备中的系统的部分框架示意图。
图3为一个实施例中进程处理方法的流程图。
图4为另一个实施例中进程处理方法的流程图。
图5为一个实施例中进程处理装置的结构框图。
图6为另一个实施例中进程处理装置的结构框图。
图7为一个实施例中手机的部分结构的框图。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
可以理解,本发明所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本发明的范围的情况下,可以将第一进程称为第二进程,且类似地,可将第二进程称为第一进程。第一进程和第二进程两者都是进程,但其不是同一进程。
在一个实施例中,如图1所示,提供了一种电子设备的内部结构示意图。该电子设备包括通过系统总线连接的处理器、存储器和显示屏。其中,该处理器用于提供计算和控制能力,支撑整个电子设备的运行。存储器用于存储数据、程序、和/或指令代码等,存储器上存储至少一个计算机程序,该计算机程序可被处理器执行,以实现本申请实施例中提供的适用于电子设备的进程处理方法。存储器可包括磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等非易失性存储介质,或随机存储记忆体(Random-Access-Memory,RAM)等。例如,在一个实施例中,存储器包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统、数据库和计算机程序。该数据库中存储有用于实现以上各个实施例所提供的一种进程处理方法相关的数据,比如可存储有每个进程或应用的名称等信息。该计算机程序可被处理器所执行,以用于实现本申请各个实施例所提供的一种进程处理方法。内存储器为非易失性存储介质中的操作系统、数据库和计算机程序提供高速缓存的运行环境。显示屏可以是触摸屏,比如为电容屏或电子屏,用于显示第一进程对应的应用的界面信息,还可以被用于检测作用于该显示屏的触摸操作,生成相应的指令,比如进行前后台应用的切换指令等。
本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。如该电子设备还包括通过系统总线连接的网络接口,网络接口可以是以太网卡或无线网卡等,用于与外部的电子设备进行通信,比如可用于同服务器进行通信。再比如该电子设备上并不存在通过系统总线连接的显示器,或者可连接外部显示设备。
在一个实施例中,如图2所示,提供了一种电子设备的部分架构图。其中,该电子设备的架构系统中包括JAVA空间层210、本地框架层220以及内核(Kernel)空间层230。JAVA空间层210上可包含冻结管理应用212,电子设备可通过该冻结管理应用212来实现对各个 应用的冻结策略,对后台耗电的相关应用做冻结和解冻等管理操作。本地框架层220中包含资源优先级和限制管理模块222和平台冻结管理模块224。电子设备可通过资源优先级和限制管理模块222实时维护不同的应用处于不同优先级和不同资源的组织中,并根据上层的需求来调整应用程序的资源组别从而达到优化性能,节省功耗的作用。电子设备可通过平台冻结管理模块224将后台可以冻结的任务按照进入冻结时间的长短,分配到对应预设的不同层次的冻结层,可选地,该冻结层可包括三个,分别是:CPU限制睡眠模式、CPU冻结睡眠模式、进程深度冻结模式。其中,CPU限制睡眠模式是指对相关进程所占用的CPU资源进行限制,使相关进程占用较少的CPU资源,将空余的CPU资源向其它未被冻结的进程倾斜,限制了对CPU资源的占用,也相应限制了进程对网络资源以及I/O接口资源的占用;CPU冻结睡眠模式是指禁止相关进程使用CPU,而保留对内存的占用,当禁止使用CPU资源时,相应的网络资源以及I/O接口资源也被禁止使用;进程深度冻结模式是指除禁止使用CPU资源之外,进一步对相关进程所占用的内存资源进行回收,回收的内存可供其它进程使用。内核空间层230中包括UID管理模块231、Cgroup模块232、Binder管控模块233、进程内存回收模块234以及冻结超时退出模块235。其中,UID管理模块231用于实现基于应用的用户身份标识(User Identifier,UID)来管理第三方应用的资源或进行冻结。相比较于基于进程身份标识(Process Identifier,PID)来进行进程管控,通过UID更便于统一管理一个用户的应用的资源。Cgroup模块232用于提供一套完善的中央处理器(Central Processing Unit,CPU)、CPUSET、内存(memory)、输入/输出(input/output,I/O)和Net相关的资源限制机制。Binder管控模块233用于实现后台binder通信的优先级的控制。其中,本地框架层220的接口模块包含开发给上层的binder接口,上层的框架或者应用通过提供的binder接口来发送资源限制或者冻结的指令给资源优先级和限制管理模块222和平台冻结管理模块224。进程内存回收模块234用于实现进程深度冻结模式,这样能当某个第三方应用长期处于冻结状态的时候,会主要释放掉进程的文件区,从而达到节省内存的模块,也加快该应用在下次启动时的速度。冻结超时退出模块235用于解决出现冻结超时场景产生的异常。通过上述的架构,可实现本申请各个实施例中的进程处理方法。
在一个实施例中,如图3所示,提供了一种进程处理方法,本实施例以该方法应用于如图1所示的电子设备为例进行说明。该方法包括:
操作302,获取处于电子设备前台运行的第一进程。
第一进程表示处于前台运行的进程。电子设备中有多个处于运行状态的进程,进程(process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础。一个应用(Application,简称APP)的运行通常是由相关的多个进程的运行而体现的。前台应用运行时涉及的进程即为第一进程,后台应用运行时涉及的进程即为后台进程。电子设备可获取处于前台应用运行时的第一进程。每个进程可作为一个任务(task)而执行,由第一进程形成任务即为前台任务,后台进程形成的任务即为后台任务。
针对每个处于前后台运行的进程,电子设备设置了对应不同的优先级,不同的优先级对应不同的资源限制程度。优先级越高的进程,对其可使用的资源的限制程度越低。通常地,第一进程对应被设置了最高的优先级,且相对高于后台进程的优先级。同一个进程,处于前台运行时以及处于后台运行时的优先级不一定相同。且同一个后台进程,处于不同状态下的优先级也不一定相同。比如,统一后台进程,在不同的时刻,或者第一进程不同时,该后台进程的优先级也不一定相同。
电子设备可按照预设的频率或者根据检测到的用户操作指令来获取第一进程。可选地,可获取该第一进程的进程标识,进程标识用于唯一标识对应的进程,可由预设位数的数字、字母或者其他字符中的一种或几种的组合所构成。比如,可以以进程标识“0001”表示进程A,以“1234”表示进程B等。
电子设备可根据自身的运行状态来实时更新处于前台运行的进程以及处于后台运行的进程,可选地,可设置对应的第一进程的第一进程池,以及后台进程的后台进程池。将处于第一进程的进程标识加入该第一进程池中,将后台进程的进程标识加入该后台进程池中,并在检测到前后台运行的进程有变动时,对应更新该第一进程池和后台进程池中的进程标识。比如,当检测到进程B由后台进程变成第一进程时,可将该进程B的进程标识“1234”从后台进程池中移入第一进程池中。
在一个实施例中,电子设备可针对每个进程,设置对应的前台标记或后台标记,将具有前台标记的进程判定为第一进程,或者将具有后台标记的进程判定为后台进程。通过获取具有前台标记的进程,以实现对第一进程的获取。
操作304,获取第二进程,第二进程为被第一进程所依赖的后台进程。
依赖表示表示一个进程需要利用于另一个或多个进程的数据才能顺利实现对该一个进程的执行的关系。存在依赖关系的两个进程,分别为被依赖的进程和依赖的进程,电子设备将检测出的将被第一进程依赖的后台进程作为第二进程。电子设备可对检测出的被第一进程所依赖的后台进程设置对应的被依赖标记,并从后台进程池中获取带有被依赖标记的后台进程,将该后台进程作为第二进程。
举例来说,进程A依赖于进程B,或进程B被进程A依赖,即表示进程A需要利用进程B的数据才能实现对该进程A的执行,此时,进程A即为依赖的进程,进程B即为第二进程。可以理解地,依赖的进程还可能为第一进程,第二进程可能为后台进程。电子设备可从后台进程集合中进行检测,以查询出是否存在被第一进程依赖的后台进程。
在一个实施例中,在操作304之前,还包括:检测后台进程集合中,是否存在被第一进程依赖的后台进程,若是,则将该后台进程作为第二进程。
后台进程集合是指由后台进程所形成的集合,该后台进程集合中包含处于后台运行的进程。电子设备可遍历所有的后台进程,并检测是否存在被第一进程依赖的后台进程,以提高对后台进程检测的全面性。
在一个实施例中,电子设备可针对所有的进程,记录各个进程之间的依赖关系,并记录具有依赖关系的进程之间,哪些是依赖方,哪些是被依赖方。针对该第一进程,可按照预先建立的依赖关系,查询该第一进程的被依赖方,即被该第一进程所依赖的后台进程。
操作306,将第二进程的优先级调整至与第一进程的优先级相匹配。
可选地,针对查询出的第二进程,电子设备可对其优先级进行调整,使得调整后的优先级与该第一进程的优先级相匹配。电子设备可设置不同的第二进程的优先级与前台优先级的匹配关系。根据该匹配关系,获取对应的适用于第二进程的优先级,并将第二进程的优先级调整至该优先级,降低对第二进程的资源限制程度,使得对第二进程所能使用的资源的限制程度与第一进程的限制程度相匹配。其中,前台优先级即表示第一进程的优先级。
在一个实施例中,与该第一进程的优先级相匹配的优先级,可为与该第一进程的优先级相同的优先级。即电子设备可将该第二进程的优先级调整至与该第一进程的优先级相同的优先级,使得对第二进程所能使用的资源的限制程度与第一进程的限制程度相同。
上述进程处理方法,通过获取被第一进程所依赖的后台进程,将被第一进程所依赖的后台进程的优先级调整至与第一进程相配的优先级。由于通常第一进程的优先级最高,对应可使用的资源的限制程度最低,而后台进程的优先级较低,以防止后台进程占用过多的资源,对前台应用造成影响。然而后台进程中存在着被第一进程所依赖的情况,被依赖的后台进程执行效率时,也会对第一进程造成影响。本申请实施例通过调整第二进程的优先级调整至与前台优先级相匹配的优先级,从而可降低第二进程所能使用的资源的限制程度,从而提高了第二进程的处理效率。由于该第二进程的处理效率提高了,从而也提高了依赖于该第二进程的第一进程的处理效率。
在一个实施例中,在操作306之后,还包括:当第一进程结束对第二进程的依赖时, 将第二进程的优先级恢复至调整前的优先级。
电子设备可检测第一进程是否结束对第二进程的依赖,若是,则将第二进程的优先级恢复至调整前的优先级。
第一进程并非一直保持对第二进程的依赖。当第一进程已经不需要再依赖第二进程的数据时,则第一进程对第二进程的依赖结束。电子设备可按照预设的频率对该第一进程与第二进程之间的依赖关系进行实时检测,以检测是否第一进程是否结束对第二进程的依赖。可选地,当检测到第一进程对某一第二进程的依赖终止后,可恢复该第二进程的优先级,即将该第二进程的优先级恢复至调整前的优先级。
由于第一进程已经不再依赖于第二进程,因而将第二进程的优先级进行还原,提高终止依赖关系的被依赖资源对可用资源的使用限制,从而可留出更多的资源供第一进程使用,进一步提高了第一进程的处理效率。
举例来说,电子设备可按照优先级由高到低,分别设置优先级1至优先级5,共5级优先级,优先级越高的进程,对其可使用的资源的限制程度越低。当存在第二进程A,第二进程A处于被第一进程所依赖的状态时,电子设备可将该第二进程A的优先级由优先级4调整至优先级1,使得第二进程A具有最高的优先级进行处理,以提高第二进程A的处理效率,使得第一进程可提高对第二进程A的数据的使用效率,以提高第一进程的处理效率;当检测到第一进程已经结束对该第二进程A的依赖时,由于第一进程不在依赖于该第二进程A,故而对该第二进程A的优先级进行还原,将该第二进程A的优先级由优先级1调整至优先级4,以保留更多的可用资源给第一进程使用,进一步提高第一进程的使用效率。
在一个实施例中,在操作304之前,还包括:当后台进程与第一进程之间存在通信机制时,将具有通信机制的后台进程作为第二进程。
电子设备可检测后台进程集合中,是否存在与第一进程具有通信机制的后台进程,将具有通信机制的后台进程判定为被第一进程依赖的后台进程。
两个进程之间的相互依赖总是建立在它们需要互相通信的基础之上。在操作系统中,进程之间的交互机制主要分为同步机制和通信机制。其中,通信机制包括socket、binder、共享内存等。网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket。Binder是一种进程间通信机制,提供远程过程调用功能。共享内存就是允许两个不相关的进程访问同一个逻辑内存,共享内存是在两个正在运行的进程之间共享和传递数据的一种非常有效的方式,不同进程之间共享的内存通常安排为同一段物理内存。
在一个实施例中,当后台进程与第一进程之间存在socket通信、binder通信、内存共享或锁等待时,判定后台进程与第一进程之间存在通信机制。
可选地,电子设备可通过以下任意一种或几种方式检测是否存在与第一进程具有通信机制的后台进程:
(1)检测是否存在与第一进程具有socket和/或binder通信的后台进程;
(2)检测是否存在与第一进程之间进行内存共享的后台进程;
(3)检测是否存在第一进程等待在锁资源上的后台进程。
电子设备可遍历后台进程,检测是否存在与第一进程之间具有socket和/或binder通信的后台进程,若是,则将检测出的后台进程作为第二进程。还可检测是否存在与第一进程之间进行内存共享的后台进程,若是,则将检测出的后台进程也作为第二进程。
在一个实施例中,电子设备可在Binder驱动中设置对第一进程和后台进程之间是否存在Binder通信的检测机制,并调用在Binder驱动中设置的检测机制,以检测出与第一进程存在Binder通信的后台进程,将检测出的后台进程作为第二进程。
在一个实施例中,电子设备可检测各个锁资源,锁资源包括线程锁,文件句柄,信号等。针对每个锁资源,可检测是否发生锁等待,即锁资源等待。当检测到产生锁等待时, 可进一步检测该发生等待的行为是否发生在第一进程上。若是,则遍历等待在该锁资源上面的所有后台进程,将检测到的等待在该锁资源上的后台进程均作为该第二进程。
在一个实施例中,电子设备可在操作系统的内核空间中设置锁资源监控模块和优先级调整模块,将锁资源监控模块内嵌到内核原生的等待接口当中。通过该锁资源监控模块,检测线程锁,文件句柄,信号等锁各种锁资源,是否发生等待,发生等待的行为是否是发生在第一进程上面,如果是发生在前台任务上面,则将检测到的消息发送至优先级调整模块。通过该优先级调整遍历等待在该锁资源上面的所有后台线程,将这些后台进程作为第二进程。并通过该优先级调整模块将第二进程的优先级调整至相匹配的优先级。
在一个实施例中,在操作304之前,还包括:当后台进程与第一进程之间存在同步机制时,将具有同步机制的后台进程作为第二进程。
电子设备还可通过调用futex系统调用检测后台进程集合中,是否存在与第一进程具有同步机制的后台进程,将具有同步机制的后台进程判定为被第一进程依赖的后台进程。
并发程序设计中,各进程对公共变量的访问必须加以制约,这种制约称为同步。在操作系统中,用户态(user mode)的同步机制可通过调用futex系统调用实现。其中,用户态指非特权状态。同步机制包括信号量、互斥锁等。当通过futex系统调用检测到与第一进程存在任意一种同步机制的后台进程时,可将检测到的后台进程作为第二进程。
上述方法中,通过对第一进程和后台进程之间的通信机制和/或同步机制的检测,将检测出的与第一进程具有通信机制和/或同步机制的后台进程作为第二进程,可提高对第二进程的检测的效率。
在一个实施例中,在操作306之前,还包括:检测第二进程被执行时所需的资源是否大于第二进程的当前优先级对应的最大允许资源,若是,则执行操作306,否则,保持第二进程的优先级不变。
可选地,电子设备可在检测出第二进程后,进一步检测该第二进程在被执行时所需的资源是足够。其中,所需的资源表示进程在被执行的各个时刻下,所需占用的最大的资源。针对每种优先级,电子设备设置了对应的资源限制程度,不同的资源限制程度的最大允许资源不同。即不同的优先级对应不同的最大允许资源。最大允许资源表示进程在各个时刻下允许被使用的最大资源。
其中,上述的资源可包括CPU、I/O文件资源等。电子设备可检测该第二进程,处于对应的优先级上,被限制的最大允许资源是否大于被执行是所需的资源,若是,则说明执行该第二进程所需的资源足够,可不必对其优先级进行调整。当第二进程所需的任意一种资源小于对应种类的最大允许资源时,则执行上述的操作306。
以资源为内存来举例说明,当第二进程执行时所需的内存是20Mb,而该第二进程所处的优先级对应的最大允许内存为15Mb,则判定该第二进程被执行时所需的资源小于对应的最大允许资源,从而继续执行操作306,对该第二进程的优先级进行调整,从而实现对对应的最大允许资源的调整。
在一个实施例中,当第二进程处于冻结状态,或第二进程的CPU占用率限制小于第一进程的CPU占用率限制时,执行将第二进程的优先级调整至与第一进程的优先级相匹配的优先级。
电子设备可检测第二进程是否处于冻结状态;和/或检测第二进程的CPU占用率限制小于第一进程的CPU占用率限制。
针对每种进程,电子设备还记录了对应的进程状态,进程状态包括冻结状态和可运行状态。冻结状态时表示进程虽然还在,但是却不被允许运行和占内存等资源了。可运行状态即表示允许进程运行的状态。当检测到第二进程处于冻结状态时,则直接判定所需资源大于最大允许资源,并执行操作306。当检测到处于运行状态时,可进一步对第二进程的CPU占用率限制进行检测,将该第二进程的CPU占用率限制与第一进程的CPU占用率限制 进行比较,当检测出对第二进程的CPU占用率限制小于第一进程的CPU占用率限制时,则同样判定所需资源大于最大允许资源,并执行操作306。
上述方法中,通过对第二进程被执行时所需的资源是否大于第二进程的当前优先级对应的最大允许资源进行检测,当所需资源大于对应的最大允许资源时,再将第二进程的优先级调整至与第一进程的优先级相匹配的优先级,若所需资源足够,则可不必进行优先级调整,可减少电子设备的操作。
在一个实施例中,第二进程包括第一被依赖进程和第二被依赖进程;第二被依赖进程被第一被依赖进程直接依赖,第一被依赖进程被第一进程直接依赖或间接依赖。
在将第二进程的优先级调整至与第一进程的优先级相匹配之前,还包括:第一被依赖进程被唤醒时,判定第一进程结束对第二被依赖进程的依赖。
电子设备可检测第一被依赖进程是否被唤醒,若是,则将第二被依赖进程的优先级恢复至调整前的优先级。
可选地,进程之间的依赖关系包括直接依赖和间接依赖。比如,存在进程A、进程B、进程C和进程D这4个进程。进程A直接依赖于进程B的数据,进程B又直接依赖于进程C的数据,而进程C也直接依赖于进程D的数据。即进程A~D之间的依赖为一种链式的依赖。此时,处于该链式依赖上的相邻进程之间的依赖关系即为直接依赖,而非相邻进程之间的依赖关系为间接依赖。即进程A直接依赖于进程B、进程B直接依赖于进程C、进程C又直接依赖于进程B。而进程A间接依赖于进程C和进程D,而进程B也间接依赖于进程D。
电子设备可获取被第一进程直接依赖和间接依赖的所有后台进程。在被第一进程所依赖的多个第二进程中,当有某一第二进程直接依赖于另一第二进程时,则该某一第二进程可记为第一被依赖进程,而另一第二进程则可记为第二被依赖进程。可以理解地,由于第一被依赖进程是直接依赖于第二被依赖进程的,因此第一被依赖进程肯定被第一进程间接依赖,而该第二被依赖进程则可能是被第一进程直接依赖,还可能是被第一进程间接依赖。
在一个实施例中,电子设备可针对存在链式依赖的关系的所有进程,按照依赖的顺序进行顺序唤醒,以使得当某一第二进程完成执行后,唤醒直接依赖于该第二进程的进程并执行。比如上述的进程A~D,则可首先唤醒进程D,当进程D执行完毕后,则唤醒进程C并执行。
电子设备可检测第一被依赖进程是否被唤醒,当第一被依赖进程被唤醒后,则说明被第一被依赖进程所直接依赖的第二被依赖进程已经执行完毕,或着第二被依赖进程所占用的资源已经释放,即第一被依赖进程已经无需依赖于该第二被依赖进程,同样地,第一进程也不会再依赖于该第二被依赖进程,可判定前台线程对第二被依赖进程的依赖关系终止。因此,可将第二被依赖进程的优先级还原至原来的优先级。
上述方法中,通过对第一被依赖进程进行唤醒检测,当检测到第一被依赖进程唤醒后,则判定第一进程对第二被依赖进程的依赖关系终止,从而将第二被依赖进程的优先级恢复至调整前的优先级,可及时对完成运行的第二进程的优先级恢复,防止其较长时间对资源的占用,从而可提供更多的资源供第一进程使用,进一步提高了第一进程的执行效率。
在一个实施例中,如图4所示,提供了另一种进程处理方法,该方法包括:
操作402,获取处于电子设备前台运行的第一进程。
可选地,电子设备可记录切换至前台运行的进程的进程标识,根据该进程标识来获取对应的第一进程。其中,第一进程可包括多个。针对切换成前台运行的第一进程,电子设备可通过图2中的冻结管理应用212,通过Binder接口向资源优先级和限制管理模块222发送对第一进程的优先级调整指令,该资源优先级和限制管理模块222通过接收到的优先级调整指令将第一进程的优先级调整为最高级别的优先级,使得对第一进程的资源限制程度最低。
操作404,获取第二进程,第二进程为被第一进程所依赖的后台进程。
电子设备可检测后台进程集合中,是否存在被第一进程依赖的后台进程,将被第一进程依赖的后台进程作为第二进程。
可选地,可通过资源优先级和限制管理模块222从所有的后台进程中进行查询,以检测是否存在被第一进程依赖的后台进程,将查询出的被依赖的进程作为第二进程。
在一个实施例中,可检测第一进程是否存在与某一个或多个后台进程之间存在同步机制或通信机制等交互机制,若存在,则将该一个或多个后台进程作为第二进程。针对同步机制的检测,可通过调用futex系统调用实现;针对通信机制的检测,可通过binder驱动来进行检测。
操作406,检测第二进程被执行时所需的资源是否大于第二进程的当前优先级对应的最大允许资源,若是,则执行操作408,否则,执行操作414。
可选地,电子设备可通过资源优先级和限制管理模块222和Cgroup模块232设置多个不同的优先级,以及每个优先级对应的资源限制程度。被限制的资源可包括CPU、CPUSET、内存、I/O和Net等类型的资源。不同的优先级可被允许占用的最大资源不同,优先级预告的,资源限制程度越低,允许占用的最大资源也越大。不同的后台进程所处的优先级不一定相同,且所需占用的资源也不一定相同。电子设备可将被依赖后台的所需资源和对应的最大允许资源进行比较,当任意一项所需资源大于对应项的最大允许资源时,则执行操作408,当各相所需资源均小于对应项的最大允许资源时,则执行操作410。
操作408,将第二进程的优先级调整至与第一进程的优先级相同。
可选地,电子设备可通过Binder接口向资源优先级和限制管理模块222发送对第二进程的优先级调整指令,该第二进程为上述判定需要进程优先级调整的后台进程。可以理解地,并非所有的第二进程都需要进程优先级调整,可调整其中的部分。资源优先级和限制管理模块222接收到该优先级调整指令后,对相应的第二进程的优先级调整至与前台优先级相同,降低对其资源限制,以使得第二进程可尽快被执行,防止前台应用出现卡顿。
操作410,检测第一被依赖进程是否被唤醒,若是,则执行操作412,否则,执行操作414。
操作412,将第二被依赖进程的优先级恢复至调整前的优先级。
在一个实施例中,第二进程可包括多个,且该多个第二进程中,包含直接被前台依赖的后台进程,还可能包括间接被第一进程依赖的后台进程,即第二进程可包括第一被依赖进程和第二被依赖进程。第一被依赖进程直接依赖于第二被依赖进程。
当第二被依赖进程完成对第一被依赖进程所需的依赖的锁资源的操作的时候,就会依次唤醒等待(pending)在该锁资源上面的所有第二进程(包括第一被依赖进程)并依次执行唤醒的第二进程。
由于已经将第二进程的优先级提升到了与第一进程相匹配的优先级上,这样依赖进程执行的速度就会非常的快,从而能快速将本身持有的锁资源进行释放,以使得依赖于该锁资源的进程顺利执行,进而很快就开始唤醒睡眠中的前台任务进行下一步的正常执行操作。同时,第二被依赖进程已经对该锁资源进行了释放,等待该锁资源的第一被依赖进程则终止了对该进程的依赖并被唤醒,可将该第二被依赖进程的优先级进行还原。
操作414,保持第二进程的优先级不变。
当第二进程被执行时所需的资源小于或等于第二进程的当前优先级对应的最大允许资源时,则不对该第二进程进行优先级的调整,使其保持不变。当第二进程还未被执行完毕后,可使其保持与第一进程相同的优先级进行执行,直至该进程被执行完毕。已经执行完的进程依旧保持原来的低优先级运行,不会永远获取高优先级不释放,从而影响系统的性能。
应该理解的是,虽然图3和图4的流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作 的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,图3和图4中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。
在一个实施例中,如图5所示,提供了一种进程处理装置,该装置包括:
第一进程获取模块502,用于获取处于电子设备前台运行的第一进程。
第二进程获取模块504,用于获取第二进程,第二进程为被第一进程所依赖的后台进程。
调整模块506,用于将第二进程的优先级调整至与第一进程的优先级相匹配。
在一个实施例中,调整模块506还用于当第一进程结束对第二进程的依赖时,将第二进程的优先级恢复至调整前的优先级。
在一个实施例中,如图6所示,提供了另一种进程处理装置,该装置还包括:
进程检测模块608,用于当后台进程与第一进程之间存在通信机制时,将具有通信机制的后台进程作为第二进程。
在一个实施例中,进程检测模块608还用于当后台进程与第一进程之间存在socket通信、binder通信、内存共享或锁等待时,判定后台进程与第一进程之间存在通信机制。
在一个实施例中,进程检测模块608还用于当后台进程与第一进程之间存在同步机制时,将具有同步机制的后台进程作为第二进程。
在一个实施例中,调整模块506还用于检测第二进程被执行时所需的资源是否大于第二进程的当前优先级对应的最大允许资源;若是,则将第二进程的优先级调整至与第一进程的优先级相匹配的优先级;否则,保持第二进程的优先级不变。
在一个实施例中,调整模块506还用于当第二进程处于冻结状态,或第二进程的CPU占用率限制小于第一进程的CPU占用率限制时,执行将第二进程的优先级调整至与第一进程的优先级相匹配的优先级。
在一个实施例中,第二进程包括第一被依赖进程和第二被依赖进程;第二被依赖进程被第一被依赖进程直接依赖,第一被依赖进程被第一进程直接依赖或间接依赖。
调整模块506还用于第一被依赖进程被唤醒时,判定第一进程结束对第二被依赖进程的依赖。
在一个实施例中,调整模块506还用于将第二进程的优先级调整至与第一进程的优先级相同。
上述的进程处理装置,通过获取被第一进程所依赖的后台进程,将被第一进程所依赖的后台进程的优先级调整至与第一进程相配的优先级。由于通常第一进程的优先级最高,对应可使用的资源的限制程度最低,而后台进程的优先级较低,以防止后台进程占用过多的资源,对前台应用造成影响。然而后台进程中存在着被第一进程所依赖的情况,被依赖的后台进程执行效率时,也会对第一进程造成影响。本申请通过调整第二进程的优先级调整至与前台优先级相匹配的优先级,从而可降低第二进程所能使用的资源的限制程度,从而提高了第二进程的处理效率。由于该第二进程的处理效率提高了,从而也提高了依赖于该第二进程的第一进程的处理效率。
上述进程处理装置中各个模块的划分仅用于举例说明,在其他实施例中,可将进程处理装置按照需要划分为不同的模块,以完成上述进程处理装置的全部或部分功能。
关于进程处理装置的具体限定可以参见上文中对于进程处理方法的限定,在此不再赘述。上述进程处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
本申请实施例中提供的进程处理装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器等电子设备上运行。该计算机程序构成的程序模块可存储在电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述的进程处理方法的操作。
在一个实施例中,提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述各实施例所提供的进程处理方法的操作。
在一个实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序对处理器执行时,实现本申请各实施例中所描述的进程处理方法的操作。
在一个实施例中,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行本申请各实施例中所描述的进程处理方法。
本申请实施例还提供了一种计算机设备。如图7所示,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以计算机设备为手机为例:
图7为与本申请实施例提供的计算机设备相关的手机的部分结构的框图。参考图7,手机包括:射频(Radio Frequency,RF)电路710、存储器720、输入单元730、显示单元740、传感器750、音频电路760、无线保真(wireless fidelity,WiFi)模块770、处理器780、以及电源790等部件。本领域技术人员可以理解,图7所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
其中,RF电路710可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器780处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路710还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System of Mobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE))、电子邮件、短消息服务(Short Messaging Service,SMS)等。
存储器720可用于存储软件程序以及模块,处理器780通过运行存储在存储器720的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器720可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器720可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元730可用于接收输入的数字或字符信息,以及产生与手机700的用户设置以及功能控制有关的键信号输入。具体地,输入单元730可包括触控面板731以及其他输入设备732。触控面板731,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板731上或在触控面板731附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板731可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检 测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器780,并能接收处理器780发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板731。除了触控面板731,输入单元730还可以包括其他输入设备732。具体地,其他输入设备732可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。
显示单元740可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元740可包括显示面板741。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板741。在一个实施例中,触控面板731可覆盖显示面板741,当触控面板731检测到在其上或附近的触摸操作后,传送给处理器780以确定触摸事件的类型,随后处理器780根据触摸事件的类型在显示面板741上提供相应的视觉输出。虽然在图7中,触控面板731与显示面板741是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板731与显示面板741集成而实现手机的输入和输出功能。
手机700还可包括至少一种传感器750,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板741的亮度,接近传感器可在手机移动到耳边时,关闭显示面板741和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。
音频电路760、扬声器761和传声器762可提供用户与手机之间的音频接口。音频电路760可将接收到的音频数据转换后的电信号,传输到扬声器761,由扬声器761转换为声音信号输出;另一方面,传声器762将收集的声音信号转换为电信号,由音频电路760接收后转换为音频数据,再将音频数据输出处理器780处理后,经RF电路710可以发送给另一手机,或者将音频数据输出至存储器720以便后续处理。
WiFi属于短距离无线传输技术,手机通过WiFi模块770可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图7示出了WiFi模块770,但是可以理解的是,其并不属于手机700的必须构成,可以根据需要而省略。
处理器780是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器720内的软件程序和/或模块,以及调用存储在存储器720内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器780可包括一个或多个处理单元。在一个实施例中,处理器780可集成应用处理器和调制解调器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调器主要处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器780中。比如,该处理器780可集成应用处理器和基带处理器,基带处理器与和其它外围芯片等可组成调制解调器。手机700还包括给各个部件供电的电源790(比如电池),优选的,电源可以通过电源管理系统与处理器780逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
在一个实施例中,手机700还可以包括摄像头、蓝牙模块等。
在本申请实施例中,该手机所包括的处理器执行存储在存储器上的计算机程序时实现上述所描述的进程处理方法。
本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/ 或易失性存储器。合适的非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDR SDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)。
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (12)
- 一种进程处理方法,包括:获取处于电子设备前台运行的第一进程;获取第二进程,所述第二进程为被所述第一进程所依赖的后台进程;及将所述第二进程的优先级调整至与所述第一进程的优先级相匹配。
- 根据权利要求1所述的方法,其特征在于,在将所述第二进程的优先级调整至与所述第一进程的优先级相匹配之后,还包括:当所述第一进程结束对所述第二进程的依赖时,将所述第二进程的优先级恢复至调整前的优先级。
- 根据权利要求1所述的方法,其特征在于,在所述获取第二进程之前,还包括:当后台进程与所述第一进程之间存在通信机制时,将具有通信机制的后台进程作为第二进程。
- 根据权利要求3所述的方法,其特征在于,当后台进程与所述第一进程之间存在socket通信、binder通信、内存共享或锁等待时,判定所述后台进程与所述第一进程之间存在通信机制。
- 根据权利要求1所述的方法,其特征在于,在所述获取第二进程之前,还包括:当后台进程与所述第一进程之间存在同步机制时,将具有同步机制的后台进程作为第二进程。
- 根据权利要求1所述的方法,其特征在于,在所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配之前,还包括:当检测到所述第二进程被执行时所需的资源大于所述第二进程的当前优先级对应的最大允许资源时,执行所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配的优先级;当检测到所述第二进程被执行时所需的资源不大于所述第二进程的当前优先级对应的最大允许资源时,保持所述第二进程的优先级不变。
- 根据权利要求1所述的方法,其特征在于,在所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配之前,还包括:当所述第二进程处于冻结状态,或所述第二进程的CPU占用率限制小于第一进程的CPU占用率限制时,执行所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配的优先级。
- 根据权利要求2所述的方法,其特征在于,所述第二进程包括第一被依赖进程和第二被依赖进程;所述第二被依赖进程被所述第一被依赖进程直接依赖,所述第一被依赖进程被所述第一进程直接依赖或间接依赖;在所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配之前,还包括:所述第一被依赖进程被唤醒时,判定所述第一进程结束对所述第二被依赖进程的依赖。
- 根据权利要求1至8中任一项所述的方法,其特征在于,所述将所述第二进程的优先级调整至与所述第一进程的优先级相匹配,包括:将所述第二进程的优先级调整至与所述第一进程的优先级相同。
- 一种进程处理装置,其特征在于,所述装置包括:第一进程获取模块,用于获取处于电子设备前台运行的第一进程;第二进程获取模块,用于获取第二进程,所述第二进程为被所述第一进程所依赖的后台进程;及调整模块,用于将所述第二进程的优先级调整至与所述第一进程的优先级相匹配。
- 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1至9中任一项所述的进程处理方法的操作。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至9中任一项所述的进程处理方法的操作。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711488926.XA CN109992397A (zh) | 2017-12-29 | 2017-12-29 | 进程处理方法和装置、电子设备、计算机可读存储介质 |
CN201711488926.X | 2017-12-29 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019128588A1 true WO2019128588A1 (zh) | 2019-07-04 |
Family
ID=67063040
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/117459 WO2019128588A1 (zh) | 2017-12-29 | 2018-11-26 | 进程处理方法和装置、电子设备、计算机可读存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109992397A (zh) |
WO (1) | WO2019128588A1 (zh) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110704112B (zh) * | 2019-08-30 | 2021-04-02 | 创新先进技术有限公司 | 在区块链中并发执行交易的方法和装置 |
CN112445628B (zh) * | 2019-09-03 | 2023-10-24 | 腾讯科技(深圳)有限公司 | 进程间资源共享方法、装置与电子设备 |
CN113535340B (zh) * | 2020-04-13 | 2023-03-31 | 荣耀终端有限公司 | 一种任务调度方法、装置及电子设备 |
CN114625525A (zh) * | 2020-12-14 | 2022-06-14 | 华为技术有限公司 | 一种资源管控方法及设备 |
CN116701320B (zh) * | 2022-12-01 | 2024-05-14 | 荣耀终端有限公司 | 一种日志生成方法及相关装置 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102163161A (zh) * | 2011-04-01 | 2011-08-24 | 奇智软件(北京)有限公司 | 一种进程管理方法及装置 |
CN103838630A (zh) * | 2014-03-03 | 2014-06-04 | 联想(北京)有限公司 | 信息处理方法、系统及电子设备 |
CN104699218A (zh) * | 2013-12-10 | 2015-06-10 | 华为终端有限公司 | 一种任务管理方法及设备 |
CN107463436A (zh) * | 2017-07-31 | 2017-12-12 | 广东欧珀移动通信有限公司 | 进程控制方法、装置、存储介质以及电子设备 |
CN107479954A (zh) * | 2017-07-31 | 2017-12-15 | 广东欧珀移动通信有限公司 | 进程管理方法、装置、存储介质及电子设备 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7774781B2 (en) * | 2005-09-30 | 2010-08-10 | Intel Corporation | Storage subsystem access prioritization by system process and foreground application identification |
CN105843650B (zh) * | 2016-03-31 | 2020-03-31 | 青岛海信移动通信技术股份有限公司 | 一种智能终端中的应用程序管理方法和装置 |
CN107391241A (zh) * | 2017-06-22 | 2017-11-24 | 努比亚技术有限公司 | 应用快速启动方法、终端及计算机可读存储介质 |
CN111309400A (zh) * | 2017-07-31 | 2020-06-19 | Oppo广东移动通信有限公司 | 进程控制方法、装置、存储介质以及电子设备 |
CN107402808B (zh) * | 2017-07-31 | 2020-03-27 | Oppo广东移动通信有限公司 | 进程管理方法、装置、存储介质及电子设备 |
-
2017
- 2017-12-29 CN CN201711488926.XA patent/CN109992397A/zh active Pending
-
2018
- 2018-11-26 WO PCT/CN2018/117459 patent/WO2019128588A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102163161A (zh) * | 2011-04-01 | 2011-08-24 | 奇智软件(北京)有限公司 | 一种进程管理方法及装置 |
CN104699218A (zh) * | 2013-12-10 | 2015-06-10 | 华为终端有限公司 | 一种任务管理方法及设备 |
CN103838630A (zh) * | 2014-03-03 | 2014-06-04 | 联想(北京)有限公司 | 信息处理方法、系统及电子设备 |
CN107463436A (zh) * | 2017-07-31 | 2017-12-12 | 广东欧珀移动通信有限公司 | 进程控制方法、装置、存储介质以及电子设备 |
CN107479954A (zh) * | 2017-07-31 | 2017-12-15 | 广东欧珀移动通信有限公司 | 进程管理方法、装置、存储介质及电子设备 |
Also Published As
Publication number | Publication date |
---|---|
CN109992397A (zh) | 2019-07-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019128588A1 (zh) | 进程处理方法和装置、电子设备、计算机可读存储介质 | |
KR102148948B1 (ko) | 전자 장치의 멀티 태스킹 방법 및 그 전자 장치 | |
WO2019128540A1 (zh) | 资源管理方法、移动终端及计算机可读存储介质 | |
US11579714B2 (en) | Apparatus and method for providing memo function | |
WO2019128546A1 (zh) | 应用程序处理方法、电子设备、计算机可读存储介质 | |
US9766690B2 (en) | Method for controlling a sleep mode and electronic device thereof | |
US20170269725A1 (en) | Electronic device for touch and finger scan sensor input and control method thereof | |
WO2019128571A1 (zh) | 资源管理方法、装置、移动终端及计算机可读存储介质 | |
WO2019137252A1 (zh) | 内存处理方法、电子设备、计算机可读存储介质 | |
WO2020024732A1 (zh) | 进程处理方法、电子设备、计算机可读存储介质 | |
WO2019137173A1 (zh) | 资源管理方法、移动终端及计算机可读存储介质 | |
WO2019137258A1 (zh) | 内存处理方法、电子设备及计算机可读存储介质 | |
WO2019128549A1 (zh) | 应用冻结方法、装置、终端及计算机可读存储介质 | |
WO2019128537A1 (zh) | 应用冻结方法、计算机设备和计算机可读存储介质 | |
WO2019128574A1 (zh) | 信息处理方法、装置、计算机设备和计算机可读存储介质 | |
CN104423996A (zh) | 视图刷新方法和装置 | |
WO2019184631A1 (zh) | 信息处理方法和装置、计算机可读存储介质、终端 | |
WO2019128573A1 (zh) | 信息处理方法、装置、计算机设备和计算机可读存储介质 | |
CN110032266B (zh) | 信息处理方法、装置、计算机设备和计算机可读存储介质 | |
WO2019128542A1 (zh) | 应用处理方法、电子设备、计算机可读存储介质 | |
CN110018905B (zh) | 信息处理方法、装置、计算机设备和计算机可读存储介质 | |
WO2019128569A1 (zh) | 应用程序冻结方法、装置、存储介质和终端 | |
WO2019128586A1 (zh) | 应用程序处理方法、电子设备、计算机可读存储介质 | |
WO2019128553A1 (zh) | 应用程序处理方法、电子设备、计算机可读存储介质 | |
CN110046032A (zh) | 应用程序处理方法和装置、电子设备、计算机可读存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18895907 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18895907 Country of ref document: EP Kind code of ref document: A1 |