WO2019128545A1 - Process handling method, and electronic device and computer-readable storage medium - Google Patents

Process handling method, and electronic device and computer-readable storage medium Download PDF

Info

Publication number
WO2019128545A1
WO2019128545A1 PCT/CN2018/116526 CN2018116526W WO2019128545A1 WO 2019128545 A1 WO2019128545 A1 WO 2019128545A1 CN 2018116526 W CN2018116526 W CN 2018116526W WO 2019128545 A1 WO2019128545 A1 WO 2019128545A1
Authority
WO
WIPO (PCT)
Prior art keywords
daemon
application
foreground
keyword
processor
Prior art date
Application number
PCT/CN2018/116526
Other languages
French (fr)
Chinese (zh)
Inventor
方攀
陈岩
Original Assignee
Oppo广东移动通信有限公司
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 Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2019128545A1 publication Critical patent/WO2019128545A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

A process handling method, comprising: acquiring process information of a daemon process running in the background; detecting whether the process information includes a pre-set keyword; and when the keyword is included, carrying out resource restriction on the daemon process.

Description

进程处理方法、电子设备、计算机可读存储介质Process processing method, electronic device, computer readable storage medium
相关申请的交叉引用Cross-reference to related applications
本申请要求于2017年12月29日提交中国专利局、申请号为201711484424.X、发明名称为“进程处理方法和装置、电子设备、计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application filed on Dec. 29, 2017, the Chinese Patent Application No. 201711484424.X, entitled "Process Processing Method and Apparatus, Electronic Apparatus, Computer Readable Storage Medium", The entire contents are incorporated herein by reference.
技术领域Technical field
本申请涉及数据处理领域,特别是涉及一种进程处理方法、电子设备、计算机可读存储介质。The present application relates to the field of data processing, and in particular, to a process processing method, an electronic device, and a computer readable storage medium.
背景技术Background technique
随着移动通信技术的发展,移动操作系统中都提供了对应用的进程进行资源限制的方法。传统的操作系统中,前台应用的进程(即前台进程)通常是不会进行资源限制的,而对于与前台应用无关的处于后台运行的应用的进程(即后台进程),则对其占用的资源加以限制,以提供更多的资源给前台应用的进程使用,提高前台应用的操作效率。With the development of mobile communication technologies, mobile operating systems provide a method for resource limitation of application processes. In a traditional operating system, a process of a foreground application (that is, a foreground process) is usually not resource-restricted, and a process (ie, a background process) of an application running in the background that is not related to the foreground application is occupied by resources. Limits to provide more resources for the foreground application process to improve the operational efficiency of the foreground application.
然而,传统方法中,总是存在一些比较隐蔽的进程,比如应用安装进程,使得系统难以检测出来并加以限制,导致这些隐蔽的后台进程占用较多的资源,影响了前台应用的运行效率。However, in the traditional method, there are always some hidden processes, such as the application installation process, which makes the system difficult to detect and limit, which causes these hidden background processes to occupy more resources, which affects the operating efficiency of the foreground application.
发明内容Summary of the invention
本申请实施例提供一种进程处理方法、电子设备、计算机可读存储介质。The embodiment of the present application provides a process processing method, an electronic device, and a computer readable storage medium.
一种进程处理方法,所述方法包括:A process processing method, the method comprising:
获取处于后台运行的守护进程的进程信息;Get the process information of the daemon running in the background;
检测所述进程信息中是否包含预设的关键字;Detecting whether the process information includes a preset keyword;
当包含所述关键字时,对所述守护进程进行资源限制。When the keyword is included, resource restrictions are imposed on the daemon.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时,使得所述处理器执行以下操作:获取处于后台运行的守护进程的进程信息;检测所述进程信息中是否包含预设的关键字;当包含所述关键字时,对所述守护进程进行资源限制。A computer readable storage medium having stored thereon a computer program, the computer program being executed by a processor, causing the processor to: acquire process information of a daemon running in the background; and detect the process information Whether the preset keyword is included; when the keyword is included, the resource is restricted to the daemon.
一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,使得所述处理器执行以下操作:取处于后台运行的守护进程的进程信息;检测所述进程信息中是否包含预设的关键字;当包含所述关键字时,对所述守护进程进行资源限制。An electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor executing the computer program, causing the processor to perform the following operations: fetching in the background Process information of the daemon process; detecting whether the process information includes a preset keyword; when the keyword is included, performing resource limitation on the daemon process.
附图说明DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present application, and other drawings can be obtained according to the drawings without any creative work for those skilled in the art.
图1为一个实施例中电子设备的内部结构示意图。FIG. 1 is a schematic diagram showing the internal structure of an electronic device in an embodiment.
图2为一个实施例中电子设备中的系统的部分框架示意图。2 is a partial block diagram of a system in an electronic device in an embodiment.
图3为一个实施例中进程处理方法的流程图。3 is a flow chart of a process processing method in an embodiment.
图4为另一个实施例中进程处理方法的流程图。4 is a flow chart of a process processing method in another embodiment.
图5为一个实施例中进程处理装置的结构框图。Figure 5 is a block diagram showing the structure of a process processing apparatus in an embodiment.
图6为另一个实施例中进程处理装置的结构框图。Figure 6 is a block diagram showing the structure of a process processing apparatus in another embodiment.
图7为一个实施例中手机的部分结构的框图。Figure 7 is a block diagram showing a portion of the structure of a handset in an embodiment.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the objects, technical solutions, and advantages of the present application more comprehensible, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一关键字称为第二关键字,且类似地,可将第二关键字称为第一关键字。第一关键字和第二关键字两者都是关键字,但其不是同一关键字。It will be understood that the terms "first", "second" and the like, as used herein, may be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, the first keyword may be referred to as a second keyword without departing from the scope of the present application, and similarly, the second keyword may be referred to as a first keyword. Both the first keyword and the second keyword are keywords, but they are not the same keyword.
在一个实施例中,如图1所示,提供了一种电子设备的内部结构示意图。该电子设备包括通过系统总线连接的处理器、存储器和显示屏。其中,该处理器用于提供计算和控制能力,支撑整个电子设备的运行。存储器用于存储数据、程序、和/或指令代码等,存储器上存储至少一个计算机程序,该计算机程序可被处理器执行,以实现本申请实施例中提供的适用于电子设备的进程处理方法。存储器可包括磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等非易失性存储介质,或随机存储记忆体(Random-Access-Memory,RAM)等。例如,在一个实施例中,存储器包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统、数据库和计算机程序。该数据库中存储有用于实现以上各个实施例所提供的一种进程处理方法相关的数据,比如可存储有每个进程或应用的名称等信息。该计算机程序可被处理器所执行,以用于实现本申请各个实施例所提供的一种进程处理方法。内存储器为非易失性存储介质中的操作系统、数据库和计算机程序提供高速缓存的运行环境。显示屏可以是触摸屏,比如为电容屏或电子屏,用于显示前台进程对应的应用的界面信息,还可以被用于检测作用于该显示屏的触摸操作,生成相应的指令,比如进行前后台应用的切换指令等。In one embodiment, as shown in FIG. 1, an internal structure diagram of an electronic device is provided. The 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). For example, in one embodiment, 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 foreground process, and can also be used for detecting a touch operation acting on the display screen, and generating corresponding instructions, such as performing front and back Application switching instructions, etc.
本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。如该电子设备还包括通过系统总线连接的网络接口,网络接口可以是以太网卡或无线网卡等,用于与外部的电子设备进行通信,比如可用于同服务器进行通信。再比如该电子设备上并不存在通过系统总线连接的显示器,或者可连接外部显示设备。A person skilled in the art can understand that 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. For example, 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. For example, there is no display connected through the system bus on the electronic device, or an external display device can be connected.
在一个实施例中,如图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用于解决出现冻结超时场景产生的异常。通过上述的架构,可实现本申请各个实施例中的进程处理方法。In one embodiment, as shown in FIG. 2, 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 may include a freeze management application 212. The electronic device may implement a freeze policy for each application through the freeze management application 212, and perform freezing and thawing management operations on 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. Optionally, 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. It also limits the occupation of network resources and I/O interface resources by the process; CPU freeze sleep mode refers to prohibiting related processes from using the CPU, while preserving the occupation of memory, when prohibiting the use of CPU resources, the corresponding network resources and I The /O interface resource is also forbidden; the process deep freeze mode means that in addition to prohibiting the use of CPU resources, the memory resources occupied by the related processes are further recovered, and the recovered memory can be used by other processes. 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. Through the above architecture, the process processing method in various embodiments of the present application can be implemented.
在一个实施例中,如图3所示,提供了一种进程处理方法,本实施例以该方法应用于如图1所示的电子设备为例进行说明。该方法包括:In an embodiment, as shown in FIG. 3, 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:
操作302,获取处于后台运行的守护进程的进程信息。In operation 302, the process information of the daemon running in the background is obtained.
电子设备中有多个处于运行状态的进程,进程(process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础。一个应用(Application,简称APP)的运行通常是由相关的多个进程的运行而体现的。前台应用运行时涉及的进程即为前台进程,后台应用运行时涉及的进程即为后台进程。电子设备可获取处于前台应用运行时的前台进程。每个进程可作为一个任务(task)而执行,由前台进程形成任务即为前台任务,后台进程形成的任务即为后台任务。There are multiple processes in the electronic device. 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 foreground process, and the process involved in the background application runtime is the background process. The electronic device can obtain the foreground process when the foreground application is running. Each process can be executed as a task. The task formed by the foreground process is the foreground task, and the task formed by the background process is the background task.
在后台运行的进程中,存在一类进程为守护进程(Daemon进程)。守护进程是一直运行的服务端程序,通常在系统后台运行,没有控制终端,不与前台交互,守护进程一般作为系统服务使用,是长时间运行的进程,通常在系统启动后就运行,在系统关闭时才结束。In the process running in the background, there is a class of processes as daemons (Daemon processes). The daemon is a server program that runs all the time. It usually runs in the background of the system. There is no control terminal and no interaction with the foreground. The daemon is generally used as a system service. It is a long-running process. It usually runs after the system is started. It ends when it is closed.
电子设备可按照预设的频率或者根据检测到的用户操作指令来获取处于后台运行的守护进程的进程信息。进程信息包括进程的用户身份标识(User Identifier,UID)、进程身份标识(Process Identifier,PID)、进程名称等基本信息。The electronic device may acquire process information of the daemon running in the background according to a preset frequency or according to the detected user operation instruction. The process information includes basic information such as the User Identifier (UID), Process Identifier (PID), and process name of the process.
在一个实施例中,电子设备可根据自身的运行状态来实时更新处于前台运行的进程以及处于后台运行的进程,可选地,可设置对应的前台进程的前台进程池,以及后台进程的后台进程池。将处于前台进程的进程信息加入该前台进程池中,将后台进程的进程信息加入该后台进程池中,并在检测到后台运行的进程有变动时,对应更新该前台进程池和后台进程池中的进程标识。比如,当检测到进程B由后台进程变成前台进程时,可将该进程B的进程信息从后台进程池中移入前台进程池中。In an embodiment, the electronic device may update the process running in the foreground and the process running in the background according to the running state of the electronic device. Optionally, the foreground process pool of the corresponding foreground process and the background process of the background process may be set. Pool. Add the process information of the foreground process to the foreground process pool, add the process information of the background process to the background process pool, and update the foreground process pool and the background process pool when detecting that the process running in the background changes. Process ID. For example, when it is detected that the process B changes from the background process to the foreground process, the process information of the process B can be moved from the background process pool to the foreground process pool.
在一个实施例中,电子设备可针对每个进程,设置对应的前台标记或后台标记,将具有前台标记的进程判定为前台进程,将具有后台标记的进程判定为后台进程,并获取具有后台标记的守护进程的进程信息。In an embodiment, the electronic device may set a corresponding foreground mark or background mark for each process, determine a process with a foreground mark as a foreground process, determine a process with a background mark as a background process, and obtain a background mark. Process information for the daemon.
操作304,检测进程信息中是否包含预设的关键字。In operation 304, it is detected whether the preset keyword is included in the process information.
电子设备预设了至少一个关键字,该关键字为预设位数的数字、字母或其它字符等其中的一种或几种构成。该关键字为可进行资源限制的守护进程的进程信息中所共有的信息。电子设备可对进程信息中预设的一个或多个字段信息进行检测,以判定所检测的字段信息中是否包含相应的关键字。比如可检测其中的进程名称以及UID等一种或多种字段中是否包含相应的关键字。The electronic device presets at least one keyword, which is one or more of a preset number of digits, letters or other characters. This keyword is information common to the process information of the daemon that can be resource limited. The electronic device may detect one or more field information preset in the process information to determine whether the detected field information includes the corresponding keyword. For example, it can detect whether the process name and the one or more fields such as UID contain corresponding keywords.
操作306,当包含关键字时,对守护进程进行资源限制。 Operation 306, when the keyword is included, resource limits are imposed on the daemon.
可选地,当检测到进信息中包含预设的关键字时,对相应的守护进程进行资源限制。其中,资源包括CPU资源、CPUSET资源、内存资源、I/O资源和Net相关的资源等。电子设备可对上述资源中的一种或多种进行限制,以防止守护进程占据较多的资源而影响前台进程的处理效率。Optionally, when the preset information is included in the incoming information, the resource is restricted to the corresponding daemon. The resources include CPU resources, CPUSET resources, memory resources, I/O resources, and Net related resources. The electronic device may limit one or more of the above resources to prevent the daemon process from occupying more resources and affecting the processing efficiency of the foreground process.
在一个实施例中,对守护进程进行资源限制,包括:对守护进程所占用的CPU资源和I/O资源进行限制。In one embodiment, resource limits are imposed on the daemon, including: limiting CPU resources and I/O resources occupied by the daemon.
可选地,由于通常这类守护进程对CPU资源和I/O资源的占用较多,电子设备通过对这类资源进行CPU资源和I/O资源的限制,可进一步提高前台应用可使用的CPU资源和I/O资源,从而提高了前台应用的处理效率。Optionally, since such a daemon process generally occupies more CPU resources and I/O resources, the electronic device can further improve the CPU that can be used by the foreground application by limiting CPU resources and I/O resources of such resources. Resources and I/O resources improve the processing efficiency of the foreground application.
本实施例所提供的进程处理方法,电子设备通过对守护进程进行关键字的检测,可提高对检测出所存在的比较隐蔽的守护进程的检测效率,并对检测出的进程信息中包含相应的关键字的守护进程进行资源限制,防止其对更多资源的占用,使更多的资源向前台应用所倾斜,提高前台应用的处理效率通过进程。In the process processing method provided by the embodiment, the electronic device can improve the detection efficiency of detecting the relatively hidden daemon process by detecting the keyword of the daemon process, and include the corresponding key in the detected process information. The word daemon performs resource restrictions to prevent it from occupying more resources, so that more resources are tilted toward the foreground application, and the processing efficiency of the foreground application is improved through the process.
在一个实施例中,关键字包括第一关键字和第二关键字;操作304包括:检测进程信息中的进程名称是否包含第一关键字;检测进程信息中的用户身份标识UID是否包含第二关键字;操作306包括:当包含第一关键字和第二关键字时,对守护进程进行资源限制。In one embodiment, the keyword includes a first keyword and a second keyword; operation 304 includes: detecting whether the process name in the process information includes the first keyword; and detecting whether the user identity UID in the process information includes the second Keyword; operation 306 includes: resource limiting the daemon process when the first keyword and the second keyword are included.
电子设备需要检索的关键字包括两种,分别为第一关键字和第二关键字。第一关键字和第二关键字分别由预设长度的不同的数字、字母或其它字符等其中的一种或多种构成。第一关键字为对进程名称进行检测的关键字,第二关键字为对UID进行检测的关键字。The keywords that the electronic device needs to retrieve include two types, a first keyword and a second keyword. The first keyword and the second keyword are respectively composed of one or more of different numbers, letters or other characters of a preset length. The first keyword is a keyword that detects the process name, and the second keyword is a keyword that detects the UID.
电子设备可获取进程信息中的进程名称以及UID,并检测进程名称中是否包含第一关键字,以及UID中是否包含第二关键字。可选地,电子设备可同时进行第一关键字和第二关键字的检测,两者的检测顺序并没有必然的限定。当检测出进程名称中包含第一关键字,且UID中包含第二关键字时,电子设备可以对该守护进程进行资源限制。The electronic device can obtain the process name and the UID in the process information, and detect whether the process name includes the first keyword and whether the second keyword is included in the UID. Optionally, the electronic device can perform detection of the first keyword and the second keyword at the same time, and the detection order of the two is not necessarily limited. When it is detected that the process name includes the first keyword, and the UID includes the second keyword, the electronic device may perform resource limitation on the daemon.
本实施例中,电子设备通过在进程名称以及UID中进行关键字的检测,进一步提高了对可进行资源限制的守护进程的检测的准确性。In this embodiment, the electronic device further improves the accuracy of detecting the daemon process that can perform resource limitation by performing keyword detection in the process name and the UID.
在一个实施例中,在对守护进程进行资源限制之前,还包括:获取前台应用的应用类别,当应用类别为游戏类应用,执行对守护进程进行资源限制。In an embodiment, before the resource restriction is performed on the daemon, the method further includes: acquiring an application category of the foreground application, and performing resource limitation on the daemon when the application category is a game application.
可选地,电子设备可检测本机的前台应用的运行状态,当前台应用处于游戏运行状态时,可执行对守护进程进行资源限制的操作。电子设备可记录不同的应用所属的应用类别,应用类别可包括游戏应用、社交应用、地图导航应用、网购支付应用、通话通讯应用、浏览器应用等。电子设备可获取处于前台运行状态的应用的应用类别,处于前台运行的应用即为前台应用。当检测到前台应用为游戏应用时,电子设备可以执行对守护进程进行资源限制的操作。Optionally, the electronic device can detect an operating state of the front-end application of the local device, and when the current running application is in the running state of the game, perform a resource limiting operation on the daemon. The electronic device can record application categories to which different applications belong, and the application categories may include game applications, social applications, map navigation applications, online shopping payment applications, call communication applications, browser applications, and the like. The electronic device can obtain the application category of the application running in the foreground, and the application running in the foreground is the foreground application. When it is detected that the foreground application is a game application, the electronic device can perform a resource restriction operation on the daemon.
本实施例中,由于游戏类的应用在运行的过程中,通常需要占用较大的资源才能保持流畅的运行,而当存在隐藏在后台运行的守护进程时,也会占用一定的资源,影响游戏应用的运行效率,因此,当检测到前台应用为游戏应用时,电子设备可以对检测出的守护进程进行资源限制,可进一步提高游戏应用的运行效率。In this embodiment, since the application of the game class is in the process of running, it usually needs to occupy a large resource to maintain smooth running, and when there is a daemon hidden in the background, it also occupies certain resources and affects the game. The running efficiency of the application, therefore, when detecting that the foreground application is a game application, the electronic device can limit the resources of the detected daemon, which can further improve the operating efficiency of the game application.
在一个实施例中,对守护进程进行资源限制,包括:降低守护进程的优先级;根据降低后的优先级对守护进程进行资源限制。In one embodiment, resource limits are imposed on the daemon, including: reducing the priority of the daemon; and limiting resources to the daemon based on the reduced priority.
可选地,针对每个处于前后台运行的进程,电子设备设置了对应不同的优先级,不同的优先级对应不同的资源限制程度。优先级越高的进程,对其可使用的资源的限制程度越低。通常地,前台进程对应被设置了最高的优先级,且相对高于后台进程的优先级。同一个进程,处于前台运行时以及处于后台运行时的优先级不一定相同。且同一个后台进程,处于不同状态下的优先级也不一定相同。比如,同一后台进程,在不同的时刻,或者前台 进程不同时,该后台进程的优先级也不一定相同。Optionally, for each process running in the front background, the electronic device is set to correspond to different priorities, and different priorities correspond to different resource limitation levels. The higher the priority, the lower the limit on the resources available to it. Generally, the foreground process is set to the highest priority and is 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. And the same background process, the priority in different states is not necessarily the same. For example, when the same background process is different at different times or when the foreground process is different, the priority of the background process is not necessarily the same.
针对查询出的守护进程,电子设备可对其优先级进行调整,以降低该守护进程的优先级,并按照降低后的优先级来对该守护进程进行资源限制,以提高对守护进程的资源限制程度,使得更多的资源向前台应用倾斜。For the queried daemon, the electronic device can adjust its priority to lower the priority of the daemon, and limit the resource to the daemon according to the reduced priority to increase the resource limit on the daemon. The extent that more resources are tilted toward the foreground application.
举例来说,电子设备可按照优先级由高到低,分别设置优先级1至优先级5,共5级优先级,优先级越高的进程,对其可使用的资源的限制程度越低。当存在守护进程A的优先级为3级,且该守护进程A的进程信息中包含上述的关键字时,电子设备将该守护进程A的优先级由优先级3级调整至优先级4或优先级5级等,以保留更多的可用资源给前台应用使用,进一步提高前台应用的运行效率。For example, 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. When the priority of the daemon A is 3, and the process information of the daemon A includes the above keywords, the electronic device adjusts the priority of the daemon A from the priority 3 to the priority 4 or preferentially. Level 5, etc., to retain more available resources for the foreground application to further improve the operational efficiency of the foreground application.
在一个实施例中,守护进程进行资源限制,包括:根据本地的资源利用率计算出对守护进程的限制程度;根据限制程度对守护进程进行资源限制。In one embodiment, the daemon process performs resource limitation, including: calculating a limit on the daemon process according to the local resource utilization rate; and limiting the resource to the daemon process according to the degree of restriction.
可选地,本地资源利用率包括CPU资源、I/O资源、内存资源等其中的一种或多种资源的利用率。资源利用率反映了电子设备的资源空闲状态,资源利用率越低,则相应的空闲的资源越多。电子设备可根据当前的资源利用率来计算出对守护进程的限制程度,使得当资源利用率越大的时候,对守护进程的限制程度越高,资源利用率越小,则对守护进程的限制程度也相应的越小。Optionally, the local resource utilization includes utilization of one or more resources of the CPU resource, the I/O resource, the memory resource, and the like. The resource utilization reflects the idle state of the resources of the electronic device, and the lower the resource utilization, the more idle resources are corresponding. The electronic device can calculate the limit on the daemon process according to the current resource utilization rate, so that when the resource utilization rate is larger, the restriction on the daemon process is higher, and the resource utilization rate is smaller, the daemon process is restricted. The degree is correspondingly smaller.
举例来说,以资源为内存为例来说明,当当前对守护进程的限制的可占用的I/O资源的数量为m或无限制时,m可为任意合适的经验值。当电子设备当前的资源利用率为a%时,电子设备可将对该守护进程的I/O资源的数量限制为n,当电子设备当前的资源利用率为b%时,电子设备可将对该守护进程的I/O资源的数量限制为k。其中,b和k均小于m,且当a小于b时,n大于k。For example, taking a resource as an example of memory, m may be any suitable empirical value when the number of available I/O resources currently limited to the daemon is m or unlimited. When the current resource utilization rate of the electronic device is a%, the electronic device may limit the number of I/O resources of the daemon to n, and when the current resource utilization rate of the electronic device is b%, the electronic device may The number of I/O resources for this daemon is limited to k. Wherein b and k are both smaller than m, and when a is smaller than b, n is greater than k.
在一个实施例中,电子设备可根据本地的资源利用率来降低守护进程的优先级,通过不同优先级所对应的资源限制程度,对该守护进程进行资源限制。其中,资源利用率越低,则对守护进程的优先级的下降幅度越小,资源利用率越高,则对守护进程的优先级的下降幅度越大。In an embodiment, the electronic device may reduce the priority of the daemon according to the local resource utilization, and limit the resource to the daemon by the degree of resource limitation corresponding to the different priorities. The lower the resource utilization rate, the smaller the priority of the daemon process, and the higher the resource utilization rate, the greater the decrease in the priority of the daemon process.
电子设备通过按照本地的资源利用率计算出对守护进程的限制程度,并根据该限制程度来对守护进程进行限制,从而可使得在本地的资源利用率较大的时候,对守护进程的限制程度更大,在本地资源的利用率较低时候,电子设备对守护进程的限制程度相对较小,使得对守护进程的限制程度与本地的资源利用率相平衡,在对前台应用的处理效率影响不大情况下,电子设备不对守护进程进行过多的限制,也避免守护进程的处理效率过于低下。The electronic device calculates the degree of restriction on the daemon process according to the local resource utilization rate, and limits the daemon process according to the degree of the restriction, so that the degree of limitation on the daemon process when the local resource utilization is large is large. Larger, when the utilization of local resources is low, the electronic device has a relatively small restriction on the daemon process, so that the degree of restriction on the daemon is balanced with the local resource utilization, and the processing efficiency of the foreground application is not affected. In large cases, the electronic device does not impose too many restrictions on the daemon process, and also avoids the processing efficiency of the daemon process is too low.
在一个实施例中,在对守护进程进行资源限制之前,还包括:检测守护进程是否被前台进程依赖;当守护进程被前台进程依赖时,将守护进程的优先级调整至与前台进程相匹配;当守护进程未被前台进程依赖时,执行对守护进程进行资源限制。In an embodiment, before the resource restriction on the daemon, the method further includes: detecting whether the daemon is dependent on the foreground process; and when the daemon is dependent on the foreground process, adjusting the priority of the daemon to match the foreground process; When the daemon is not dependent on the foreground process, the resource limit is enforced on the daemon.
在一个实施例中,电子设备对该守护进程进行依赖检测的操作,可在上述操作306之前的任意过程之中进行检测,比如,可首先进行依赖关系的检测,当不存在依赖关系时,则进行关键字的检测。当不存在依赖关系,且包含上述的关键字时,则执行守护进程进行资源限制。In an embodiment, the electronic device performs the dependency detection operation on the daemon, and may perform detection in any process before the foregoing operation 306. For example, the dependency relationship may be detected first, when there is no dependency relationship, Perform keyword detection. When there is no dependency and contains the above keywords, the daemon is executed to perform resource limitation.
依赖表示一个进程需要利用于另一个或多个进程的数据才能顺利实现对该一个进程的执行的关系。存在依赖关系的两个进程,分别为被依赖的进程和依赖的进程,电子设备将检测出的将被前台进程依赖的后台运行的守护进程判定为被前台进程依赖的后台进程。电子设备可对检测出的被前台进程所依赖的后台进程设置对应的被依赖标记,并从后台进程池中获取带有被依赖标记的后台进程,将该后台进程判定为被前台进程依赖的后台进程。Dependency 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 detects the background running daemon that will be depended by the foreground process as the background process that is depended by the foreground process. The electronic device may set a corresponding dependency flag to the detected background process that is depended by the foreground process, and obtain a background process with the dependency mark from the background process pool, and determine the background process as a background that is depended by the foreground process. process.
针对该守护进程,当被前台进程依赖时,电子设备可将将守护进程判定为被前台进程依赖的后台进程,将被前台进程依赖的守护进程的优先级调整至与前台进程的优先级相匹 配。该前台进程即为前台运行的进程。For the daemon, when dependent on the foreground process, the electronic device can determine that the daemon process is a background process that is depended by the foreground process, and the priority of the daemon process that is dependent on the foreground process is adjusted to match the priority of the foreground process. . The foreground process is the process running in the foreground.
可选地,针对查询出的被前台进程依赖的守护进程,电子设备可对其优先级进行调整,使得调整后的优先级与该前台进程的优先级相匹配。电子设备可设置不同的被前台进程依赖的守护进程的优先级与前台优先级的匹配关系。根据该匹配关系,电子设备可以获取对应的适用于被前台进程依赖的守护进程的优先级,并将被前台进程依赖的守护进程的优先级调整至该优先级,降低对被前台进程依赖的守护进程的资源限制程度,使得对被前台进程依赖的守护进程所能使用的资源的限制程度与前台进程的限制程度相匹配。Optionally, for the queried daemon that is queried by the foreground process, the electronic device may adjust its priority so that the adjusted priority matches the priority of the foreground process. The electronic device can set different matching priorities of the daemon processes that are dependent on the foreground process and the foreground priority. According to the matching relationship, the electronic device can obtain a corresponding priority for the daemon process that is dependent on the foreground process, and adjust the priority of the daemon process that is dependent on the foreground process to the priority, and reduce the guard against the foreground process. The degree of resource throttling of a process matches the extent to which resources that can be used by daemons that are dependent on the foreground process match the limits of the foreground process.
在一个实施例中,与该前台进程的优先级相匹配的优先级,可为与该前台进程的优先级相同的优先级。即电子设备可将该被前台进程依赖的守护进程的优先级调整至与该前台进程的优先级相同的优先级,使得对被前台进程依赖的守护进程所能使用的资源的限制程度与前台进程的限制程度相同。In one embodiment, the priority that matches the priority of the foreground process may be the same priority as the foreground process. That is, the electronic device can adjust the priority of the daemon process that is depended by the foreground process to the same priority as the foreground process, so that the degree of limitation on the resources that can be used by the daemon process that is dependent on the foreground process is related to the foreground process. The limits are the same.
电子设备通过对守护进程进行依赖关系检测,将被前台进程所依赖的守护进程的优先级调整至与前台进程相配的优先级。由于通常前台进程的优先级最高,对应可使用的资源的限制程度最低,而后台进程的优先级较低,以防止后台进程占用过多的资源,对前台应用造成影响。然而后台进程中存在着被前台进程所依赖的情况,被依赖的后台进程执行效率时,也会对前台进程造成影响。本申请通过调整被依赖的守护进程的优先级调整至与前台优先级相匹配的优先级,从而可降低被依赖的守护进程所能使用的资源的限制程度,从而提高了被依赖的守护进程的处理效率。由于该被依赖的守护进程的处理效率提高了,从而也提高了依赖于该被依赖的守护进程的前台进程的处理效率。By detecting the dependency of the daemon, the electronic device adjusts the priority of the daemon that the foreground process depends on to the priority of the foreground process. Because the foreground process has the highest priority, the limit of the available resources is the lowest, and the background process has the lower priority to prevent the background process from occupying too many resources and affecting the foreground application. However, in the background process, there is a situation that is depended on by the foreground process. When the dependent background process is executed efficiently, it also affects the foreground process. The application adjusts the priority of the dependent daemon to the priority matching the foreground priority, thereby reducing the limit of the resources that the dependent daemon can use, thereby improving the dependent daemon. Processing efficiency. Since the processing efficiency of the dependent daemon is improved, the processing efficiency of the foreground process depending on the dependent daemon is also improved.
在一个实施例中,如图4所示,提供了另一种进程处理方法,该方法包括:In one embodiment, as shown in FIG. 4, another process processing method is provided, the method comprising:
操作402,获取处于后台运行的守护进程的进程信息。Operation 402: Obtain process information of a daemon running in the background.
可选地,进程信息包括上述的进程名称和UID。电子设备可对本地运行的所有进程进行扫描,以获取处于后台运行的守护进程的进程名称和UID。可选地,电子设备可同时获取多个守护进程的进程名称和UID,还可按照预设的顺序,在完成对其中一轮的守护进程的检测之后,再获取下一轮的守护进程的进程信息并进行检测,其中,每一轮中包含的进程的数量可为一个或多个且不一定行相同。Optionally, the process information includes the process name and UID described above. The electronic device scans all processes running locally to get the process name and UID of the daemon running in the background. Optionally, the electronic device can acquire the process name and the UID of the multiple daemons at the same time, and obtain the process of the next round of the daemon process after completing the detection of one of the daemons in a preset order. Information is detected and detected, wherein the number of processes included in each round may be one or more and may not be the same.
在一个实施例中,电子设备可通过图2中的冻结管理应用210,通过Binder接口向资源优先级和限制管理模块222发送对守护进程的检测调整指令,该资源优先级和限制管理模块222通过接收到的检测指令获取守护进程的进程信息。In one embodiment, the electronic device may send a detection adjustment instruction to the daemon process to the resource priority and restriction management module 222 through the Binder interface through the freeze management application 210 in FIG. 2, and the resource priority and restriction management module 222 passes The received detection instruction acquires the process information of the daemon.
操作404,检测进程信息中的进程名称是否包含第一关键字;检测进程信息中的用户身份标识UID是否包含第二关键字。 Operation 404, detecting whether the process name in the process information includes the first keyword; and detecting whether the user identity UID in the process information includes the second keyword.
在一个实施例中,第一关键字可为“dex2oat”。第二关键字可为“2999”的关键字,电子设备可检测进程名称中是否包含“dex2oat”,以及UID的前是否为以“2999”开头的UID,其中,“2999”的后面还可包含连续的多个9,比如可为“299999”、“2999999”或“29999999”等。In one embodiment, the first keyword may be "dex2oat." The second keyword may be a keyword of "2999", and the electronic device may detect whether the process name includes "dex2oat" and whether the UID is preceded by a UID starting with "2999", wherein "2999" may be included after A plurality of consecutive 9, such as "299999", "2999999" or "29999999".
操作406,当包含第一关键字和第二关键字,且前台应用为游戏类应用时,对守护进程进行资源限制,对守护进程所占用的CPU资源和I/O资源进行限制。 Operation 406, when the first keyword and the second keyword are included, and the foreground application is a game application, the resource limitation is performed on the daemon, and the CPU resources and I/O resources occupied by the daemon are restricted.
在一个实施例中,当守护进程的第一关键字中包含“dex2oat”,且UID的前4位为“2999”,或者包含更多连续的“9”时,电子设备可以判定该守护进程为应用安装进程,并对识别出的应用安装进程进行标记。同时,电子设备可检测前台应用是否为游戏应用,当为游戏应用时,则对该守护进程的可占用的CPU资源和I/O资源进行限制。比如,电子设备的CPU为8核或者6核的CPU,则可限制该守护进程可占用的CPU仅为1核,以提供更多的CPU资源供前台运行的游戏应用所使用。当前台应用对I/O接口的占用为30个或20个时,电子设备可以限制其只能占用3个I/O接口,以提供更多的I/O资源供前台运行的游戏应用所使 用。In an embodiment, when the first keyword of the daemon includes "dex2oat", and the first 4 digits of the UID are "2999", or contains more consecutive "9", the electronic device may determine that the daemon is Apply the installation process and mark the identified application installation process. At the same time, the electronic device can detect whether the foreground application is a game application, and when it is a game application, limit the occupied CPU resources and I/O resources of the daemon. For example, if the CPU of the electronic device is an 8-core or a 6-core CPU, the CPU that can be occupied by the daemon can be limited to only one core, so as to provide more CPU resources for the game application running in the foreground. When the current application uses 30 or 20 I/O interfaces, the electronic device can limit it to occupy only 3 I/O interfaces to provide more I/O resources for use by game applications running in the foreground. .
在一个实施例中,电子设备可通过Binder接口向资源优先级和限制管理模块222发送对检测出的守护进程的资源限制指令。可选地,该资源限制指令可为对守护进程的优先级调整指令。资源优先级和限制管理模块222接收到该优先级调整指令后,降低相应的守护进程的优先级,提高对其资源限制,防止前台应用出现卡顿。In one embodiment, the electronic device may send a resource limit instruction to the detected daemon to the resource priority and limit management module 222 via the Binder interface. Optionally, the resource limit instruction may be a priority adjustment instruction to the daemon. After receiving the priority adjustment instruction, the resource priority and limit management module 222 lowers the priority of the corresponding daemon process, increases the resource limit thereof, and prevents the foreground application from being stuck.
在一个实施例中,在对守护进程的资源进行限制之前,还包括:检测守护进程是否被前台进程依赖,当守护进程未被前台进程依赖时,电子设备可以对守护进程所占用的CPU资源和I/O资源进行限制。In an embodiment, before limiting the resources of the daemon, the method further includes: detecting whether the daemon is dependent on the foreground process, and when the daemon is not dependent on the foreground process, the electronic device may use CPU resources occupied by the daemon. I/O resources are restricted.
在一个实施例中,当守护进程与前台进程之间存在socket通信、binder通信、内存共享或锁等待时,电子设备可以判定后台进程与前台进程之间存在通信机制。In one embodiment, when there is socket communication, binder communication, memory sharing, or lock waiting between the daemon and the foreground process, the electronic device can determine that there is a communication mechanism between the background process and the foreground process.
可通过以下任意一种或几种方式检测是否存在与前台进程具有通信机制的后台进程:You can detect whether there is a background process that has communication mechanism with the foreground process by any one or several of the following methods:
(1)检测是否存在与前台进程具有socket和binder通信中的至少一种的后台进程;(1) detecting whether there is a background process having at least one of socket and binder communication with the foreground process;
(2)检测是否存在与前台进程之间进行内存共享的后台进程;(2) detecting whether there is a background process for memory sharing with the foreground process;
(3)检测是否存在前台进程等待在锁资源上的后台进程。(3) Check if there is a background process waiting for the foreground process to wait on the lock resource.
电子设备可在Binder驱动中设置对前台进程和后台进程之间是否存在Binder通信的检测机制,并调用在Binder驱动中设置的检测机制,以检测出与前台进程存在Binder通信的后台进程,将检测出的后台进程判定为被前台进程依赖的后台进程。The electronic device can set a detection mechanism for the Binder communication between the foreground process and the background process in the Binder driver, and call the detection mechanism set in the Binder driver to detect the background process in which the Binder communication exists with the foreground process, and the detection will be detected. The background process is determined to be a background process that is dependent on the foreground process.
在一个实施例中,电子设备可检测各个锁资源,锁资源包括线程锁,文件句柄,信号等。针对每个锁资源,可检测是否发生锁等待,即锁资源等待。当检测到产生锁等待时,可进一步检测该发生等待的行为是否发生在前台进程上。若是,则遍历等待在该锁资源上面的所有后台进程,将检测到的等待在该锁资源上的后台进程均判定为被前台进程依赖的后台进程。In one embodiment, 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 foreground 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 all determined to be background processes that are depended by the foreground process.
在一个实施例中,电子设备可在操作系统的内核空间中设置锁资源监控模块和优先级调整模块,将锁资源监控模块内嵌到内核原生的等待接口当中。通过该锁资源监控模块,检测线程锁,文件句柄,信号等锁各种锁资源,是否发生等待,发生等待的行为是否是发生在前台进程上面,如果是发生在前台任务上面,则将检测到的消息发送至优先级调整模块。电子设备通过该优先级调整遍历等待在该锁资源上面的所有后台线程,将这些后台进程判定为被前台进程依赖的后台进程。并通过该优先级调整模块将相应的守护进程的优先级调整至相匹配的优先级。In one embodiment, 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. Through 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 foreground process, and if it occurs on the foreground task, it will detect The message is sent to the priority adjustment module. The electronic device traverses all the background threads waiting for the lock resource by the priority adjustment, and determines these background processes as the background processes that are depended by the foreground process. And the priority adjustment module adjusts the priority of the corresponding daemon to the matching priority.
在一个实施例中,在操作304之前,还包括:当后台进程与前台进程之间存在同步机制时,判定具有同步机制的守护进程为被前台进程依赖的后台进程。In an embodiment, before the operation 304, the method further includes: when there is a synchronization mechanism between the background process and the foreground process, determining that the daemon having the synchronization mechanism is a background process that is dependent on the foreground process.
电子设备还可通过调用futex系统调用检测后台进程集合中,是否存在与前台进程具有同步机制的后台进程,将具有同步机制的后台进程判定为被前台进程依赖的后台进程。The electronic device can also detect the background process in the background process set by calling the futex system call, whether there is a background process having a synchronization mechanism with the foreground process, and determine the background process with the synchronization mechanism as the background process that is depended by the foreground process.
并发程序设计中,各进程对公共变量的访问必须加以制约,这种制约称为同步。在操作系统中,用户态(user mode)的同步机制可通过调用futex系统调用实现。其中,用户态指非特权状态。同步机制包括信号量、互斥锁等。当通过futex系统调用检测到与前台进程存在任意一种同步机制的后台进程时,可将检测到的后台进程判定为被前台进程依赖的后台进程。In concurrent programming, access to public variables must be restricted by each process. This constraint is called synchronization. In the operating system, the user mode synchronization mechanism can be implemented by calling the futex system call. Among them, the user state refers to the non-privileged state. Synchronization mechanisms include semaphores, mutex locks, and more. When a background process that detects any kind of synchronization mechanism with the foreground process is detected by the futex system call, the detected background process may be determined as a background process that is dependent on the foreground process.
电子设备通过对前台进程和后台进程之间的通信机制和同步机制中的至少一种的检测,将检测出的与前台进程具有通信机制和同步机制中的至少一种的后台进程判定为被前台进程依赖的后台进程,可提高对被前台进程依赖的守护进程的检测的效率。The electronic device determines, by the detection of at least one of a communication mechanism and a synchronization mechanism between the foreground process and the background process, the detected background process having at least one of a communication mechanism and a synchronization mechanism with the foreground process as being forwarded The background process that the process depends on can improve the efficiency of detecting the daemons that are dependent on the foreground process.
上述的进程处理方法,当前台应用为游戏应用时,由于通常的游戏应用需要占用较大的CPU资源和I/O资源才能保障游戏运行的流畅性,而后台进程中,会存在一种应用安装进程,该应用安装进程在运行过程中通常也会占用较大的CPU资源和I/O资源,且这类应用安装进程具有较大的隐蔽性,使得电子设备难以检测出来,通过对守护进程的进程名称以及 UID进行检测,当检测出进程名称包含符合应用安装进程共同共有的第一关键字、UID包含符合应用安装进程共同共有的第二关键字时,电子设备可以对该守护进程占用的CPU资源和I/O资源进行限制,从而防止该守护进程对CPU资源和I/O资源的占用,提高了前台运行的游戏应用的处理效率。In the above process processing method, when the current application is a game application, since the normal game application needs to occupy a large CPU resource and I/O resources, the smoothness of the game operation can be guaranteed, and in the background process, there is an application installation. Process, the application installation process usually occupies large CPU resources and I/O resources during the running process, and such application installation process has greater concealment, making the electronic device difficult to detect, through the daemon process. The process name and the UID are detected. When the process name includes a first keyword that is common to the application installation process, and the UID includes a second keyword that is common to the application installation process, the electronic device may use the CPU occupied by the daemon. Restrictions on resources and I/O resources prevent the daemon from consuming CPU resources and I/O resources, improving the processing efficiency of game applications running in the foreground.
应该理解的是,虽然图3和图4的流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,图3和图4中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the operations in the flowcharts of 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 explicitly stated herein, the execution of these operations is not strictly limited, and the operations may be performed in other sequences. 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.
在一个实施例中,如图5所示,提供了一种进程处理装置,该装置包括进程获取模块502、关键字检测模块504以及进程处理模块506。其中,进程获取模块502用于获取处于后台运行的守护进程的进程信息;关键字检测模块504用于检测进程信息中是否包含预设的关键字;进程处理模块506用于当包含关键字时,对守护进程进行资源限制。In one embodiment, as shown in FIG. 5, a process processing apparatus is provided. The apparatus includes a process acquisition module 502, a keyword detection module 504, and a process processing module 506. The process obtaining module 502 is configured to: process the process information of the daemon running in the background; the keyword detection module 504 is configured to detect whether the process information includes a preset keyword; and the process processing module 506 is configured to: when the keyword is included, Resource restrictions on the daemon.
在一个实施例中,关键字包括第一关键字和第二关键字;关键字检测模块504用于检测进程信息中的进程名称是否包含第一关键字;检测进程信息中的用户身份标识UID是否包含第二关键字;进程处理模块506用于当包含第一关键字和第二关键字时,对守护进程进行资源限制。In an embodiment, the keyword includes a first keyword and a second keyword; the keyword detection module 504 is configured to detect whether the process name in the process information includes the first keyword; and detect whether the user identity identifier UID in the process information is The second keyword is included; the process processing module 506 is configured to perform resource limitation on the daemon when the first keyword and the second keyword are included.
在一个实施例中,进程处理模块506还用于获取前台应用的应用类别,当应用类别为游戏类应用,对守护进程进行资源限制。In one embodiment, the process processing module 506 is further configured to obtain an application category of the foreground application, and when the application category is a game application, resource limitation is performed on the daemon.
在一个实施例中,进程处理模块506还用于降低守护进程的优先级;根据降低后的优先级对守护进程进行资源限制。In one embodiment, the process processing module 506 is further configured to reduce the priority of the daemon process; resource limiting the daemon process according to the reduced priority.
在一个实施例中,进程处理模块506还用于根据本地的资源利用率计算出对守护进程的限制程度;根据限制程度对守护进程进行资源限制。In one embodiment, the process processing module 506 is further configured to calculate a limit on the daemon process according to the local resource utilization rate; and limit the resource to the daemon process according to the degree of restriction.
在一个实施例中,进程处理模块506还用于对守护进程所占用的CPU资源和I/O资源进行限制。In one embodiment, the process processing module 506 is further configured to limit CPU resources and I/O resources occupied by the daemon.
在一个实施例中,如图6所示,提供了另一种进程处理装置,该装置还包括:In one embodiment, as shown in FIG. 6, another process processing apparatus is provided, the apparatus further comprising:
依赖检测模块508,用于检测守护进程是否被前台进程依赖。The dependency detection module 508 is configured to detect whether the daemon process is dependent on the foreground process.
进程处理模块506还用于当守护进程被前台进程依赖时,则将守护进程的优先级调整至与前台进程相匹配;当守护进程未被前台进程依赖,且进程信息包含该关键字时,执行对守护进程进行资源限制。The process processing module 506 is further configured to: when the daemon process is dependent on the foreground process, adjust the priority of the daemon to match the foreground process; when the daemon is not dependent on the foreground process, and the process information includes the keyword, execute Resource restrictions on the daemon.
上述的进程处理装置,通过对守护进程进行关键字的检测,可提高对检测出所存在的比较隐蔽的守护进程的检测效率,并对检测出的进程信息中包含相应的关键字的守护进程进行资源限制,防止其对更多资源的占用,使更多的资源向前台应用所倾斜,提高前台应用的处理效率通过进程。The above-mentioned process processing device can improve the detection efficiency of detecting the relatively hidden daemon process by detecting the keyword of the daemon process, and perform resources for the daemon process including the corresponding keyword in the detected process information. Restrictions prevent them from occupying more resources, so that more resources are tilted toward the foreground application, and the processing efficiency of the foreground application is improved through the process.
上述进程处理装置中各个模块的划分仅用于举例说明,在其他实施例中,可将进程处理装置按照需要划分为不同的模块,以完成上述进程处理装置的全部或部分功能。The division of 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.
关于进程处理装置的具体限定可以参见上文中对于进程处理方法的限定,在此不再赘述。上述进程处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。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.
本申请实施例中提供的进程处理装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器等电子设备上运行。该计算机程序构成的程序模块可存储在 电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述的进程处理方法的操作。The implementation of each module in the process processing apparatus provided in the embodiments of the present application 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 modules of the computer program can be stored on a memory of the electronic device. When 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.
在一个实施例中,提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述各实施例所提供的进程处理方法的操作。In one embodiment, an electronic device is provided, 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.
在一个实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序对处理器执行时,实现本申请各实施例中所描述的进程处理方法的操作。In one embodiment, there is also provided 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.
在一个实施例中,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行本申请各实施例中所描述的进程处理方法。In one embodiment, 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.
本申请实施例还提供了一种计算机设备。如图7所示,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以计算机设备为手机为例: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. :
图7为与本申请实施例提供的计算机设备相关的手机的部分结构的框图。参考图7,手机包括:射频(Radio Frequency,RF)电路710、存储器720、输入单元730、显示单元740、传感器750、音频电路760、无线保真(wireless fidelity,WiFi)模块770、处理器780、以及电源790等部件。本领域技术人员可以理解,图7所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。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. Referring to FIG. 7, 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. It will be understood by those skilled in the art that the structure of the mobile phone shown in FIG. 7 does not constitute a limitation to the mobile phone, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements.
其中,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)等。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. Generally, 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. In addition, 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.
存储器720可用于存储软件程序以及模块,处理器780通过运行存储在存储器720的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器720可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器720可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。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. Moreover, 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.
输入单元730可用于接收输入的数字或字符信息,以及产生与手机700的用户设置以及功能控制有关的键信号输入。具体地,输入单元730可包括触控面板731以及其他输入设备732。触控面板731,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板731上或在触控面板731附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板731可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触 摸信息,并将它转换成触点坐标,再送给处理器780,并能接收处理器780发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板731。除了触控面板731,输入单元730还可以包括其他输入设备732。具体地,其他输入设备732可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。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. Specifically, 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. In one embodiment, the touch panel 731 can include two portions of a touch detection device and a touch controller. Wherein, 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. In addition, the touch panel 731 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 731, the input unit 730 may also include other input devices 732. In particular, 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.).
显示单元740可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元740可包括显示面板741。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板741。在一个实施例中,触控面板731可覆盖显示面板741,当触控面板731检测到在其上或附近的触摸操作后,传送给处理器780以确定触摸事件的类型,随后处理器780根据触摸事件的类型在显示面板741上提供相应的视觉输出。虽然在图7中,触控面板731与显示面板741是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板731与显示面板741集成而实现手机的输入和输出功能。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. In one embodiment, 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. In one embodiment, 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. Although the 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.
手机700还可包括至少一种传感器750,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板741的亮度,接近传感器可在手机移动到耳边时,关闭显示面板741和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。The handset 700 can also include at least one type of sensor 750, such as a light sensor, motion sensor, and other sensors. Specifically, 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.
音频电路760、扬声器761和传声器762可提供用户与手机之间的音频接口。音频电路760可将接收到的音频数据转换后的电信号,传输到扬声器761,由扬声器761转换为声音信号输出;另一方面,传声器762将收集的声音信号转换为电信号,由音频电路760接收后转换为音频数据,再将音频数据输出处理器780处理后,经RF电路710可以发送给另一手机,或者将音频数据输出至存储器720以便后续处理。 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属于短距离无线传输技术,手机通过WiFi模块770可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图7示出了WiFi模块770,但是可以理解的是,其并不属于手机700的必须构成,可以根据需要而省略。WiFi is a short-range wireless transmission technology, and 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. Although 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.
处理器780是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器720内的软件程序和/或模块,以及调用存储在存储器720内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器780可包括一个或多个处理单元。在一个实施例中,处理器780可集成应用处理器和调制解调器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调器主要处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器780中。比如,该处理器780可集成应用处理器和基带处理器,基带处理器与和其它外围芯片等可组成调制解调器。手机700还包括给各个部件供电的电源790(比如电池),优选的,电源可以通过电源管理系统与处理器780逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。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. In one embodiment, processor 780 can include one or more processing units. In one embodiment, 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. For example, 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. Preferably, 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.
在一个实施例中,手机700还可以包括摄像头、蓝牙模块等。In one embodiment, the handset 700 can also include a camera, a Bluetooth module, and the like.
在本申请实施例中,该手机所包括的处理器执行存储在存储器上的计算机程序时实现上述所描述的进程处理方法。In the embodiment of the present application, the processor included in the mobile phone implements the process processing method described above when executing a computer program stored in the memory.
本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。合适的非易失性存储器可包括只读存储器(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)。Any reference to a memory, storage, database or other medium used herein may include non-volatile and/or volatile memory. Suitable non-volatile memories 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. By way of illustration and not limitation, 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. Link (Synchlink) DRAM (SLDRAM), Memory Bus (Rambus) Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM).
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above embodiments are merely illustrative of several embodiments of the present application, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the claims. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the scope of the invention should be determined by the appended claims.

Claims (27)

  1. 一种进程处理方法,所述方法包括:A process processing method, the method comprising:
    获取处于后台运行的守护进程的进程信息;Get the process information of the daemon running in the background;
    检测所述进程信息中是否包含预设的关键字;及Detecting whether the process information includes a preset keyword; and
    当包含所述关键字时,对所述守护进程进行资源限制。When the keyword is included, resource restrictions are imposed on the daemon.
  2. 根据权利要求1所述的方法,其特征在于,所述关键字包括第一关键字和第二关键字;The method of claim 1, wherein the keyword comprises a first keyword and a second keyword;
    所述检测所述进程信息中是否包含预设的关键字,包括:The detecting whether the process information includes a preset keyword includes:
    检测所述进程信息中的进程名称是否包含第一关键字;Detecting whether the process name in the process information includes a first keyword;
    检测所述进程信息中的用户身份标识UID是否包含第二关键字;及Detecting whether the user identity UID in the process information includes a second keyword; and
    所述当包含所述关键字时,对所述守护进程进行资源限制,包括:When the keyword is included, the resource limitation of the daemon process includes:
    当包含所述第一关键字和第二关键字时,对所述守护进程进行资源限制。When the first keyword and the second keyword are included, resource limitation is performed on the daemon process.
  3. 根据权利要求1所述的方法,其特征在于,在所述对所述守护进程进行资源限制之前,还包括:The method according to claim 1, wherein before the resource limiting the daemon process, the method further comprises:
    获取前台应用的应用类别,当所述应用类别为游戏类应用,执行所述对所述守护进程进行资源限制。Obtaining an application category of the foreground application, and when the application category is a game application, performing resource limitation on the daemon.
  4. 根据权利要求1所述的方法,其特征在于,所述对所述守护进程进行资源限制,包括:The method according to claim 1, wherein the resource limiting the daemon process comprises:
    降低所述守护进程的优先级;及Lowering the priority of the daemon; and
    根据降低后的优先级对所述守护进程进行资源限制。The daemon is resource limited according to the lowered priority.
  5. 根据权利要求1所述的方法,其特征在于,所述守护进程进行资源限制,包括:The method according to claim 1, wherein the daemon process performs resource limitation, including:
    根据本地的资源利用率计算出对所述守护进程的限制程度;及Calculating the degree of restriction on the daemon process based on local resource utilization; and
    根据所述限制程度对所述守护进程进行资源限制。Restricting resources of the daemon process according to the degree of limitation.
  6. 根据权利要求1所述的方法,其特征在于,所述对所述守护进程进行资源限制,包括:The method according to claim 1, wherein the resource limiting the daemon process comprises:
    对所述守护进程所占用的CPU资源和I/O资源进行限制。Limit the CPU resources and I/O resources occupied by the daemon process.
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,在所述对所述守护进程进行资源限制之前,还包括:The method according to any one of claims 1 to 6, further comprising: before the resource limiting the daemon process, further comprising:
    检测所述守护进程是否被前台进程依赖;Detecting whether the daemon process is dependent on the foreground process;
    当所述守护进程被前台进程依赖时,将所述守护进程的优先级调整至与前台进程相匹配;及When the daemon process is dependent on the foreground process, the priority of the daemon is adjusted to match the foreground process; and
    当所述守护进程未被前台进程依赖时,执行所述对所述守护进程进行资源限制。The resource restriction on the daemon process is performed when the daemon process is not dependent on the foreground process.
  8. 根据权利要求7所述的方法,其特征在于,所述检测待处理应用是否被前台应用依赖,包括:The method according to claim 7, wherein the detecting whether the application to be processed is dependent on the foreground application comprises:
    检测所述待处理应用与所述前台应用之间是否存在通信机制和同步机制中的至少一种;及Detecting whether at least one of a communication mechanism and a synchronization mechanism exists between the to-be-processed application and the foreground application; and
    当所述待处理应用与所述前台应用之间存在通信机制和同步机制中的至少一种时,所述待处理应用被所述前台应用依赖。The to-be-processed application is dependent on the foreground application when there is at least one of a communication mechanism and a synchronization mechanism between the to-be-processed application and the foreground application.
  9. 根据权利要求8所述的方法,其特征在于,当所述待处理应用与所述前台应用之间存在socket通信、binder通信、内存共享或锁等待时,所述待处理应用与所述前台应用之间存在通信机制。The method according to claim 8, wherein when the socket application, the binder communication, the memory sharing or the lock wait exists between the to-be-processed application and the foreground application, the to-be-processed application and the foreground application There is a communication mechanism between them.
  10. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时,使得所述处理器执行以下操作:A computer readable storage medium having stored thereon a computer program, wherein when the computer program is executed by a processor, the processor causes the processor to:
    获取处于后台运行的守护进程的进程信息;Get the process information of the daemon running in the background;
    检测所述进程信息中是否包含预设的关键字;及Detecting whether the process information includes a preset keyword; and
    当包含所述关键字时,对所述守护进程进行资源限制。When the keyword is included, resource restrictions are imposed on the daemon.
  11. 根据权利要求10所述的计算机可读存储介质,其特征在于,所述关键字包括第一关键字和第二关键字;所述计算机程序被所述处理器执行时,使得所述处理器在执行所述检测所述进程信息中是否包含预设的关键字时,还执行以下操作:A computer readable storage medium according to claim 10, wherein said keyword comprises a first keyword and a second keyword; said computer program being executed by said processor such that said processor is When performing the detecting whether the process information includes a preset keyword, the following operations are also performed:
    检测所述进程信息中的进程名称是否包含第一关键字;Detecting whether the process name in the process information includes a first keyword;
    检测所述进程信息中的用户身份标识UID是否包含第二关键字;及Detecting whether the user identity UID in the process information includes a second keyword; and
    所述当包含所述关键字时,对所述守护进程进行资源限制,包括:When the keyword is included, the resource limitation of the daemon process includes:
    当包含所述第一关键字和第二关键字时,对所述守护进程进行资源限制。When the first keyword and the second keyword are included, resource limitation is performed on the daemon process.
  12. 根据权利要求10所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制之前,还执行以下操作:The computer readable storage medium of claim 10, wherein the computer program is executed by the processor such that the processor further performs before performing the resource restriction on the daemon process The following operations:
    获取前台应用的应用类别,当所述应用类别为游戏类应用,执行所述对所述守护进程进行资源限制。Obtaining an application category of the foreground application, and when the application category is a game application, performing resource limitation on the daemon.
  13. 根据权利要求10所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制时,还执行以下操作:A computer readable storage medium according to claim 10, wherein said computer program is executed by said processor such that said processor further executes when said performing resource restriction on said daemon process The following operations:
    降低所述守护进程的优先级;及Lowering the priority of the daemon; and
    根据降低后的优先级对所述守护进程进行资源限制。The daemon is resource limited according to the lowered priority.
  14. 根据权利要求10所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述守护进程进行资源限制时,还执行以下操作:The computer readable storage medium of claim 10, wherein when the computer program is executed by the processor, causing the processor to perform the following operations when performing the resource limitation by the daemon:
    根据本地的资源利用率计算出对所述守护进程的限制程度;及Calculating the degree of restriction on the daemon process based on local resource utilization; and
    根据所述限制程度对所述守护进程进行资源限制。Restricting resources of the daemon process according to the degree of limitation.
  15. 根据权利要求10所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制时,还执行以下操作:A computer readable storage medium according to claim 10, wherein said computer program is executed by said processor such that said processor further executes when said performing resource restriction on said daemon process The following operations:
    对所述守护进程所占用的CPU资源和I/O资源进行限制。Limit the CPU resources and I/O resources occupied by the daemon process.
  16. 根据权利要求10至15中任一项所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制之前,还执行以下操作:The computer readable storage medium according to any one of claims 10 to 15, wherein the computer program is executed by the processor, causing the processor to perform the pairing of the daemon Before the resource is restricted, the following actions are also performed:
    检测所述守护进程是否被前台进程依赖;Detecting whether the daemon process is dependent on the foreground process;
    当所述守护进程被前台进程依赖时,将所述守护进程的优先级调整至与前台进程相匹配;及When the daemon process is dependent on the foreground process, the priority of the daemon is adjusted to match the foreground process; and
    当所述守护进程未被前台进程依赖时,执行所述对所述守护进程进行资源限制。The resource restriction on the daemon process is performed when the daemon process is not dependent on the foreground process.
  17. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述检测待处理应用是否被前台应用依赖时,还执行以下操作:The computer readable storage medium of claim 16, wherein when the computer program is executed by the processor, causing the processor to perform a process of detecting whether an application to be processed is dependent on a foreground application, Do the following:
    检测所述待处理应用与所述前台应用之间是否存在通信机制和同步机制中的至少一种;及Detecting whether at least one of a communication mechanism and a synchronization mechanism exists between the to-be-processed application and the foreground application; and
    当所述待处理应用与所述前台应用之间存在通信机制和同步机制中的至少一种时,所述待处理应用被所述前台应用依赖。The to-be-processed application is dependent on the foreground application when there is at least one of a communication mechanism and a synchronization mechanism between the to-be-processed application and the foreground application.
  18. 根据权利要求17所述的计算机可读存储介质,其特征在于,当所述待处理应用与所述前台应用之间存在socket通信、binder通信、内存共享或锁等待时,所述待处理应用与所述前台应用之间存在通信机制。The computer readable storage medium according to claim 17, wherein when there is socket communication, binder communication, memory sharing or lock waiting between the to-be-processed application and the foreground application, the to-be-processed application and There is a communication mechanism between the foreground applications.
  19. 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时,使得所述处理器执行以下操作:An electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein when the processor executes the computer program, the processor causes the processor to:
    获取处于后台运行的守护进程的进程信息;Get the process information of the daemon running in the background;
    检测所述进程信息中是否包含预设的关键字;及Detecting whether the process information includes a preset keyword; and
    当包含所述关键字时,对所述守护进程进行资源限制。When the keyword is included, resource restrictions are imposed on the daemon.
  20. 根据权利要求19所述的电子设备,其特征在于,所述关键字包括第一关键字和第二关键字;所述计算机程序被所述处理器执行时,使得所述处理器在执行所述检测所述进程信息中是否包含预设的关键字时,还执行以下操作:The electronic device of claim 19, wherein the keyword comprises a first keyword and a second keyword; when the computer program is executed by the processor, causing the processor to perform the When detecting whether the process information includes a preset keyword, the following operations are also performed:
    检测所述进程信息中的进程名称是否包含第一关键字;Detecting whether the process name in the process information includes a first keyword;
    检测所述进程信息中的用户身份标识UID是否包含第二关键字;及Detecting whether the user identity UID in the process information includes a second keyword; and
    所述当包含所述关键字时,对所述守护进程进行资源限制,包括:When the keyword is included, the resource limitation of the daemon process includes:
    当包含所述第一关键字和第二关键字时,对所述守护进程进行资源限制。When the first keyword and the second keyword are included, resource limitation is performed on the daemon process.
  21. 根据权利要求19所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制之前,还执行以下操作:The electronic device according to claim 19, wherein when said computer program is executed by said processor, said processor further performs the following operations before performing said resource limitation on said daemon:
    获取前台应用的应用类别,当所述应用类别为游戏类应用,执行所述对所述守护进程进行资源限制。Obtaining an application category of the foreground application, and when the application category is a game application, performing resource limitation on the daemon.
  22. 根据权利要求19所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制时,还执行以下操作:The electronic device according to claim 19, wherein when the computer program is executed by the processor, the processor further performs the following operations when performing the resource limitation on the daemon process:
    降低所述守护进程的优先级;及Lowering the priority of the daemon; and
    根据降低后的优先级对所述守护进程进行资源限制。The daemon is resource limited according to the lowered priority.
  23. 根据权利要求19所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述守护进程进行资源限制时,还执行以下操作:The electronic device according to claim 19, wherein when said computer program is executed by said processor, said processor further performs the following operations when said processor performs resource limitation by said daemon:
    根据本地的资源利用率计算出对所述守护进程的限制程度;及Calculating the degree of restriction on the daemon process based on local resource utilization; and
    根据所述限制程度对所述守护进程进行资源限制。Restricting resources of the daemon process according to the degree of limitation.
  24. 根据权利要求19所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制时,还执行以下操作:The electronic device according to claim 19, wherein when the computer program is executed by the processor, the processor further performs the following operations when performing the resource limitation on the daemon process:
    对所述守护进程所占用的CPU资源和I/O资源进行限制。Limit the CPU resources and I/O resources occupied by the daemon process.
  25. 根据权利要求19至24中任一项所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述对所述守护进程进行资源限制之前,还执行以下操作:An electronic device according to any one of claims 19 to 24, wherein said computer program is executed by said processor such that said processor performs resource limiting of said daemon process prior to said , also do the following:
    检测所述守护进程是否被前台进程依赖;Detecting whether the daemon process is dependent on the foreground process;
    当所述守护进程被前台进程依赖时,将所述守护进程的优先级调整至与前台进程相匹配;及When the daemon process is dependent on the foreground process, the priority of the daemon is adjusted to match the foreground process; and
    当所述守护进程未被前台进程依赖时,执行所述对所述守护进程进行资源限制。The resource restriction on the daemon process is performed when the daemon process is not dependent on the foreground process.
  26. 根据权利要求25所述的电子设备,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器在执行所述检测待处理应用是否被前台应用依赖时,还执行以下操作:The electronic device according to claim 25, wherein when said computer program is executed by said processor, said processor further performs the following operations when said detecting whether said application to be processed is dependent by a foreground application :
    检测所述待处理应用与所述前台应用之间是否存在通信机制和同步机制中的至少一种;及Detecting whether at least one of a communication mechanism and a synchronization mechanism exists between the to-be-processed application and the foreground application; and
    当所述待处理应用与所述前台应用之间存在通信机制和同步机制中的至少一种时,所述待处理应用被所述前台应用依赖。The to-be-processed application is dependent on the foreground application when there is at least one of a communication mechanism and a synchronization mechanism between the to-be-processed application and the foreground application.
  27. 根据权利要求26所述的电子设备,其特征在于,当所述待处理应用与所述前台应用之间存在socket通信、binder通信、内存共享或锁等待时,所述待处理应用与所述前台应用之间存在通信机制。The electronic device according to claim 26, wherein when there is socket communication, binder communication, memory sharing or lock waiting between the to-be-processed application and the foreground application, the to-be-processed application and the foreground There is a communication mechanism between applications.
PCT/CN2018/116526 2017-12-29 2018-11-20 Process handling method, and electronic device and computer-readable storage medium WO2019128545A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711484424.XA CN109992394B (en) 2017-12-29 2017-12-29 Process processing method and device, electronic equipment and computer readable storage medium
CN201711484424.X 2017-12-29

Publications (1)

Publication Number Publication Date
WO2019128545A1 true WO2019128545A1 (en) 2019-07-04

Family

ID=67063020

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/116526 WO2019128545A1 (en) 2017-12-29 2018-11-20 Process handling method, and electronic device and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN109992394B (en)
WO (1) WO2019128545A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115016631B (en) * 2021-11-22 2023-07-18 荣耀终端有限公司 Process scheduling method and terminal equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101777107A (en) * 2009-01-14 2010-07-14 深圳市维信联合科技有限公司 Document protection method, protection module and computer
CN103117895A (en) * 2013-01-25 2013-05-22 哈尔滨工业大学 LXI instrument service monitoring method
CN104991803A (en) * 2015-07-10 2015-10-21 上海斐讯数据通信技术有限公司 System and method for managing and controlling self-startup of android application under specific conditions

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102331950B (en) * 2011-09-15 2017-02-22 北京安天电子设备有限公司 Method and system for realizing daemon process based on Linux operation system timing task
CN103020181A (en) * 2012-11-29 2013-04-03 乐视致新电子科技(天津)有限公司 Method and system for loading and playing information
CN106897612A (en) * 2015-12-18 2017-06-27 北京奇虎科技有限公司 A kind of method and device for intercepting bundled software
CN105975320B (en) * 2016-05-26 2020-03-17 宇龙计算机通信科技(深圳)有限公司 Method and device for forbidding installation of third-party application and terminal

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101777107A (en) * 2009-01-14 2010-07-14 深圳市维信联合科技有限公司 Document protection method, protection module and computer
CN103117895A (en) * 2013-01-25 2013-05-22 哈尔滨工业大学 LXI instrument service monitoring method
CN104991803A (en) * 2015-07-10 2015-10-21 上海斐讯数据通信技术有限公司 System and method for managing and controlling self-startup of android application under specific conditions

Also Published As

Publication number Publication date
CN109992394A (en) 2019-07-09
CN109992394B (en) 2021-08-17

Similar Documents

Publication Publication Date Title
US10187872B2 (en) Electronic device and method of providing notification by electronic device
KR102148948B1 (en) Multi tasking method of electronic apparatus and electronic apparatus thereof
US20190220318A1 (en) Memory Reclamation Method and Apparatus
CN105630129B (en) Power control method and apparatus for reducing power consumption
WO2019128540A1 (en) Resource management method, mobile terminal and computer readable storage medium
KR102161200B1 (en) Method for controlling a sleep mode and an electronic device thereof
WO2022262530A1 (en) Memory management method and electronic device
WO2019128546A1 (en) Application program processing method, electronic device, and computer readable storage medium
WO2019137252A1 (en) Memory processing method, electronic device, and computer-readable storage medium
US20170269725A1 (en) Electronic device for touch and finger scan sensor input and control method thereof
WO2019128588A1 (en) Process processing method and apparatus, electronic device, computer readable storage medium
WO2019128537A1 (en) Application freezing method, and computer device and computer-readable storage medium
WO2019128549A1 (en) Method and apparatus for freezing application, and terminal and computer-readable storage medium
CN109992965B (en) Process processing method and device, electronic equipment and computer readable storage medium
US9760417B2 (en) Application dehydration and rehydration during application-to-application calls
KR102586628B1 (en) Electronic Device AND Memory Management Method Thereof
WO2019128574A1 (en) Information processing method and device, computer device and computer readable storage medium
WO2019128573A1 (en) Information processing method, apparatus, computer device and computer-readable storage medium
WO2019128571A1 (en) Resource management method and device, mobile terminal, as well as computer readable storage medium
JP2018504708A (en) Method, device, and system for managing information recommendations
WO2019137258A1 (en) Memory processing method, electronic device and computer readable storage medium
WO2019184631A1 (en) Information processing method and apparatus, computer-readable storage medium, and terminal
CN110032321B (en) Application processing method and device, electronic equipment and computer readable storage medium
WO2019128569A1 (en) Method and apparatus for freezing application, and storage medium and terminal
WO2019128586A1 (en) Application processing method, electronic device, and computer readable storage medium

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: 18893466

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: 18893466

Country of ref document: EP

Kind code of ref document: A1