WO2019137173A1 - 资源管理方法、移动终端及计算机可读存储介质 - Google Patents

资源管理方法、移动终端及计算机可读存储介质 Download PDF

Info

Publication number
WO2019137173A1
WO2019137173A1 PCT/CN2018/122086 CN2018122086W WO2019137173A1 WO 2019137173 A1 WO2019137173 A1 WO 2019137173A1 CN 2018122086 W CN2018122086 W CN 2018122086W WO 2019137173 A1 WO2019137173 A1 WO 2019137173A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
application
background
foreground
restriction level
Prior art date
Application number
PCT/CN2018/122086
Other languages
English (en)
French (fr)
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 WO2019137173A1 publication Critical patent/WO2019137173A1/zh

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/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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • 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
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a resource management method, a mobile terminal, and a computer readable storage medium.
  • a resource management method, a mobile terminal, and a computer readable storage medium are provided according to various embodiments of the present application.
  • a resource management method including:
  • a mobile terminal includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following operations:
  • a computer readable storage medium having stored thereon a computer program, the computer program being executed by a processor to:
  • the resource management method, the mobile terminal, and the computer readable storage medium provided by the embodiments of the present application when detecting that the application enters the background operation, may obtain resource usage data when the application runs in the background in a preset time period, according to the resource usage data. Determining the resource usage level of the application and the resource restriction level under the resource type, and assigning the application to the resource configuration corresponding to the resource restriction level under the resource type used, and configuring the resource usage priority corresponding to the resource restriction level, which can be used in the background.
  • the application dynamically implements different levels of resource constraints under different resource types to optimize system performance and save power.
  • FIG. 1 is a block diagram of a mobile terminal in one embodiment.
  • FIG. 2 is a system architecture diagram of a resource management method in an embodiment.
  • FIG. 3 is a schematic flow chart of a resource management method in an embodiment.
  • FIG. 4 is a schematic flow chart of determining a resource restriction level of an application under a resource type in an embodiment.
  • FIG. 5 is a schematic flowchart of a resource group corresponding to a resource restriction level allocated to an used resource category in an embodiment.
  • FIG. 6 is a schematic flowchart of reducing the resource restriction level of a background process having a dependency relationship with a foreground process in one embodiment.
  • Figure 7 is a block diagram of a resource management device in one embodiment.
  • Figure 8 is a block diagram of a level determination module in one embodiment.
  • Figure 9 is a block diagram of a configuration module in one embodiment.
  • Figure 10 is a block diagram of a mobile terminal in another embodiment.
  • the mobile terminal includes a processor, a memory, a display screen, and an input device connected through a system bus.
  • the memory may include a non-volatile storage medium and a processor.
  • the non-volatile storage medium of the mobile terminal stores an operating system and a computer program, which are executed by the processor to implement a resource management method provided in the embodiments of the present application.
  • the processor is used to provide computing and control capabilities to support the operation of the entire mobile terminal.
  • the internal memory in the mobile terminal provides an environment for the operation of a computer program in a non-volatile storage medium.
  • the display screen of the mobile terminal may be a liquid crystal display or an electronic ink display screen.
  • the input device may be a touch layer covered on the display screen, or may be a button, a trackball or a touchpad provided on the casing of the mobile terminal, or may be An external keyboard, trackpad, or mouse.
  • the mobile terminal can be a mobile phone, a tablet or a personal digital assistant or a wearable device.
  • 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 of the mobile terminal to which the solution of the present application is applied.
  • the specific mobile terminal may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
  • the system architecture includes a JAVA spatial layer 210, a local framework layer 220, and a kernel space layer 230.
  • the JAVA spatial layer 210 can include a freeze management module 212.
  • the freeze management module 212 can implement a freeze policy for each running application, and freeze the related applications that consume more power in the background or preempt a large amount of system resources.
  • a resource priority and restriction manager 222 and a platform freeze manager 224 are included in the local framework layer 220.
  • the mobile terminal can maintain different applications in different resource usage priorities and different resource groups in real time through the resource priority and restriction manager 222, and adjust the resource group of the application according to the requirements of the upper layer to achieve optimized performance.
  • the mobile terminal can use the platform freeze manager 224 to allocate the freezeable application in the background to the freeze layer of the corresponding preset different levels according to the length of the entry freeze time.
  • the frozen layer may include three: a CPU limited sleep mode, a CPU freeze sleep mode, and a process deep freeze mode.
  • the CPU restricts the sleep mode to limit the CPU resources occupied by the related processes, so that the related processes occupy less CPU resources, and the free CPU resources are tilted to other unfrozen processes, thereby limiting the occupation of CPU resources.
  • the local framework layer 220 may further include an interface module, where the interface module includes a binder interface developed to the upper layer, and the upper layer framework or the application sends the resource restriction or the frozen instruction to the resource priority and the limit management through the provided binder interface.
  • the kernel space layer 230 may include a UID management module 231, a Cgroup module 233, a Binder management module 235, a process memory recovery module 237, and a freeze timeout exit module 239.
  • 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 233 is used to provide a complete set of CPU, CPUSET, memory, input/output (I/O) and Net related resource restriction mechanisms.
  • the Binder management module 235 is used to implement the priority control of the background binder communication.
  • the process memory recovery module 237 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 freeze timeout exit module 239 can be used to resolve an exception generated by the freeze timeout scenario.
  • a resource management method including the following operations:
  • the mobile terminal can run one or more applications at the same time, and can include a foreground application running in the foreground and a background application running in the background.
  • the mobile terminal can monitor each running application and detect whether an application is running in the background.
  • the application enters the background operation, which may be that the application switches from the foreground operation to the background operation, or may directly enter the background operation after the application is started.
  • the mobile terminal can monitor various running applications through the activity manager to monitor the running status changes of the respective applications.
  • the running status of the application may include, but is not limited to, startup, foreground running, background running, exiting, and the like.
  • the mobile terminal can obtain a list of all running applications through the activity manager's RunningAppProcessInfo class at intervals, for example, get a list of all running applications every 2 seconds, and judge each running in the application list one by one.
  • the running state of the application is running in the foreground or in the background.
  • the mobile terminal detects that the application is running in the background in the application list acquired this time, and is not running in the background in the application list obtained last time, it may be determined that the application is an application running in the background.
  • the mobile terminal can also monitor the life cycle of each activity and obtain the running status of each running application according to the life cycle of each activity.
  • the mobile terminal can establish a global counter, and count each activity's call to onStart and onStop.
  • the global counter is incremented by 1.
  • the global counter is decremented by 1.
  • the application's global counter is greater than 0, it indicates that the application is running in the foreground.
  • the application's global counter is equal to 0, it indicates that the application is running in the background.
  • the mobile terminal detects that the global counter of the application changes from 1 to 0, it can be determined that the application enters the background operation, or the mobile terminal detects that a new activity is created, and the global counter of the application corresponding to the new activity is 0. Then, you can determine that the application goes into the background and so on. It can be understood that the mobile terminal detects that the application enters the background operation, and other methods may be used, and is not limited to the above manner.
  • the resource usage data obtained when the application is running in the background in the preset time period may be acquired.
  • the preset time period can be set according to actual needs, such as 3 days, one week, and so on.
  • the resource usage data may include a resource type and an occupation ratio occupied by the application each time in the background in a preset time period, and the resource types may include, but are not limited to, a CPU, an I/O, a memory, and a network resource.
  • Operation 320 Acquire a resource type used by the application according to the resource usage data.
  • the mobile terminal can obtain the resource type used by the application according to the resource usage data of the application running in the background, and the resource type used by the application may be the resource type included in the resource usage data.
  • the application runs in the background for a total of 2 times in the preset time period. When it runs in the background for the first time, it occupies 20% of the CPU and 10% of the memory. When it runs in the background for the second time, it takes up 10% of the CPU, 10% of the memory, and 30% of the network.
  • the type of resources that the mobile terminal can obtain for the application may include a CPU, a memory, and a network resource.
  • the resource type used by the application may also be a resource type in which the proportion of the resource usage data is greater than a preset value, and different preset types may be set for different resource types.
  • the mobile terminal may perform statistics on the types of resources and the proportion of resources occupied by the application each time in the background in the preset time period, and calculate the different resource types when the application runs in the background in the preset time period. Average occupancy ratio. The mobile terminal compares the average occupancy ratio of the resource type with the preset value corresponding to the resource type, and determines whether the average occupancy ratio is greater than the corresponding preset value. For example, the application runs in the background for a total of 3 times in the preset time period.
  • the mobile terminal can calculate that the average occupancy ratio of the application in the CPU resources is 18.3%, the average occupation ratio of the memory resources is 13.3%, and the average occupation ratio of the CPU resources is greater than the preset value of 8. %, the average occupancy ratio of the memory resource is greater than the preset value of 10%, the mobile terminal can determine that the resource type used by the application includes the CPU and the memory resource.
  • Operation 330 determining a resource restriction level of the application under the resource category according to the resource usage data.
  • the mobile terminal may set different resource restriction levels according to actual requirements.
  • the resource restriction level may be used to indicate the extent to which the application usage resource is restricted. The higher the resource restriction level, the greater the degree of restriction. Restricted resources may include, but are not limited to, CPU resources, memory resources, I/O resources, network resources, and the like.
  • the resource restriction level of each resource type used by the application may be determined according to the occupation ratio of each resource type used by the application in the resource usage data.
  • the resource restriction level set by the mobile terminal may include an unrestricted level, a normal restriction level, a depth restriction level, a freeze level, and the like.
  • An unrestricted level can mean that the resources used by the application are not limited.
  • the normal restriction level may refer to an application that can use less resources, such as up to 50% of resources, but is not limited thereto.
  • the depth limit level may refer to an application that can use very few resources, such as a maximum of only 20% of resources, but is not limited thereto.
  • the freeze level refers to the behavior of the application that cannot use any resources and stop the application.
  • the different types of resources may include the resource restriction levels set by the foregoing, and the mobile terminal may separately set the resource restriction levels of the applications running in the background for different types of resources.
  • different types of resources may include the resource restriction levels set by the foregoing, and the mobile terminal may determine, according to the proportion of the different resource types in the resource usage data of the application, the resources of each resource type that should be used. Restricted level.
  • the resource restriction level can also be divided according to other methods, and is not limited to this, and different resource types can also be divided into different resource restriction levels.
  • different resource restriction levels under the resource category may correspond to different occupation ratio intervals.
  • the interval corresponding to the unrestricted level of the network resource may be that the proportion of the network resources occupied by the application is less than 10%
  • the interval corresponding to the common restriction level may be that the proportion of the network resources occupied by the application is between 10% and 30%
  • the depth limit level corresponds to
  • the interval of the network resources occupied by the application is between 30% and 70%
  • the interval corresponding to the freeze level may be that the proportion of the network resources occupied by the application is greater than 70%.
  • the interval corresponding to the unrestricted level of the CPU resource may be that the proportion of the CPU resources occupied by the application is less than 5%, and the interval corresponding to the common restriction level may be the ratio of the CPU resources occupied by the application between 5% and 15%, and the interval corresponding to the depth limit level.
  • the ratio of the CPU resources occupied by the application may be between 15% and 30%, and the interval corresponding to the depth limit level may be greater than 30% of the CPU resources occupied by the application, but is not limited thereto.
  • the mobile device may obtain the occupation ratio interval of each resource type used by the application according to the resource usage data, thereby determining each application to be used.
  • the resource restriction level of the resource type For example, the mobile terminal can calculate the average occupancy ratio of the application in each resource category, and obtain the occupation ratio interval to which the average occupancy ratio belongs, thereby determining the resource restriction level of each resource category used by the application.
  • the application is allocated to the resource group corresponding to the resource restriction level under the resource category, and the resource usage priority corresponding to the resource restriction level is configured.
  • the mobile terminal may allocate the application to the resource group corresponding to the resource restriction level under the used resource category, and configure and determine the resource restriction level.
  • the corresponding resource usage priority The higher the resource restriction level, the more restrictive the resource usage is, and the lower the resource usage priority.
  • the mobile terminal may divide different resource groups based on a kernel Cgroup (control group) mechanism, and set a resource usage priority of each resource group by using a file node write configuration manner, and is allocated to each resource group.
  • the application in the application is managed by the time or proportion of the resource.
  • the Cgroup is a physical resource (such as CPU, memory, I/O, network, etc.) that can be used to limit, record, and isolate the process.
  • Mechanisms For different kinds of resources, mobile terminals can be divided into different resource groups.
  • the mobile terminal can load a configuration file of the Cgroup, and the configuration file can record the divided resource groups, the resource usage priorities of the resource groups, and the resource scheduling policies corresponding to the resource usage priorities.
  • the resource scheduling policy may include, but is not limited to, the time allocated by the process allocated to the resource group, the proportion of occupied resources, the resource identifier used, and the like.
  • the application of the resource group corresponding to the common restriction level of the network resource can occupy up to 20% of the network resources, and the application of the resource group corresponding to the common restriction level of the configurable CPU resource can be used within 1 minute. Seconds CPU resources, etc., but are not limited to this.
  • the mobile terminal can be implemented by modifying the configuration file of the Cgroup.
  • the mobile terminal allocates the application running in the background to the resource group corresponding to the determined resource restriction level under the used resource category, and configures the resource usage priority corresponding to the determined resource restriction level, and the application may follow the resource group.
  • the corresponding resource scheduling policy uses the resource type.
  • the mobile terminal may determine, according to the resource usage data, a resource restriction level of the resource category used by the application, and allocate the application to each used resource category.
  • the resource group corresponding to the resource restriction level For example, the resource type used by the mobile terminal to obtain the application running in the background includes the CPU resource and the network resource, and the resource restriction level of the application is determined to be the depth limit level according to the resource usage data, and the resource restriction level of the network resource is normal. Limit level.
  • the mobile terminal may separately allocate the application to a resource group corresponding to the depth limit level under the CPU resource, and a resource group corresponding to the common restriction level under the network resource.
  • the resource usage data of the application running in the background in a preset time period may be acquired, and the resource type used by the application and the resource limitation under the resource category are determined according to the resource usage data.
  • the level and the application are allocated to the resource configuration corresponding to the resource restriction level in the resource type to be used, and the resource usage priority corresponding to the resource restriction level is configured, and the background application can dynamically implement different resource limits in different resource types. Optimize system performance and save power.
  • operation 330 determines a resource restriction level of the application under the resource category based on the resource usage data, including the following operations:
  • Operation 402 Obtain a proportion of resource types currently used by the application that are not currently occupied.
  • the mobile terminal detects that the application enters the background operation, acquires resource usage data when the application runs in the background in a preset time period, and acquires the resource type used by the application according to the resource usage data.
  • the mobile terminal can obtain the proportion of the current resource usage of the application that is not occupied by the application. Specifically, the current occupation ratio of each resource category used by the application can be obtained, and the proportion of the unoccupied is calculated according to the occupation ratio.
  • the mobile terminal may record the activity data of each resource category in a preset file.
  • the activity data of different resource categories may be recorded in different preset files.
  • the activity data of the resource type may refer to data generated when the corresponding resource type is occupied to provide operating capability to an operating system or an application of the mobile terminal.
  • the preset file corresponding to the CPU resource may record the accumulated working time of the CPU from the time when the mobile terminal is started to the current time, and the accumulated time of the different processes or applications from the mobile terminal to the current time using the CPU;
  • the corresponding preset file may record the size of the memory occupied at different times, and the size of the memory occupied by different processes or applications, etc., but is not limited thereto.
  • the mobile terminal may read activity data of each resource category used by the application running in the background from the preset file, and calculate, according to the activity data, a proportion of each resource category used by the application that is not currently occupied.
  • the mobile terminal can read the accumulated working time of the CPU from the mobile terminal to the current time from the /proc/stat file in the /proc directory according to a preset collection period.
  • the mobile terminal can record the accumulated working time of each read CPU, and calculate the difference between the accumulated working time of the CPU recorded this time and the accumulated working time of the last recorded CPU, and obtain the real work of the CPU in the collection period. time.
  • the mobile terminal can determine the ratio of the actual working time of the CPU to the collection period in the collection period, and the ratio is the total occupancy rate of the CPU, etc., and the idle rate of the CPU can be obtained according to the total occupancy rate of the CPU, and the space ratio of the CPU is the CPU.
  • the proportion of occupation The mobile terminal can also read the current occupied size of the memory from the preset file corresponding to the memory at a certain time period, and determine the current memory occupation ratio according to the current occupied size of the memory, thereby obtaining the memory that is currently not occupied. proportion.
  • the resource restriction level applied under the resource category is determined according to the resource usage data.
  • the mobile terminal can compare the proportion of the currently unoccupied resource types used by the application running in the background with the preset threshold. When the proportion of the resource type that is not currently occupied is less than the preset threshold, the mobile terminal can indicate that the resource type is busy.
  • the mobile terminal can limit the use of the resource type to applications running in the background.
  • the mobile terminal can determine the resource restriction level under the resource category according to the occupation ratio of the resource type in the application running in the background. When the proportion of the resource type that is not currently occupied is greater than or equal to the preset threshold, the resource type may be in a relatively idle state, and the resource usage restriction may not be performed on the application running in the background.
  • the preset threshold may be set according to actual requirements, and the different resource types may correspond to different preset thresholds. For example, the preset threshold corresponding to the CPU resource may be 40%, and the preset threshold corresponding to the network resource may be 30. %, etc., but not limited to this.
  • the mobile terminal may detect whether there is a foreground application running, and when there is a foreground application running, the application that runs in the background may be
  • the resource usage data determines the resource restriction level of the application under the resource category. It can maximize the use of resources in the foreground application, and reduce the situation that the background application and the foreground application preempt the resources and cause the card to be stuck.
  • determining the resource restriction level of the application under the resource type according to the resource usage data of the application may be
  • the background application dynamically implements different levels of resource constraints under different resource types, optimizes system performance, and saves power.
  • the operation allocates an application to a resource group corresponding to a resource restriction level under a resource category, including the following operations:
  • Operation 502 obtaining user group information of the application.
  • a process is a running activity of a program on a computer on a data set. It is the basic unit for resource allocation and scheduling, and is the basis of the operating system structure. There are usually multiple processes running on a mobile terminal, and different processes can be used to perform different tasks separately.
  • the mobile terminal can assign different user groups to the running application, and can manage the permissions of the application through the user group.
  • the mobile terminal allocates the application group that runs in the background to the resource group corresponding to the determined resource restriction level, and obtains the application identifier of the application, and obtains the user group information of the application according to the application identifier.
  • the application identifier may be composed of one or more of numbers, letters, symbols, and the like.
  • the user group information may include a user group identifier or the like, wherein the user group identifier may be composed of one or more of numbers, letters, symbols, and the like.
  • Operation 504 querying a process identifier that has a mapping relationship with the user group information.
  • the mobile terminal can query the process identifiers that have a mapping relationship with the user group information according to the user group information of the application running in the background, thereby obtaining each process running under the application.
  • the kernel space layer of the mobile terminal can collect the user group information to which the process belongs in real time. When the process is created or destroyed, the kernel can allocate and release the user group information to which the process belongs, and the process can also occur during the running process. The case where the user group information is changed.
  • the kernel space layer collects user group information of each process in real time, and can establish a mapping relationship between process information such as process ID and process name and user group information.
  • the process identifier with the mapping relationship may be directly queried according to the user group information of the application, compared to traversing all running processes. Therefore, it is more convenient and quick to find the process running under the application and directly find the process identifier that has the mapping relationship with the user group information.
  • the background process that matches the process identifier is allocated to the resource group corresponding to the resource restriction level under the resource category.
  • the mobile terminal After the mobile terminal searches for the process identifier with the mapping relationship according to the user group information of the application running in the background, all the processes running under the application can be obtained according to the process identifier.
  • the mobile terminal may allocate all the processes running in the application to the resource group corresponding to the determined resource restriction level under the used resource category, and configure all the processes running under the application to correspond to the determined resource restriction level.
  • the resource usage priority enables the purpose of configuring the application to be a resource usage priority corresponding to the determined resource restriction level.
  • the process identifier with the mapping relationship may be found according to the user group information of the application, and the background process matching the process identifier is added to the resource group corresponding to the determined resource restriction level under the used resource category.
  • unified resource usage management can be performed on each process running under the background application according to the resource restriction level, thereby optimizing system performance and saving power consumption.
  • the foregoing resource management method further includes the following operations:
  • Operation 602 obtaining a foreground process running in the foreground.
  • the mobile terminal can obtain a foreground process running in the foreground.
  • the mobile terminal can obtain a list of all running processes through the activity manager's RunningAppProcessInfo class, and obtain a running status from the process list to the foreground.
  • the running process can determine that the running state is the foreground process running in the foreground.
  • Operation 604 when there is a background process having a dependency relationship with the foreground process, reducing the resource restriction level of the background process having the dependency.
  • the mobile terminal After the mobile terminal obtains the foreground process running in the foreground, it can detect whether there is a background process that has a dependency relationship with the foreground process.
  • the dependency relationship refers to a process that needs to wait for the message of another process to be executed normally, and then the two processes are executed. There is a dependency.
  • the mobile terminal may pre-record the process identifier with the dependency, obtain the process identifier of the foreground process, and obtain the process identifier that has a dependency relationship with the foreground process according to the process identifier of the foreground process.
  • the mobile terminal may detect each process running in the background according to the process identifier having a dependency relationship with the foreground process, and determine whether there is a background process having a dependency relationship with the foreground process.
  • the mobile terminal can reduce the resource restriction level of the background process that has a dependency relationship with the foreground process, and improve the resource usage priority of the background process with the dependency.
  • the mobile terminal may adjust the resource restriction level of the background process that has a dependency relationship with the foreground process to the same resource restriction as the foreground process, and may allocate the background process with the dependency to the same resource group as the foreground process. Do not, and configure the same resource usage priority as the foreground process.
  • the mobile terminal can detect whether there is a background process that has interactive communication with the foreground process, and the background process that has interactive communication with the foreground process can be determined as a background process having a dependency relationship with the foreground process.
  • the inter-process interaction communication may include a synchronization mechanism and/or a communication mechanism, etc., wherein the synchronization mechanism may refer to two processes coordinating with each other to complete a task, and the communication mechanism refers to spreading between different processes. Or exchange information.
  • the mobile terminal may detect whether there is a background process having a communication mechanism with the foreground process, and may determine a background process having a communication mechanism with the foreground process as a background process having a dependency.
  • the communication mechanism may include a socket, a binder, a shared memory, etc., wherein two programs on the network exchange data through a two-way communication connection, and one end of the connection is called a socket; the binder is an inter-process communication mechanism, providing Remote procedure call function; shared memory is to allow two unrelated processes to access the same logical memory, shared memory is a very effective way to share and transfer data between two running processes, sharing between different processes
  • the memory is usually arranged in the same piece of physical memory.
  • the mobile terminal may detect whether there is a background process that has a socket and/or a binder communication with the process running in the foreground, and may determine, as a dependency, a background process that has a socket and/or a binder communication with the process running in the foreground. backstage process.
  • the mobile terminal can also detect whether there is a background process that performs memory sharing with the process running in the foreground, and can determine the background process that performs memory sharing with the process running in the foreground as a background process with dependencies.
  • the mobile terminal may add a detection mechanism to the binder driver, and detect whether there is a background process having a communication mechanism with the foreground process according to the detection mechanism added in the binder driver.
  • the mobile terminal may detect whether there is a background process having a synchronization mechanism with the foreground process, and may determine a background process having a synchronization mechanism with the foreground process as a background process having a dependency.
  • the synchronization mechanism may include a semaphore, a mutex, etc., wherein the semaphore data structure is a value and a pointer pointing to the next process waiting for the semaphore, and the mutex can be used to ensure the integrity of the shared data. Sex, only one process can access an object with a mutex lock at any time.
  • the mobile terminal can detect, by using a call of a futex (fast user space mutex) system, whether there is a background process that has a synchronization mechanism with the foreground process.
  • the call of the futex system can be used to implement the synchronization mechanism between processes, and the operation in the user space is a user mode and kernel mode hybrid mechanism, wherein the user state refers to a non-privileged state.
  • the mobile terminal when it detects that a foreground process has a lock wait behavior, it may determine a lock resource that the foreground process waits for.
  • the lock resource may include a thread lock, a file handle, a signal, etc., wherein the file handle refers to a sequence number retrieved by the operating system function when the data is read from the file, so that the file can be opened, and the file handle is unique to the opened file. Identification basis.
  • the mobile terminal can traverse all the processes running in the background, and detect whether there is a background process waiting for the same lock resource as the foreground process, and the background process waiting for the same lock resource as the foreground process can be determined as a background process having a dependency.
  • the mobile terminal can detect whether the background process having a dependency on the foreground process ends the dependency. For example, the mobile terminal can detect whether the background process ends the communication with the socket and/or the binder of the process running in the foreground, and when the communication ends, it is determined to end the dependency. The mobile terminal can also detect whether the background process waiting for the same lock resource with the foreground running process completes the task, and when the task is completed, judges to end the dependency, but is not limited thereto. The mobile terminal can restore the background process that ends the dependency to the resource restriction level before the reduction, and re-limit the resource usage of the background process.
  • the resource restriction level of the background process having the dependency relationship with the foreground process can be reduced, and the foreground process can be timely responded to prevent the foreground process from entering the wait due to the limitation of the resource usage of the background process, thereby reducing power consumption. At the same time improve the speed of the front desk.
  • a resource management method including the following operations:
  • Operation (1) when detecting that the application enters the background operation, acquires resource usage data when the application runs in the background within a preset time period.
  • Operation (2) acquires the resource type used by the application according to the resource usage data.
  • Operation (3) determines the resource restriction level of the application under the resource category according to the resource usage data.
  • the operation (3) includes: obtaining a proportion that the resource type used by the application is currently not occupied; and when the proportion of the resource type that is not currently occupied is less than a preset threshold, determining, according to the resource usage data, the application is under the resource category. Resource limit level.
  • the application is allocated to the resource group corresponding to the resource restriction level under the resource type, and the resource usage priority corresponding to the resource restriction level is configured.
  • the operation (4) includes: acquiring user group information of the application; querying a process identifier that has a mapping relationship with the user group information; and assigning the background process that matches the process identifier to the resource corresponding to the resource restriction level under the resource type In the group.
  • the foregoing resource management method further includes: acquiring a foreground process running in the foreground; and reducing a resource restriction level of the background process having the dependency when there is a background process having a dependency relationship with the foreground process.
  • the method further includes: when the background process and the foreground process have at least one of a synchronization mechanism and a communication mechanism, the background process that has at least one of a synchronization mechanism and a communication mechanism Determined as a background process with dependencies.
  • the method further includes: determining a waiting lock resource when detecting that the foreground process has a lock waiting behavior; and waiting when there is a background process waiting for the lock resource
  • the background process of the lock resource is determined to be a background process with dependencies.
  • the method further includes: when the current process ends the dependency relationship with the background process, the background process that restores the end dependency is lowering the previous resource restriction level.
  • the resource usage data of the application running in the background in a preset time period may be acquired, and the resource type used by the application and the resource limitation under the resource category are determined according to the resource usage data.
  • the level and the application are allocated to the resource configuration corresponding to the resource restriction level in the resource type to be used, and the resource usage priority corresponding to the resource restriction level is configured, and the background application can dynamically implement different resource limits in different resource types. Optimize system performance and save power.
  • a resource management apparatus 700 including a data acquisition module 710 , a category acquisition module 720 , a level determination module 730 , and a configuration module 740 .
  • the data obtaining module 710 is configured to: when detecting that the application enters the background running, acquire resource usage data when the application runs in the background in a preset time period.
  • the category obtaining module 720 is configured to acquire a resource type used by the application according to the resource usage data.
  • the level determining module 730 is configured to determine, according to the resource usage data, a resource restriction level applied by the resource category.
  • the configuration module 740 is configured to allocate an application to a resource group corresponding to the resource restriction level in the resource category, and configure a resource usage priority corresponding to the resource restriction level.
  • the resource usage data of the application running in the background in a preset time period may be acquired, and the resource type used by the application and the resource limitation under the resource category are determined according to the resource usage data.
  • the level and the application are allocated to the resource configuration corresponding to the resource restriction level in the resource type to be used, and the resource usage priority corresponding to the resource restriction level is configured, and the background application can dynamically implement different resource limits in different resource types. Optimize system performance and save power.
  • the level determination module 730 includes a ratio acquisition unit 732 and a determination unit 734.
  • the ratio obtaining unit 732 is configured to obtain a proportion of resource types currently used by the application that are not currently occupied.
  • the determining unit 734 is configured to determine, according to the resource usage data, a resource restriction level applied to the resource category, if the proportion of the resource type that is not currently occupied is less than a preset threshold.
  • determining the resource restriction level of the application under the resource type according to the resource usage data of the application may be
  • the background application dynamically implements different levels of resource constraints under different resource types, optimizes system performance, and saves power.
  • the configuration module 740 includes an information acquisition unit 742, a query unit 744, and an allocation unit 746.
  • the information obtaining unit 742 is configured to acquire user group information of the application.
  • the query unit 744 is configured to query a process identifier that has a mapping relationship with the user group information.
  • the allocating unit 746 is configured to allocate the background process that matches the process identifier to the resource group corresponding to the resource restriction level under the resource category.
  • the process identifier with the mapping relationship may be found according to the user group information of the application, and the background process matching the process identifier is added to the resource group corresponding to the determined resource restriction level under the used resource category.
  • unified resource usage management can be performed on each process running under the background application according to the resource restriction level, thereby optimizing system performance and saving power consumption.
  • the resource management apparatus 700 includes a data acquisition module 710, a category acquisition module 720, a level determination module 730, and a configuration module 740, and a process acquisition module.
  • a process acquisition module is used to obtain a foreground process running in the foreground.
  • the configuration module 740 is further configured to reduce a resource restriction level of the background process having the dependency when there is a background process having a dependency relationship with the foreground process.
  • the foregoing resource management apparatus 700 further includes a dependency determining module.
  • a dependency determining module configured to determine, when the background process and the foreground process have at least one of a synchronization mechanism and a communication mechanism, a background process having at least one of a synchronization mechanism and a communication mechanism as a background having a dependency relationship process.
  • the dependency determining module is further configured to determine a waiting lock resource when detecting a lock waiting behavior of the foreground process, and wait for the background process of the lock resource to be determined when there is a background process waiting for the lock resource.
  • a background process with dependencies is further configured to determine a waiting lock resource when detecting a lock waiting behavior of the foreground process, and wait for the background process of the lock resource to be determined when there is a background process waiting for the lock resource.
  • the configuration module 740 is further configured to: when the current process ends the dependency relationship with the background process, the background process that restores the end dependency is lowering the previous resource restriction level.
  • the resource restriction level of the background process having the dependency relationship with the foreground process can be reduced, and the foreground process can be timely responded to prevent the foreground process from entering the wait due to the limitation of the resource usage of the background process, and the power consumption is reduced. At the same time improve the speed of the front desk.
  • Each of the above-described resource management 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 mobile terminal, or may be stored in a memory in the mobile terminal in a software format, so that the processor invokes the operations corresponding to the above modules.
  • FIG. 10 is a block diagram showing a partial structure of a mobile phone related to a mobile terminal provided by an embodiment of the present application.
  • the mobile phone includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, and a processor 1080. And power supply 1090 and other components.
  • RF radio frequency
  • the RF circuit 1010 can be used for receiving and transmitting information 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 1080.
  • the uplink data can also be sent to the base station.
  • RF circuits include, but are not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
  • LNA Low Noise Amplifier
  • RF circuit 1010 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 GSM, GPRS, Code Division Multiple Access (CDMA), W-CDMA, Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
  • the memory 1020 can be used to store software programs and modules, and the processor 1080 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 1020.
  • the memory 1020 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.);
  • the data storage area can store data (such as audio data, address book, etc.) created according to the use of the mobile phone.
  • memory 1020 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 1030 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the handset 1000.
  • the input unit 1030 may include a touch panel 1032 and other input devices 1034.
  • the touch panel 1032 which may also be referred to as a touch screen, can collect touch operations on or near the user (such as a user using a finger, a stylus, or the like on the touch panel 1032 or near the touch panel 1032. Operation) and drive the corresponding connection device according to a preset program.
  • the touch panel 1032 can include two portions of a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 1080 is provided and can receive commands from the processor 1080 and execute them.
  • the touch panel 1032 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 1030 can also include other input devices 1034.
  • other input devices 1034 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
  • the display unit 1040 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 1040 can include a display panel 1042.
  • the display panel 1042 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the touch panel 1032 can cover the display panel 1042. When the touch panel 1032 detects a touch operation thereon or nearby, the touch panel 1032 transmits to the processor 1080 to determine the type of the touch event, and then the processor 1080 is The type of touch event provides a corresponding visual output on display panel 1042.
  • the touch panel 1032 and the display panel 1042 are used as two independent components to implement the input and input functions of the mobile phone, in some embodiments, the touch panel 1032 can be integrated with the display panel 1042. Realize the input and output functions of the phone.
  • the handset 1000 can also include at least one type of sensor 1050, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1042 according to the brightness of the ambient light, and the proximity sensor may close the display panel 1042 and/or when the mobile phone moves to the ear. Or backlight.
  • the motion sensor may include an acceleration sensor, and the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
  • the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
  • Audio circuitry 1060, speaker 1062, and microphone 1064 can provide an audio interface between the user and the handset.
  • the audio circuit 1060 can transmit the converted electrical data of the received audio data to the speaker 1062, and convert it into a sound signal output by the speaker 1062.
  • the microphone 1064 converts the collected sound signal into an electrical signal, and the audio circuit 1060. After receiving, it is converted into audio data, and then processed by the audio data output processor 1080, transmitted to another mobile phone via the RF circuit 1010, or outputted to the memory 1020 for subsequent processing.
  • WiFi is a short-range wireless transmission technology.
  • the mobile phone through the WiFi module 1070 can help users to send and receive e-mail, browse the web and access streaming media, etc. It provides users with wireless broadband Internet access.
  • FIG. 10 shows the WiFi module 1070, it can be understood that it does not belong to the essential configuration of the mobile phone 1000 and can be omitted as needed.
  • the processor 1080 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 1020, and invoking data stored in the memory 1020, The phone's various functions and processing data, so that the overall monitoring of the phone.
  • processor 1080 can include one or more processing units.
  • the processor 1080 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 1080.
  • the processor 1080 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem.
  • the mobile phone 1000 also includes a power source 1090 (such as a battery) for powering various components.
  • the power source can be logically coupled to the processor 1080 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • the handset 1000 may also include a camera, a Bluetooth module, and the like.
  • the processor 880 included in the mobile terminal implements the foregoing resource management method when executing a computer program stored in a memory.
  • the mobile terminal can include a memory 1020 and a processor 1080.
  • the memory 1020 stores a computer program that, when executed by the processor 1080, causes the processor to perform the following operations:
  • the application is allocated to the resource group corresponding to the resource restriction level under the resource category, and the resource usage priority corresponding to the resource restriction level is configured.
  • a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the resource management method described above.
  • a computer program product comprising a computer program, when executed on a computer device, causes the computer device to perform the resource management method described above when executed.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or the like.
  • Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM), which acts as an external cache.
  • RAM is available in a variety of formats, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization chain. Synchlink DRAM (SLDRAM), Memory Bus (Rambus) Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Stored Programmes (AREA)

Abstract

一种资源管理方法,包括:当检测到应用进入后台运行时,获取应用在预设时间段内在后台运行时的资源使用数据(310);根据资源使用数据获取应用使用的资源种类(320);根据资源使用数据确定应用在资源种类下的资源限制等级(330);将应用分配到资源种类下与资源限制等级对应的资源组别中,并配置与资源限制等级对应的资源使用优先级(340)。

Description

资源管理方法、移动终端及计算机可读存储介质
本申请要求于2018年01月10日提交中国专利局、申请号为2018100239025、发明名称为“资源管理方法、装置、移动终端及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别是涉及一种资源管理方法、移动终端及计算机可读存储介质。
背景技术
随着互联网的飞速发展,智能移动终端已经成为许多用户最常用的电子设备,例如智能手机、平板电板等。用户可在智能移动终端上安装各式的应用程序进行使用,当应用程序在后台进行运行时,会与前台运行的应用程序抢占CPU(Central Processing Unit,中央处理器)、内存、带宽等系统资源,导致出现前台运行的应用卡顿、系统运行缓慢及移动终端发热等问题。
发明内容
根据本申请的各种实施例提供一种资源管理方法、移动终端及计算机可读存储介质。
一种资源管理方法,包括:
当检测到应用进入后台运行时,获取所述应用在预设时间段内在后台运行时的资源使用数据;
根据所述资源使用数据获取所述应用使用的资源种类;
根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级;及
将所述应用分配到所述资源种类下与所述资源限制等级对应的资源组别中,并配置与所述资源限制等级对应的资源使用优先级。
一种移动终端,包括存储器及处理器,所述存储器中存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器实现如下操作:
当检测到应用进入后台运行时,获取所述应用在预设时间段内在后台运行时的资源使用数据;
根据所述资源使用数据获取所述应用使用的资源种类;
根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级;及
将所述应用分配到所述资源种类下与所述资源限制等级对应的资源组别中,并配置与所述资源限制等级对应的资源使用优先级。
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如下操作:
当检测到应用进入后台运行时,获取所述应用在预设时间段内在后台运行时的资源使用数据;
根据所述资源使用数据获取所述应用使用的资源种类;
根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级;及
将所述应用分配到所述资源种类下与所述资源限制等级对应的资源组别中,并配置与所述资源限制等级对应的资源使用优先级。
本申请实施例提供的资源管理方法、移动终端及计算机可读存储介质,当检测到应用进入后台运行时,可获取该应用在预设时间段内在后台运行时的资源使用数据,根据资源使用数据确定应用使用的资源种类及资源种类下的资源限制等级,并将应用分配到使用的 资源种类下与资源限制等级对应的资源配置中,配置与资源限制等级对应的资源使用优先级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中移动终端的框图。
图2为一个实施例中资源管理方法的系统架构图。
图3为一个实施例中资源管理方法的流程示意图。
图4为一个实施例中确定应用在使用的资源种类下的资源限制等级的流程示意图。
图5为一个实施例中将应用分配到使用的资源种类下与资源限制等级对应的资源组别的流程示意图。
图6为一个实施例中降低与前台进程具备依赖关系的后台进程的资源限制等级的流程示意图。
图7为一个实施例中资源管理装置的框图。
图8为一个实施例中等级确定模块的框图。
图9为一个实施例中配置模块的框图。
图10为另一个实施例中移动终端的框图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
图1为一个实施例中移动终端的框图。如图1所示,该移动终端包括通过系统总线连接的处理器、存储器、显示屏和输入装置。其中,存储器可包括非易失性存储介质及处理器。移动终端的非易失性存储介质存储有操作系统及计算机程序,该计算机程序被处理器执行时以实现本申请实施例中提供的一种资源管理方法。该处理器用于提供计算和控制能力,支撑整个移动终端的运行。移动终端中的内存储器为非易失性存储介质中的计算机程序的运行提供环境。移动终端的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层,也可以是移动终端外壳上设置的按键、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该移动终端可以是手机、平板电脑或者个人数字助理或穿戴式设备等。本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的移动终端的限定,具体的移动终端可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
图2为一个实施例中资源管理方法的系统架构图。如图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资源之外,进一步对相关进程所占用的内存资源进行回收,回收的内存可供其它进程使用。可选地,本地框架层220还可包括接口模块,该接口模块包含开发给上层的binder接口,上层的框架或者应用通过提供的binder接口来发送资源限制或者冻结的指令给资源优先级和限制管理器222和平台冻结管理器224。
内核空间层230中可包括UID管理模块231、Cgroup模块233、Binder管控模块235、进程内存回收模块237以及冻结超时退出模块239。其中,UID管理模块231用于实现基于应用的用户身份标识(User Identifier,UID)来管理第三方应用的资源或进行冻结。相比较于基于进程身份标识(Process Identifier,PID)来进行进程管控,通过UID更便于统一管理一个用户的应用的资源。Cgroup模块233用于提供一套完善的CPU、CPUSET、内存(memory)、输入/输出(input/output,I/O)和Net相关的资源限制机制。Binder管控模块235用于实现后台binder通信的优先级的控制。进程内存回收模块237用于实现进程深度冻结模式,这样能当某个第三方应用长期处于冻结状态的时候,会主要释放掉进程的文件区,从而达到节省内存的模块,也加快该应用在下次启动时的速度。冻结超时退出模块239可用于解决出现冻结超时场景产生的异常。通过上述的系统架构,可实现本申请各个实施例中的资源管理方法。
如图3所示,在一个实施例中,提供一种资源管理方法,包括以下操作:
操作310,当检测到应用进入后台运行时,获取应用在预设时间段内在后台运行时的资源使用数据。
移动终端上可同时运行有一个或多个应用程序,可包括在前台运行的前台应用及在后台运行的后台应用。移动终端可对运行的各个应用程序进行监听,并检测是否有应用进入后台运行。应用进入后台运行可以是应用从前台运行切换至后台运行,也可以是应用启动后直接进入后台运行等。
在一个实施例中,移动终端可通过活动管理器对运行的各个应用程序进行监听,监听各个应用程序的运行状态变化。可选地,应用程序的运行状态可包括但不限于启动、前台运行、后台运行、退出等。移动终端可每隔一段时间通过活动管理器的RunningAppProcessInfo类获取正在运行的所有应用程序列表,例如,每隔2秒获取一次正在运行的所有应用程序列表,并逐一判断应用程序列表中各个正在运行的应用程序的运行状态是前台运行还是后台运行。当移动终端检测到应用在本次获取的应用程序列表中为后台运行,在上一次获取的应用程序列表中不是后台运行时,则可确定该应用为进入后台运行的应用。
可选地,移动终端还可监听每个activity(活动)的生命周期,并根据每个activity的生命周期获取正在运行的各个应用程序的运行状态。移动终端可建立全局计数器,统计每个activity对onStart及onStop两个方法的调用,当应用程序调用一次onStart时,全局计数器加1,当应用程序调用一次onStop时,全局计数器减1。当应用程序的全局计数器大于0时,可说明应用程序在前台运行,当应用程序的全局计数器等于0时,可说明 应用程序在后台运行。当移动终端检测到应用的全局计数器从1变为0时,则可确定该应用进入后台运行,或是移动终端检测到创建了新的activity,且该新的activity对应的应用的全局计数器为0时,则可确定该应用进入后台运行等。可以理解地,移动终端检测应用进入后台运行也可采用其他方法,并不仅限于上述方式。
移动终端检测到应用进入后台运行时,可获取该获取在预设时间段内在后台运行时的资源使用数据。预设时间段可根据实际需求进行设定,比如3天、一周等。资源使用数据可包括该应用在预设时间段内每次在后台运行时占用的资源种类及占用比例等,其中,资源种类可包括但不限于CPU、I/O、内存及网络资源等。
操作320,根据资源使用数据获取应用使用的资源种类。
移动终端可根据进入后台运行的应用的资源使用数据获取该应用使用的资源种类,应用使用的资源种类可以是资源使用数据中包含的资源种类。例如,应用在预设时间段内总共在后台运行2次,第一次在后台运行时占用CPU20%、内存10%,第二次在后台运行时占用CPU10%、内存10%、网络30%,则移动终端可获取该应用使用的资源种类可包括CPU、内存及网络资源。
应用使用的资源种类也可以是资源使用数据中占用比例大于预设值的资源种类等,不同资源种类可设定不同的预设值。可选地,移动终端可对应用在预设时间段内每次在后台运行时占用的资源种类及占用比例进行统计,并可计算该应用在预设时间段内在后台运行时在不同资源种类的平均占用比例。移动终端可将应用在资源种类的平均占用比例与该资源种类对应的预设值进行比较,并判断平均占用比例是否大于该对应的预设值。例如,应用在预设时间段内总共在后台运行3次,第一次在后台运行时占用CPU20%、内存10%,第二次在后台运行时占用CPU10%、内存10%,第三次在后台运行时占用CPU25%、内存20%,则移动终端可计算该应用在CPU资源的平均占用比例为18.3%,内存资源的平均占用比例为13.3%,CPU资源的平均占用比例大于预设值8%,内存资源的平均占用比例大于预设值10%,则移动终端可确定该应用使用的资源种类包括CPU及内存资源。
操作330,根据资源使用数据确定应用在资源种类下的资源限制等级。
可选地,移动终端可根据实际需求设定不同的资源限制等级,资源限制等级可用于表示应用使用资源被限制的程度,资源限制等级越高,受限制的程度可越大。受限制的资源可包括但不限于CPU资源、内存资源、I/O资源、网络资源等。移动终端获取进入后台运行的应用使用的资源种类后,可根据资源使用数据中该应用使用的各个资源种类的占用比例确定应用在使用的各个资源种类下的资源限制等级。
在一个实施例中,移动终端设定的资源限制等级可包括无限制级别、普通限制级别、深度限制级别及冻结级别等。无限制级别可指的是应用使用的资源不受限制。普通限制级别可指的是应用可使用较少的资源,比如最多仅可使用50%的资源等,但不限于此。深度限制级别可指的是应用可使用极少的资源,比如最多仅可使用20%的资源等,但不限于此。冻结级别指的是应用无法使用任何的资源,停止应用的一切行为。可选地,不同种类的资源均可包含上述设定的几种资源限制等级,移动终端可分别针对不同种类的资源设定进入后台运行的应用的资源限制等级。可选地,不同种类的资源均可包含上述设定的几种资源限制等级,移动终端可分别根据应用的资源使用数据中在不同资源种类的占用比例确定用应在使用的各个资源种类的资源限制等级。资源限制等级也可按照其他方式进行划分,并不仅限于此,不同资源种类也可划分不同的资源限制等级。
可选地,资源种类下不同的资源限制等级可对应不同的占用比例区间。例如,网络资源的无限制级别对应的区间可以是应用占用的网络资源比例小于10%,普通限制级别对应的区间可以是应用占用的网络资源比例在10%~30%之间,深度限制级别对应的区间可以是应用占用的网络资源比例在30%~70%之间,冻结级别对应的区间可以是应用占用的网络资源比例大于70%等。CPU资源的无限制级别对应的区间可以是应用占用的CPU资源比例小 于5%,普通限制级别对应的区间可以是应用占用的CPU资源比例在5%~15%之间,深度限制级别对应的区间可以是应用占用的CPU资源比例在15%~30%之间,深度限制级别对应的区间可以是应用占用的CPU资源比例大于30%等,但不限于此。可选地,移动终端获取进入后台运行的应用在预设时间段内的资源使用数据后,可根据资源使用数据获取该应用在使用的各个资源种类的占用比例区间,从而确定应用在使用的各个资源种类的资源限制等级。比如,移动终端可计算应用在各个资源种类的平均占用比例,并获取平均占用比例所属的占用比例区间,从而确定应用在使用的各个资源种类的资源限制等级。
操作340,将应用分配到资源种类下与资源限制等级对应的资源组别中,并配置与资源限制等级对应的资源使用优先级。
移动终端确定进入后台运行的应用在使用的资源种类的资源限制等级后,可将该应用发配到该使用的资源种类下与资源限制等级对应的资源组别中,并配置与确定的资源限制等级对应的资源使用优先级。资源限制等级越高,限制资源使用的程度越强,可对应较低的资源使用优先级。资源限制等级越低,限制资源使用的程度越弱,可对应较高的资源使用优先级。
可选地,移动终端可基于内核Cgroup(control group)机制划分不同的资源组别,并可采用文件节点写配置的方式设置各个资源组别的资源使用优先级,对被分配到各个资源组别中的应用使用资源的时间或比例等进行管理,其中,Cgroup是内核中提供的一种可以限制、记录、隔离进程所使用的物理资源(比如:CPU、内存、I/O、网络等资源)的机制。针对不同种类的资源,移动终端可划分不同的资源组别。移动终端可加载Cgroup的配置文件,配置文件中可记录有划分的资源组别、各个资源组别的资源使用优先级及与资源使用优先级对应的资源调度策略。资源调度策略可包括但不限于被分配到资源组别中的进程使用资源的时间、占用资源比例、使用的资源标识等。例如,可配置网络资源下的普通限制级别对应的资源组别的应用最大可占用20%的网络资源,可配置CPU资源下的普通限制级别对应的资源组别的应用在1分钟内可使用30秒的CPU资源等,但不限于此。当需要添加新的资源组别,或是修改资源组别的资源使用优先级及资源调度策略,移动终端可通过修改Cgroup的配置文件来实现。
移动终端将进入后台运行的应用分配到使用的资源种类下与确定的资源限制等级对应的资源组别中,并配置与确定的资源限制等级对应的资源使用优先级,该应用可按照该资源组别对应的资源调度策略使用该资源种类。可选地,当该应用使用的资源种类有多个时,移动终端可根据资源使用数据逐一确定该应用在各个使用的资源种类的资源限制等级,并将该应用分别分配到各个使用的资源种类下与资源限制等级对应的资源组别中。例如,移动终端获取进入后台运行的应用使用的资源种类包括CPU资源及网络资源,并根据资源使用数据确定该应用在CPU资源的资源限制等级为深度限制级别,在网络资源的资源限制等级为普通限制级别。移动终端可将该应用分别分配到CPU资源下与深度限制级别对应的资源组别,以及网络资源下与普通限制级别对应的资源组别中。
在本实施例中,当检测到应用进入后台运行时,可获取该应用在预设时间段内在后台运行时的资源使用数据,根据资源使用数据确定应用使用的资源种类及资源种类下的资源限制等级,并将应用分配到使用的资源种类下与资源限制等级对应的资源配置中,配置与资源限制等级对应的资源使用优先级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
如图4所示,在一个实施例中,操作330根据资源使用数据确定应用在资源种类下的资源限制等级,包括以下操作:
操作402,获取应用使用的资源种类当前未被占用的比例。
移动终端检测到应用进入后台运行,获取该应用在预设时间段内在后台运行时的资源使用数据,并根据资源使用数据获取该应用使用的资源种类。移动终端可以获取该应用使 用的各个资源种类当前未被占用的比例,具体地,可以先获取应用使用的各个资源种类当前的占用比例,并根据占用比例计算未被占用的比例。
在一个实施例中,移动终端可将各个资源种类的活动数据记录在预设文件中,可选的,不同资源种类的活动数据可记录在不同的预设文件中。资源种类的活动数据可指的是对应资源种类被占用向移动终端的操作系统或应用程序等提供运行能力时产生的数据。例如,CPU资源对应的预设文件中可记录有CPU从移动终端启动至当前时刻的累计工作时间,以及各个不同的进程或应用等从移动终端启动至当前时刻使用CPU的累计时间等;内存资源对应的预设文件中可记录有在不同时刻内存被占用的大小,以及各个不同的进程或应用等占用的内存大小等,但不限于此。
可选地,移动终端可从预设文件中读取进入后台运行的应用使用的各个资源种类的活动数据,并根据活动数据计算该应用使用的各个资源种类当前未被占用的比例。例如,移动终端可按照预设的采集周期从/proc目录下的/proc/stat文件中读取CPU从移动终端启动至当前时刻的累计工作时间。移动终端可记录每一次读取的CPU的累计工作时间,并计算本次记录的CPU的累计工作时间与上一次记录的CPU的累计工作时间之间的差值,得到采集周期内CPU的真正工作时间。移动终端可确定采集周期内CPU的真正工作时间与采集周期的比值,该比值即为CPU的总占用率等,可根据CPU的总占用率得到CPU的空闲率,CPU的空间率即为CPU未被占用的比例。移动终端也可每隔一定时间段从与内存对应的预设文件中读取内存当前被占用的大小,并根据内存当前被占用的大小确定当前内存的占用比例,从而得到内存当前未被占用的比例。
操作404,当资源种类当前未被占用的比例小于预设阈值时,则根据资源使用数据确定应用在资源种类下的资源限制等级。
移动终端可将进入后台运行的应用使用的各个资源种类当前未被占用的比例与预设阈值进行比较,当资源种类当前未被占用的比例小于预设阈值时,可说明该资源种类处于繁忙状态,移动终端可对后台运行的应用在该资源种类的使用进行限制。移动终端可根据进入后台运行的应用在该资源种类的占用比例确定在该资源种类下的资源限制等级。当资源种类当前未被占用的比例大于或等于预设阈值时,可说明该资源种类处于较空闲的状态,可不对后台运行的应用进行资源使用限制。可选地,预设阈值可根据实际需求进行设定,不同资源种类可对应不同的预设阈值,例如,CPU资源对应的预设阈值可以是40%,网络资源对应的预设阈值可以是30%等,但不限于此。
在一个实施例中,当资源种类当前未被占用的比例大于或等于预设阈值时,移动终端可检测是否有前台应用在运行,当有前台应用在运行时,则可根据进入后台运行的应用的资源使用数据确定该应用在该资源种类下的资源限制等级。可以最大限度地保证前台应用的资源使用,减少出现后台应用与前台应用抢占资源导致卡顿等情况。
在本实施例中,当进入后台运行的应用使用的资源种类当前未被占用的比例小于预设阈值,则根据该应用的资源使用数据确定该应用在该资源种类下的资源限制等级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
如图5所示,在一个实施例中,操作将应用分配到资源种类下与资源限制等级对应的资源组别中,包括以下操作:
操作502,获取应用的用户组信息。
进程是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础。移动终端上通常可运行有多个进程,不同的进程可用于分别执行不同的任务。应用程序进行运行时,移动终端可为运行的应用程序分配不同的用户组,可通过用户组管理应用程序的权限等。移动终端将进入后台运行的应用分配到使用的资源种类下与确定的资源限制等级对应的资源组别,可获取该应用的应用标识,并根据应用标识获取该应用的用户组信息。其中,应用标识可以由数字、字母及符号等中 的一种或多种组成。用户组信息可包括用户组标识等,其中,用户组标识可以由数字、字母及符号等中的一种或多种组成。
操作504,查询与用户组信息具备映射关系的进程标识。
移动终端可根据进入后台运行的应用的用户组信息查询与用户组信息具备映射关系的进程标识,从而得到该应用下运行的各个进程。移动终端的内核空间层可实时对进程所属的用户组信息进行收集,当进程创建或销毁时,内核可对进程所属的用户组信息进行分配及释放等,进程在运行的过程中,也可以发生用户组信息改变的情况。内核空间层实时对各个进程所属的用户组信息进行收集,并可建立进程标识、进程名称等进程信息与用户组信息的映射关系。当移动终端需要将应用分配到与资源种类下与确定的资源限制等级对应的资源组别时,可根据该应用的用户组信息直接查询具备映射关系的进程标识,相比起遍历所有运行的进程从而找到应用下运行的进程,直接查找与用户组信息具备映射关系的进程标识更加方便快捷。
操作506,将与进程标识匹配的后台进程分配到资源种类下与资源限制等级对应的资源组别中。
移动终端根据进入后台运行的应用的用户组信息查询到具备映射关系的进程标识后,可根据进程标识获取该应用下运行的所有进程。移动终端可将该应用下运行的所有进程分配到与使用的资源种类下与确定的资源限制等级对应的资源组别中,并对该应用下运行的所有进程配置与确定的资源限制等级对应的资源使用优先级,从而可实现配置该应用为与确定的资源限制等级对应的资源使用优先级的目的。
在本实施例中,可根据应用的用户组信息查找到具有映射关系的进程标识,并将与进程标识匹配的后台进程添加到与使用的资源种类下与确定的资源限制等级对应的资源组别中,可按照资源限制等级对后台应用下运行的各个进程进行统一的资源使用管理,优化系统性能,节省功耗。
如图6所示,在一个实施例中,上述资源管理方法,还包括以下操作:
操作602,获取在前台运行的前台进程。
当有前台应用运行时,移动终端可获取在前台运行的前台进程,可选地,移动终端可通过活动管理器的RunningAppProcessInfo类获取正在运行的所有进程列表,并从进程列表中获取运行状态为前台运行的进程,即可确定该运行状态为前台运行的进程为前台进程。
操作604,当存在与前台进程具备依赖关系的后台进程时,降低具备依赖关系的后台进程的资源限制等级。
移动终端获取在前台运行的前台进程后,可检测是否存在与前台进程具备依赖关系的后台进程,具备依赖关系指的是一个进程需要等待另一个进程的消息才可正常执行,则两个进程间存在依赖关系。可选地,移动终端可预先记录具备有依赖关系的进程标识,可获取前台进程的进程标识,并根据该前台进程的进程标识获取与前台进程具备依赖关系的进程标识。移动终端可根据与前台进程具备依赖关系的进程标识逐一对后台运行的各个进程进行检测,确定是否存在与前台进程具备依赖关系的后台进程。
移动终端可降低与前台进程具备依赖关系的后台进程的资源限制等级,提高该具备依赖关系的后台进程的资源使用优先级。可选地,移动终端可将与前台进程具备依赖关系的后台进程的资源限制等级调整为与前台进程相同的资源限制等配,可将具备依赖关系的后台进程分配至与前台进程相同的资源组别中,并配置与前台进程相同的资源使用优先级。提高与前台运行的进程具备依赖关系的后台进程的资源使用优先级,可加快与前台运行的进程具备依赖关系的后台进程的任务执行,从而减少前台运行的进程的等待时间,加快前台进程的运行。
在一个实施例中,移动终端可检测是否存在与前台进程存在交互通信的后台进程,可 将与前台进程存在交互通信的后台进程确定为与前台进程具备依赖关系的后台进程。可选地,进程间的交互通信可包括同步机制和/或通信机制等,其中,同步机制可指的是两个进程相互协调共同完成任务,通信机制指的是在不同的进程之间进行传播或交换信息。
在一个实施例中,移动终端可检测是否存在与前台进程具有通信机制的后台进程,并可将与前台进程具有通信机制的后台进程确定为具备依赖关系的后台进程。通信机制可包括socket、binder、共享内存等,其中,网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket;binder是一种进程间通信机制,提供远程过程调用功能;共享内存就是允许两个不相关的进程访问同一个逻辑内存,共享内存是在两个正在运行的进程之间共享和传递数据的一种非常有效的方式,不同进程之间共享的内存通常安排为同一段物理内存。可选地,移动终端可检测是否存在与前台运行的进程具有socket和/或binder通信的后台进程,并可将与前台运行的进程具有socket和/或binder通信的后台进程确定为具备依赖关系的后台进程。移动终端也可以检测是否存在与前台运行的进程进行内存共享的后台进程,并可将与前台运行的进程进行内存共享的后台进程确定为具备依赖关系的后台进程。在一个实施例中,移动终端可在binder驱动中添加检测机制,并根据binder驱动中添加的检测机制检测是否存在与前台进程具有通信机制的后台进程。
在一个实施例中,移动终端可检测是否存在与前台进程具有同步机制的后台进程,并可将与前台进程具有同步机制的后台进程确定为具备依赖关系的后台进程。同步机制可包括信号量、互斥锁等,其中,信号量(semaphore)的数据结构为一个值和一个指针,指针指向等待该信号量的下一个进程,互斥锁可用于保证共享数据的完整性,任意时刻只有一个进程可访问上具备有互斥锁的对象。可选地,移动终端可通过futex(fast userspace mutex,快速用户空间互斥体)系统的调用检测是否存在与前台进程具有同步机制的后台进程。futex系统的调用可用于实现进程间的同步机制,在用户空间中进行操作,是一种用户态(user mode)和内核态混合机制,其中,用户态指的是非特权状态。
在一个实施例中,当移动终端检测到前台进程发生锁等待行为时,可确定前台进程等待的锁资源。锁资源可包括线程锁、文件句柄、信号等,其中,文件句柄指的是从文件读取数据时,操作系统函数取回的顺序号,从而能够打开文件,文件句柄对于打开的文件是唯一的识别依据。移动终端可遍历所有在后台运行的进程,并检测是否存在等待在与前台进程同一锁资源的后台进程,可将与前台进程等待在同一锁资源的后台进程确定为具有依赖关系的后台进程。
在一个实施例中,移动终端可检测与前台进程具备依赖关系的后台进程,是否结束该依赖关系。比如,移动终端可检测后台进程是否结束与前台运行的进程的socket和/或binder通信,当结束通信时,则判定结束依赖关系。移动终端也可以检测与前台运行的进程等待在同一锁资源的后台进程是否完成任务,当任务完成时,则判断结束依赖关系,但不限于此。移动终端可以将结束依赖关系的后台进程恢复到降低之前的资源限制等级,重新对后台进程的资源使用进行限制。
在本实施例中,可以降低与前台进程具备依赖关系的后台进程的资源限制等级,保证前台进程能够及时得到响应,防止因后台进程的资源使用受到限制而使前台进程进入等待,在降低功耗的同时提高前台的运行速度。
在一个实施例中,提供一种资源管理方法,包括以下操作:
操作(1),当检测到应用进入后台运行时,获取应用在预设时间段内在后台运行时的资源使用数据。
操作(2),根据资源使用数据获取应用使用的资源种类。
操作(3),根据资源使用数据确定应用在资源种类下的资源限制等级。
可选地,操作(3),包括:获取应用使用的资源种类当前未被占用的比例;当资源种 类当前未被占用的比例小于预设阈值时,则根据资源使用数据确定应用在资源种类下的资源限制等级。
操作(4),将应用分配到资源种类下与资源限制等级对应的资源组别中,并配置与资源限制等级对应的资源使用优先级。
可选地,操作(4),包括:获取应用的用户组信息;查询与用户组信息具备映射关系的进程标识;将与进程标识匹配的后台进程分配到资源种类下与资源限制等级对应的资源组别中。
可选地,上述资源管理方法,还包括:获取在前台运行的前台进程;当存在与前台进程具备依赖关系的后台进程时,降低具备依赖关系的后台进程的资源限制等级。
可选地,在获取在前台运行的前台进程之后,还包括:当后台进程与前台进程具备同步机制和通信机制中至少一种时,将具备同步机制和通信机制中的至少一种的后台进程确定为具备依赖关系的后台进程。
可选地,在获取在前台运行的前台进程之后,还包括:当检测到前台进程发生锁等待行为时,确定等待的锁资源;当存在等待在所述锁资源的后台进程时,则将等待在所述锁资源的后台进程确定为具备依赖关系的后台进程。
可选地,在降低所述具备依赖关系的后台进程的资源限制等级之后,还包括:当前台进程结束与后台进程的依赖关系时,恢复结束依赖关系的后台进程在降低之前的资源限制等级。
在本实施例中,当检测到应用进入后台运行时,可获取该应用在预设时间段内在后台运行时的资源使用数据,根据资源使用数据确定应用使用的资源种类及资源种类下的资源限制等级,并将应用分配到使用的资源种类下与资源限制等级对应的资源配置中,配置与资源限制等级对应的资源使用优先级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
应该理解的是,上述的流程示意图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,上述的流程示意图中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。
如图7所示,在一个实施例中,提供一种资源管理装置700,包括数据获取模块710、种类获取模块720、等级确定模块730及配置模块740。
数据获取模块710,用于当检测到应用进入后台运行时,获取应用在预设时间段内在后台运行时的资源使用数据。
种类获取模块720,用于根据资源使用数据获取应用使用的资源种类。
等级确定模块730,用于根据资源使用数据确定应用在所述资源种类下的资源限制等级。
配置模块740,用于将应用分配到所述资源种类下与资源限制等级对应的资源组别中,并配置与资源限制等级对应的资源使用优先级。
在本实施例中,当检测到应用进入后台运行时,可获取该应用在预设时间段内在后台运行时的资源使用数据,根据资源使用数据确定应用使用的资源种类及资源种类下的资源限制等级,并将应用分配到使用的资源种类下与资源限制等级对应的资源配置中,配置与资源限制等级对应的资源使用优先级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
如图8所示,在一个实施例中,等级确定模块730,包括比例获取单元732及确定单元734。
比例获取单元732,用于获取应用使用的资源种类当前未被占用的比例。
确定单元734,用于若资源种类当前未被占用的比例小于预设阈值,则根据资源使用数据确定应用在所述资源种类下的资源限制等级。
在本实施例中,当进入后台运行的应用使用的资源种类当前未被占用的比例小于预设阈值,则根据该应用的资源使用数据确定该应用在该资源种类下的资源限制等级,可以对后台应用动态实现在不同资源种类下不同等级的资源限制,优化系统性能,节省功耗。
如图9所示,在一个实施例中,配置模块740,包括信息获取单元742、查询单元744及分配单元746。
信息获取单元742,用于获取应用的用户组信息。
查询单元744,用于查询与用户组信息具备映射关系的进程标识。
分配单元746,用于将与进程标识匹配的后台进程分配到资源种类下与资源限制等级对应的资源组别中。
在本实施例中,可根据应用的用户组信息查找到具有映射关系的进程标识,并将与进程标识匹配的后台进程添加到与使用的资源种类下与确定的资源限制等级对应的资源组别中,可按照资源限制等级对后台应用下运行的各个进程进行统一的资源使用管理,优化系统性能,节省功耗。
在一个实施例中,上述资源管理装置700,除了包括数据获取模块710、种类获取模块720、等级确定模块730及配置模块740,还包括进程获取模块。
进程获取模块,用于获取在前台运行的前台进程。
配置模块740,还用于当存在与前台进程具备依赖关系的后台进程时,降低具备依赖关系的后台进程的资源限制等级。
可选地,上述资源管理装置700,还包括依赖关系确定模块。
依赖关系确定模块,用于当后台进程与所述前台进程具备同步机制和通信机制中的至少一种时,将具备同步机制和通信机制中的至少一种的后台进程确定为具备依赖关系的后台进程。
可选地,依赖关系确定模块,还用于当检测到前台进程发生锁等待行为时,确定等待的锁资源,当存在等待在锁资源的后台进程时,则将等待在锁资源的后台进程确定为具备依赖关系的后台进程。
可选地,配置模块740,还用于当前台进程结束与后台进程的依赖关系时,恢复结束依赖关系的后台进程在降低之前的资源限制等级。
在本实施例中,可降低与前台进程具备依赖关系的后台进程的资源限制等级,保证前台进程能够及时得到响应,防止因后台进程的资源使用受到限制而使前台进程进入等待,在降低功耗的同时提高前台的运行速度。
上述资源管理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于移动终端中的处理器中,也可以以软件形式存储于移动终端中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
图10为与本申请实施例提供的移动终端相关的手机的部分结构的框图。参考图10,手机包括:射频(Radio Frequency,RF)电路1010、存储器1020、输入单元1030、显示单元1040、传感器1050、音频电路1060、无线保真(wireless fidelity,WiFi)模块1070、处理器1080、以及电源1090等部件。本领域技术人员可以理解,图10所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
其中,RF电路1010可用于收发信息或通话过程中,信号的接收和发送,可将基站的 下行信息接收后,给处理器1080处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路1010还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于GSM、GPRS、码分多址(Code Division Multiple Access,CDMA)、W-CDMA、长期演进(Long Term Evolution,LTE)、电子邮件、短消息服务(Short Messaging Service,SMS)等。
存储器1020可用于存储软件程序以及模块,处理器1080通过运行存储在存储器1020的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器1020可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器1020可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元1030可用于接收输入的数字或字符信息,以及产生与手机1000的用户设置以及功能控制有关的键信号输入。具体地,输入单元1030可包括触控面板1032以及其他输入设备1034。触控面板1032,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板1032上或在触控面板1032附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板1032可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器1080,并能接收处理器1080发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板1032。除了触控面板1032,输入单元1030还可以包括其他输入设备1034。具体地,其他输入设备1034可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。
显示单元1040可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元1040可包括显示面板1042。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板1042。在一个实施例中,触控面板1032可覆盖显示面板1042,当触控面板1032检测到在其上或附近的触摸操作后,传送给处理器1080以确定触摸事件的类型,随后处理器1080根据触摸事件的类型在显示面板1042上提供相应的视觉输出。虽然在图10中,触控面板1032与显示面板1042是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板1032与显示面板1042集成而实现手机的输入和输出功能。
手机1000还可包括至少一种传感器1050,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板1042的亮度,接近传感器可在手机移动到耳边时,关闭显示面板1042和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器。
音频电路1060、扬声器1062和传声器1064可提供用户与手机之间的音频接口。音频电路1060可将接收到的音频数据转换后的电信号,传输到扬声器1062,由扬声器1062转换为声音信号输出;另一方面,传声器1064将收集的声音信号转换为电信号,由音频电路1060接收后转换为音频数据,再将音频数据输出处理器1080处理后,经RF电路 1010可以发送给另一手机,或者将音频数据输出至存储器1020以便后续处理。
WiFi属于短距离无线传输技术,手机通过WiFi模块1070可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图10示出了WiFi模块1070,但是可以理解的是,其并不属于手机1000的必须构成,可以根据需要而省略。
处理器1080是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器1020内的软件程序和/或模块,以及调用存储在存储器1020内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器1080可包括一个或多个处理单元。在一个实施例中,处理器1080可集成应用处理器和调制解调器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调器主要处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器1080中。比如,该处理器1080可集成应用处理器和基带处理器,基带处理器与和其它外围芯片等可组成调制解调器。手机1000还包括给各个部件供电的电源1090(比如电池),优选的,电源可以通过电源管理系统与处理器1080逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
在一个实施例中,手机1000还可以包括摄像头、蓝牙模块等。
在本申请实施例中,该移动终端所包括的处理器880执行存储在存储器上的计算机程序时实现上述的资源管理方法。
在一个实施例中,该移动终端可包括存储器1020及处理器1080,存储器1020中存储有计算机程序,该计算机程序被处理器1080执行时,使得处理器执行如下操作:
当检测到应用进入后台运行时,获取应用在预设时间段内在后台运行时的资源使用数据;
根据资源使用数据获取应用使用的资源种类;
根据资源使用数据确定应用在资源种类下的资源限制等级;
将应用分配到所述资源种类下与资源限制等级对应的资源组别中,并配置与资源限制等级对应的资源使用优先级。
在一个实施例中,提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述的资源管理方法。
在一个实施例中,提供一种包含计算机程序的计算机程序产品,当其在计算机设备上运行时,使得计算机设备执行时实现上述的资源管理方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等。
如此处所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。合适的非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)。
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛 盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (11)

  1. 一种资源管理方法,包括:
    当检测到应用进入后台运行时,获取所述应用在预设时间段内在后台运行时的资源使用数据;
    根据所述资源使用数据获取所述应用使用的资源种类;
    根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级;及
    将所述应用分配到所述资源种类下与所述资源限制等级对应的资源组别中,并配置与所述资源限制等级对应的资源使用优先级。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级,包括:
    获取所述应用使用的资源种类当前未被占用的比例;及
    当所述资源种类当前未被占用的比例小于预设阈值时,则根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级。
  3. 根据权利要求2所述的方法,其特征在于,所述获取所述应用使用的资源种类当前未被占用的比例,包括:
    从预设文件中读取所述应用使用的资源种类的活动数据,其中,所述预设文件记录了各个所述资源种类的活动数据;及
    根据所述应用使用的资源种类的活动数据计算所述应用使用的资源种类当前未被占用的比例。
  4. 根据权利要求2所述的方法,其特征在于,还包括:
    当所述资源种类当前未被占用的比例大于或等于预设阈值时,检测是否有前台应用在运行;及
    当有前台应用在运行时,则根据所述资源使用数据确定所述应用在所述资源种类下的资源限制等级。
  5. 根据权利要求1所述的方法,其特征在于,所述将所述应用分配到所述资源种类下与所述资源限制等级对应的资源组别中,包括:
    获取所述应用的用户组信息;
    查询与所述用户组信息具备映射关系的进程标识;及
    将与所述进程标识匹配的后台进程分配到所述资源种类下与所述资源限制等级对应的资源组别中。
  6. 根据权利要求5所述的方法,其特征在于,还包括:
    获取在前台运行的前台进程;及
    当存在与所述前台进程具备依赖关系的后台进程时,降低所述具备依赖关系的后台进程的资源限制等级。
  7. 根据权利要求6所述的方法,其特征在于,在所述获取在前台运行的前台进程之后,还包括:
    当后台进程与所述前台进程具备同步机制和通信机制中的至少一种时,将具备同步机制和通信机制中的至少一种的后台进程确定为具备依赖关系的后台进程。
  8. 根据权利要求6所述的方法,其特征在于,在所述获取在前台运行的前台进程之后,还包括:
    当检测到所述前台进程发生锁等待行为时,确定等待的锁资源;及
    当存在等待在所述锁资源的后台进程时,则将所述等待在所述锁资源的后台进程确定为具备依赖关系的后台进程。
  9. 根据权利要求6至8任一所述的方法,其特征在于,在所述降低所述具备依赖关系的后台进程的资源限制等级之后,还包括:
    当所述前台进程结束与所述后台进程的依赖关系时,恢复结束依赖关系的后台进程在降低之前的资源限制等级。
  10. 一种移动终端,包括存储器及处理器,所述存储器中存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器实现如权利要求1至9任一所述的方法。
  11. 一个或多个包含计算机程序的计算机可读存储介质,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至9任一所述的方法。
PCT/CN2018/122086 2018-01-10 2018-12-19 资源管理方法、移动终端及计算机可读存储介质 WO2019137173A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810023902.5 2018-01-10
CN201810023902.5A CN110018903A (zh) 2018-01-10 2018-01-10 资源管理方法、装置、移动终端及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2019137173A1 true WO2019137173A1 (zh) 2019-07-18

Family

ID=67188104

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/122086 WO2019137173A1 (zh) 2018-01-10 2018-12-19 资源管理方法、移动终端及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN110018903A (zh)
WO (1) WO2019137173A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527445A (zh) * 2019-09-18 2021-03-19 北京国双科技有限公司 任务调度方法、装置、设备及存储介质
CN116567132A (zh) * 2022-01-28 2023-08-08 荣耀终端有限公司 一种功耗控制方法及装置
CN117271252A (zh) * 2022-06-15 2023-12-22 中兴通讯股份有限公司 应用的运行状态调节方法、终端及存储介质
CN117349006A (zh) * 2023-09-14 2024-01-05 荣耀终端有限公司 Cpu资源管理方法及相关装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645955A (zh) * 2013-12-16 2014-03-19 百度在线网络技术(北京)有限公司 应用程序的运行管理方法和装置
CN104268022A (zh) * 2014-09-23 2015-01-07 浪潮(北京)电子信息产业有限公司 一种操作系统中进程的资源分配方法及系统
CN105912397A (zh) * 2016-03-31 2016-08-31 乐视控股(北京)有限公司 一种资源管理方法和装置
CN106681475A (zh) * 2016-12-12 2017-05-17 北京珠穆朗玛移动通信有限公司 降低移动终端功耗的方法及移动终端
CN107291557A (zh) * 2017-08-02 2017-10-24 中国银行股份有限公司 一种业务处理方法和装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102083316B1 (ko) * 2013-04-24 2020-04-14 삼성전자주식회사 사용자 디바이스의 메모리 관리 방법 및 장치
US9503599B2 (en) * 2014-04-08 2016-11-22 Canon Information And Imaging Solutions, Inc. Apparatus, system and method for managing background processing on an image processing device
CN106792165A (zh) * 2016-12-02 2017-05-31 武汉斗鱼网络科技有限公司 一种资源动态调整方法及装置
CN107391241A (zh) * 2017-06-22 2017-11-24 努比亚技术有限公司 应用快速启动方法、终端及计算机可读存储介质
CN107436801A (zh) * 2017-06-23 2017-12-05 努比亚技术有限公司 I/o资源调度方法、终端和计算机可读存储介质
CN107544842B (zh) * 2017-08-25 2019-02-05 Oppo广东移动通信有限公司 应用程序处理方法和装置、计算机设备、存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645955A (zh) * 2013-12-16 2014-03-19 百度在线网络技术(北京)有限公司 应用程序的运行管理方法和装置
CN104268022A (zh) * 2014-09-23 2015-01-07 浪潮(北京)电子信息产业有限公司 一种操作系统中进程的资源分配方法及系统
CN105912397A (zh) * 2016-03-31 2016-08-31 乐视控股(北京)有限公司 一种资源管理方法和装置
CN106681475A (zh) * 2016-12-12 2017-05-17 北京珠穆朗玛移动通信有限公司 降低移动终端功耗的方法及移动终端
CN107291557A (zh) * 2017-08-02 2017-10-24 中国银行股份有限公司 一种业务处理方法和装置

Also Published As

Publication number Publication date
CN110018903A (zh) 2019-07-16

Similar Documents

Publication Publication Date Title
WO2019128540A1 (zh) 资源管理方法、移动终端及计算机可读存储介质
US11099900B2 (en) Memory reclamation method and apparatus
CN107526640B (zh) 资源管理方法、装置、移动终端及计算机可读存储介质
WO2019137173A1 (zh) 资源管理方法、移动终端及计算机可读存储介质
WO2019137252A1 (zh) 内存处理方法、电子设备、计算机可读存储介质
JP6870158B2 (ja) メモリを処理するための方法および装置ならびに記憶媒体
WO2019137170A1 (zh) 信息处理方法、移动终端及计算机可读存储介质
WO2019128546A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
WO2019128571A1 (zh) 资源管理方法、装置、移动终端及计算机可读存储介质
EP3506114B1 (en) Memory processing method and device and storage medium
WO2019137258A1 (zh) 内存处理方法、电子设备及计算机可读存储介质
WO2019128588A1 (zh) 进程处理方法和装置、电子设备、计算机可读存储介质
WO2019024804A1 (zh) Cpu监测方法、计算机可读存储介质和移动终端
CN110032266B (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
WO2019128537A1 (zh) 应用冻结方法、计算机设备和计算机可读存储介质
CN110032429B (zh) 信息处理方法、装置、移动终端及计算机可读存储介质
WO2019128573A1 (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
WO2019128574A1 (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
WO2019128569A1 (zh) 应用程序冻结方法、装置、存储介质和终端
WO2019128542A1 (zh) 应用处理方法、电子设备、计算机可读存储介质
WO2019128586A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
WO2019137187A1 (zh) 资源管理方法、装置、移动终端及计算机可读存储介质
WO2019128570A1 (zh) 应用程序冻结方法、装置、存储介质和终端
CN109375995B (zh) 应用冻结方法和装置、存储介质、电子设备
CN109992369B (zh) 应用程序处理方法和装置、电子设备、计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18899431

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

Country of ref document: EP

Kind code of ref document: A1