Resource control method, device and equipment
By grouping tasks and dynamically adjusting resource thresholds, the problem of unbalanced resource allocation in the device is solved, lag and resource abuse are avoided, and system stability and user experience are improved.
Patent Information
- Application Number
- CN202510088228.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-06-10
AI Technical Summary
In the prior art, device background applications create a large number of backend tasks while frontend applications create fewer frontend tasks, resulting in unbalanced resource allocation and lag in frontend tasks, which affects system stability and user experience.
By grouping tasks differently and dynamically adjusting the resource thresholds corresponding to each group, we ensure that important real-time tasks obtain sufficient resources and avoid resource abuse and lag. The specific method includes obtaining load information and adjusting resource thresholds of the first task group and the second task group according to conditions to realize dynamic management of resources.
It effectively avoids resource abuse, improves the stability and performance of the system, and improves the user experience.
Smart Images

Figure CN120123076A_ABST
Abstract
Description
[0001] This application is a divisional application. The application number of the original application is 202410708211.4, the filing date of the original application is May 31, 2024, and the entire content of the original application is incorporated herein by reference. Technical Field
[0002] This application relates to the field of terminal communication technologies, and particularly to a resource control method, apparatus, and device. Background Art
[0003] With the continuous development of electronic devices, various types of tasks are running in the electronic devices. The device system includes system resources such as central processing unit (CPU) resources, network resources, and memory resources to be allocated for task use. Currently, if a large number of background tasks are created by background applications in the device and fewer foreground tasks are created by foreground applications, more resources will be allocated to the background tasks. At the same time, the foreground tasks will be allocated fewer resources and will experience lags and other situations. This leads to resource abuse and affects the system stability, performance, and user experience. Summary of the Invention
[0004] This application provides a resource control method, apparatus, and device. By grouping tasks differently and dynamically adjusting the resource thresholds corresponding to the groups, this method can ensure the resource allocation for important real-time tasks, avoid situations such as lags, and achieve dynamic management of resources. Thus, the system stability, performance, and user experience are improved.
[0005] To achieve the above object, this application adopts the following technical solutions:
[0006] In a first aspect, this application provides a resource control method applied to an electronic device. The electronic device includes a first task group and a second task group. The method includes: obtaining load information, where the load information is used to represent the resource usage amount corresponding to the tasks in the first task group and the second task group. The first task group includes real-time tasks corresponding to the applications currently interacting with the user. The first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group. The resource threshold is used to represent the maximum resource usage amount corresponding to the tasks in the task group. When the load information meets the first condition, adjusting the first resource threshold corresponding to the first task group to a third resource threshold, and adjusting the second resource threshold corresponding to the second task group to a fourth resource threshold.
[0007] Thus, on the one hand, in order to conform to the characteristics of terminal interaction priority, embodiments of the present application can divide tasks into different groups and set a relatively high resource threshold for the task group including real-time tasks, so that subsequent more flexible allocation and limitation of system resources can be carried out according to the characteristics of the groups. When a large number of background tasks created by applications are included in the second task group, embodiments of the present application can set a lower resource threshold for the second task group and a higher resource threshold for the first task group. On the basis that resource allocation is more inclined to tasks that more affect the user experience, it can avoid the situation that a large number of background tasks are allocated more resources and prevent resource abuse from affecting system stability.
[0008] On the other hand, embodiments of the present application can dynamically adjust the resource thresholds corresponding to different groups according to the load information corresponding to different groups. That is to say, the electronic device can adjust the resource threshold corresponding to the first task group and the resource threshold corresponding to the second task group based on the system operation situation when the load information meets the first condition. For example, when the number of real-time tasks in the first task group increases and the number of ordinary tasks in the second task group decreases, the resource threshold corresponding to the first task group can be increased. In this way, embodiments of the present application can ensure the resource allocation corresponding to important real-time tasks and avoid situations such as freezing to achieve dynamic management of resources. Thus, the stability, performance of the system and the user experience are improved.
[0009] In some implementable ways, when the load information meets the first condition and during the process of adjusting the first resource threshold to the third resource threshold and adjusting the second resource threshold to the fourth resource threshold, if within N consecutive preset periods, the used amount of resources in the first task group in the load information is greater than the first resource threshold and the used amount of resources in the second task group is less than the second resource threshold, the first resource threshold can be increased by the first ratio to obtain the third resource threshold, and the second resource threshold can be decreased by the first ratio to obtain the fourth resource threshold.
[0010] Or, if within N consecutive preset periods, the used amount of resources in the first task group is less than the first resource threshold and the used amount of resources in the second task group is greater than the second resource threshold, the first resource threshold can be decreased by the second ratio to obtain the third resource threshold, and the second resource threshold can be increased by the second ratio to obtain the fourth resource threshold; N is greater than 1.
[0011] In this way, embodiments of the present application can determine the load information within N consecutive preset periods. In the scenario where the used amount of resources corresponding to the task group is greater than the resource threshold, by dynamically adjusting the resource threshold of the task group, not only can the resource allocation be more inclined to tasks that more affect the user experience, but also the running requirements of the front and back ends of the mobile phone can be maximally met. The differences in the system running environment are maximally satisfied to ensure the running requirements of the mobile phone system.
[0012] In some implementable ways, the method further includes: the electronic device may determine a first ratio according to the difference between the amount of resources already used by the second task group and the second resource threshold. The electronic device may also determine a second ratio according to the difference between the amount of resources already used by the first task group and the first resource threshold.
[0013] Thus, in the process of adjusting the resource threshold in the embodiments of the present application, when the amount of resources already used by the task group does not exceed the resource threshold, not all the unused part of the resources is allocated to the task group corresponding to the exceeded resource threshold. Instead, a suitable ratio is determined based on the difference between the amount of resources already used and its resource threshold to adjust the resource thresholds of the two task groups. Thereby, the system resources are allocated as evenly as possible, and at the same time, the operation requirements corresponding to the two task groups are satisfied, improving the stability and performance of the system.
[0014] In some implementable ways, the method further includes: the electronic device may, every preset period, when the amount of resources already used by the first task group in the load information is greater than the first resource threshold, suspend the execution of at least one unexecuted task in the first task group; and / or, when the amount of resources already used by the second task group is greater than the second resource threshold, suspend the execution of at least one unexecuted task in the second task group.
[0015] Thus, the embodiments of the present application can control the tasks according to the running conditions of the tasks in the task group within a preset period. Specifically, when the amount of resources already used by the tasks in the task group is greater than the resource threshold, at least one unexecuted task in the task group will be suspended to facilitate the priority scheduling of tasks in other task groups. Avoiding a large number of background tasks created by background applications from occupying more resources and preventing resource abuse from affecting the system stability and performance. Thereby, improving the user experience.
[0016] In some implementable ways, when the load information meets the first condition, in the process of adjusting the first resource threshold to the third resource threshold and the second resource threshold to the fourth resource threshold, if within a preset duration, N preset periods are accumulated and the amount of resources already used by the first task group in the load information is greater than the first resource threshold, and the amount of resources already used by the second task group is less than the second resource threshold, the first resource threshold is increased by the first ratio to obtain the third resource threshold, and the second resource threshold is decreased by the first ratio to obtain the fourth resource threshold.
[0017] Or, if within a preset duration, N preset periods are accumulated and the amount of resources already used by the first task group is less than the first resource threshold, and the amount of resources already used by the second task group is greater than the second resource threshold, the first resource threshold is decreased by the second ratio to obtain the third resource threshold, and the second resource threshold is increased by the second ratio to obtain the fourth resource threshold; N is greater than 1.
[0018] Thus, the embodiments of the present application can also determine the load information within N preset cycles accumulated within a preset duration. Within N preset cycles accumulated within the preset duration, if the used amount of resources in one of the two task groups is greater than the corresponding resource threshold, and the used amount of resources in the other task group is less than the corresponding resource threshold, increase the resource threshold of the task group corresponding to the used amount of resources greater than the resource threshold, and decrease the resource threshold of the task group corresponding to the used amount of resources less than the resource threshold. This can not only make the resource allocation more inclined to the tasks that have a greater impact on the user experience, but also maximize the running requirements of the foreground and background of the mobile phone. It can meet the running requirements corresponding to different task groups to the greatest extent, and improve the stability and performance of the system.
[0019] In some implementable ways, the method further includes: the electronic device can divide the first task group and the second task group according to the task attributes of the tasks corresponding to the applications, where the task attributes are used to characterize the latency requirement situation corresponding to the tasks. The electronic device can also obtain the running tasks corresponding to the currently launched applications, and add the running tasks to the first task group and the second task group according to the task attributes corresponding to the running tasks.
[0020] Thus, the embodiments of the present application can divide different task groups according to the task attributes, and add the running tasks corresponding to the currently launched applications to different groups, which is convenient for associating a large number of running tasks. At the same time, it is more conducive to the electronic device to implement the interaction priority requirement in the subsequent resource allocation process. Thereby, the user experience is improved.
[0021] In some implementable ways, the electronic device includes multiple second task groups. In the process of adjusting the first resource threshold corresponding to the first task group to the third resource threshold and adjusting the second resource threshold corresponding to the second task group to the fourth resource threshold, within N consecutive preset cycles, if the used amount of resources in the first target task group among the first task group and the multiple second task groups is greater than its corresponding resource threshold, and the used amount of resources in the second target task group is less than its corresponding resource threshold, increase the resource threshold of the first target task group by a third ratio, and decrease the resource threshold of the second target task group by a third ratio.
[0022] Thus, in the embodiments of the present application, when there are multiple task groups, the load information within N consecutive preset cycles can also be determined. It can dynamically adjust the resource thresholds of multiple task groups, meet the running requirements corresponding to different task groups to the greatest extent, improve the adjustment flexibility, as well as the stability and performance of the system.
[0023] In some implementable manners, the first task group includes a first sub-task group and a second sub-task group. The first sub-task group corresponds to a first sub-resource threshold, and the second sub-task group corresponds to a second sub-resource threshold. During the process of obtaining the load information, the load information of the first sub-task group and the load information of the second sub-task group can be obtained.
[0024] The method further includes: when the load information of the first sub-task group and the load information of the second sub-task group meet the second condition, the electronic device can also adjust the first sub-resource threshold corresponding to the first sub-task group to a third sub-resource threshold, and adjust the second sub-resource threshold corresponding to the second sub-task group to a fourth sub-resource threshold.
[0025] In this way, the embodiments of the present application can further perform a next-level grouping for different task groups to further obtain different sub-groupings. Grouping can facilitate the management of a large number of tasks. Similarly, the sub-resource thresholds corresponding to different sub-groupings can also be dynamically adjusted. Thus, the adjustment flexibility is improved.
[0026] In some implementable manners, during the process of adjusting the first sub-resource threshold corresponding to the first sub-task group to a third sub-resource threshold and adjusting the second sub-resource threshold corresponding to the second sub-task group to a fourth sub-resource threshold when the load information of the first sub-task group and the load information of the second sub-task group meet the second condition, within N consecutive preset periods, when the used amount of resources of a third target task group in the first sub-task group and the second sub-task group is greater than its corresponding resource threshold, and the used amount of resources of a fourth target task group is less than its corresponding resource threshold, the resource threshold of the third target task group is increased according to a fourth ratio, and the resource threshold of the fourth target task group is decreased according to the fourth ratio.
[0027] In this way, in the embodiments of the present application, within N consecutive preset periods, when any one of the first sub-task group and the second sub-task group exceeds the upper limit and the other sub-task group does not exceed the upper limit, the resource threshold of the sub-task group corresponding to the one that exceeds the upper limit can be increased, and the resource threshold of the sub-task group corresponding to the one that does not exceed the upper limit can be decreased. It can make the resource allocation more inclined to the tasks that more affect the user experience, meet the differences in the system running environment to the greatest extent, and ensure the running requirements of the mobile phone system.
[0028] In some implementable manners, the resource threshold is the time slice threshold corresponding to the CPU core time slice of the central processing unit. The task is a process or a thread. The first task group includes real-time tasks corresponding to the applications currently interacting with the user. One task group in the second task group includes foreground tasks running in the foreground of the electronic device, and one task group in the second task group includes background tasks running in the background of the electronic device.
[0029] In some implementable ways, the second resource threshold corresponding to the second task group including foreground tasks is greater than the second resource threshold corresponding to the second task group including background tasks.
[0030] In this way, by setting the second resource threshold corresponding to the second task group including foreground tasks to be greater than the second resource threshold corresponding to the second task group including background tasks, not only can the allocation of resources be more inclined to tasks that have a greater impact on the user experience, but also the running requirements of the front and back ends of the mobile phone can be maximally met. Thus, the user experience can be improved.
[0031] In some implementable ways, during the process of adding a running task to the first task group and the second task group, the running tasks can be sorted in ascending order according to the task identifier of the running task, and then added to the first task group and the second task group.
[0032] In this way, in the embodiment of the present application, by using the task identifier of the running task to sort the running tasks in ascending order, the corresponding running task can be found more quickly. For example, a binary search algorithm can be used for retrieval to improve the search efficiency. At the same time, it is also convenient for subsequent statistics of the resource usage amounts corresponding to the running tasks in the first task group and the second task group, thereby improving the statistical efficiency.
[0033] In a second aspect, the embodiment of the present application further provides a resource control device, which includes a parameter configuration module, a statistics module, a policy management and control module, and a dynamic adjustment module.
[0034] The parameter configuration module is configured to configure the first resource threshold corresponding to the first task group and the second resource threshold corresponding to the second task group; the first task group includes real-time tasks corresponding to the applications currently interacting with the user, and the first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group, and the resource threshold is used to represent the maximum resource usage amount corresponding to the tasks in the task group.
[0035] The statistics module is configured to obtain load information, and the load information is used to represent the resource usage amounts corresponding to the tasks in the first task group and the second task group.
[0036] The policy management and control module is configured to determine whether the load information meets the first condition.
[0037] The dynamic adjustment module is configured to, when the load information meets the first condition, adjust the first resource threshold corresponding to the first task group to a third resource threshold, and adjust the second resource threshold corresponding to the second task group to a fourth resource threshold.
[0038] In this way, the resource control device provided by the embodiments of the present application can set a lower resource threshold for the second task group and a higher resource threshold for the first task group. On the basis that resource allocation is more inclined to tasks that have a greater impact on the user experience, it can avoid the situation where a large number of background tasks are allocated more resources, preventing resource abuse from affecting the system stability. At the same time, through the dynamic adjustment of the resource threshold, it can ensure the resource allocation corresponding to important real-time tasks, avoiding situations such as lag, so as to achieve dynamic management of resources.
[0039] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device is caused to execute the method described in the first aspect.
[0040] In a fourth aspect, an embodiment of the present application further provides a computer-readable medium, in which instructions are stored. When the instructions run on an electronic device, the electronic device is caused to execute the method described in the first aspect.
[0041] In a fifth aspect, an embodiment of the present application further provides a computer program product, which contains instructions. When the instructions run on a computer or a processor, the computer or the processor is caused to execute the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a schematic diagram of the hardware structure of a mobile phone provided by an embodiment of the present application;
[0043] Figure 2 It is a schematic diagram of the software structure of a mobile phone provided by an embodiment of the present application;
[0044] Figure 3 It is a schematic diagram of a scenario of different task groups provided by an embodiment of the present application;
[0045] Figure 4 It is a schematic diagram of a process of performing dynamic control and management provided by an embodiment of the present application;
[0046] Figure 5 It is a schematic diagram of a process of restricting tasks provided by an embodiment of the present application;
[0047] Figure 6 It is a schematic diagram of a process of adjusting the resource threshold provided by an embodiment of the present application;
[0048] Figure 7 It is a schematic diagram of a process of adjusting the first resource threshold and the second resource threshold provided by an embodiment of the present application;
[0049] Figure 8 A schematic diagram of a sub - task group scenario provided by an embodiment of the present application;
[0050] Figure 9 A schematic structural diagram of a resource control device provided by an embodiment of the present application;
[0051] Figure 10 A schematic structural diagram of a mobile phone provided by an embodiment of the present application. Detailed implementation manners
[0052] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application. Among them, in the description of the present application, unless otherwise specified, " / " means that the objects associated before and after are in an "or" relationship. For example, A / B may represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B may be singular or plural. And, in the description of the present application, unless otherwise specified, "a plurality of" means two or more than two. "At least one (item)" or similar expressions below refer to any combination of these items, including any combination of single - item (item) or plural - item (items). For example, at least one (item) of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or multiple. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish the same items or similar items with basically the same functions and roles.
[0053] Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and "first" and "second" do not necessarily mean different. At the same time, in some embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design solutions. Exactly, using words such as "exemplary" or "for example" aims to present relevant concepts in a specific way for easy understanding.
[0054] In addition, the device architecture and business scenarios described in the embodiments of the present application are for more clearly explaining the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those of ordinary skill in the art know that with the evolution of the device architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0055] Time slice: The running time allocated by the central processing unit (CPU) of an electronic device to each task. It can be understood that the running time of the CPU is divided into many time periods, and each task is allocated a time period, which is called its time slice, that is, the time allowed for the task to run.
[0056] Task: A series of device instructions that can achieve a certain goal. A task can be either a process or a thread. Usually, a task corresponds to a series of device operations, such as input operations, download operations, encoding and decoding operations, etc. The process or thread completes a task by executing the device operations in the task.
[0057] Process: An execution activity of a program in a device on a certain data set. It is the basic unit for the system to allocate resources and the basis of the operating system structure. A process is a memory area that contains certain resources. The operating system uses processes to divide its work into some functional units. One or more execution units contained in a process are called threads. A process also has a private virtual address space, which can only be accessed by the threads it contains. A thread can only belong to one process and it can only access the resources owned by that process. When the operating system creates a process, the process will automatically apply for a thread named the main thread or the primary thread.
[0058] Application program: Also known as an application. An application program is composed of one or more cooperating processes.
[0059] With the continuous development of electronic devices, various types of tasks are running in the electronic device. The device system includes system resources such as CPU resources, network resources, and memory resources to be allocated to tasks for use. Usually, the resource allocation strategy can schedule different types of tasks based on the order of obtaining tasks or the priorities of tasks. For example, more resources are allocated to busy tasks and fewer resources are allocated to idle tasks.
[0060] In this way, if the device background application creates a large number of background tasks and the foreground application creates fewer foreground tasks, more resources will be allocated to the background tasks. At the same time, the foreground tasks will be allocated fewer resources and there will be situations such as lag. Thus, the above solution will lead to resource abuse, affecting system stability, performance, and the user experience.
[0061] To solve the above technical problems, an embodiment of the present application provides a resource control method, apparatus, and device. The resource control method can be applied to an electronic device, which includes a first task group and a second task group. The method includes: The electronic device can obtain load information, which is used to characterize the resource usage of tasks in the first task group and the second task group. The first task group includes real-time tasks corresponding to applications currently interacting with the user. The first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group. The resource threshold is used to characterize the maximum resource usage of tasks in the task group. The electronic device can also, when the load information meets the first condition, adjust the first resource threshold corresponding to the first task group to a third resource threshold, and adjust the second resource threshold corresponding to the second task group to a fourth resource threshold.
[0062] Thus, the electronic device provided by the embodiment of the present application includes a first task group and a second task group. The first task group includes real-time tasks, and the maximum resource usage of the first task group is greater than that of the second task group. The electronic device can, when the load information meets the first condition, adjust the first resource threshold of the first task group to a third resource threshold, and adjust the second resource threshold of the second task group to a fourth resource threshold. That is to say, the electronic device can configure a higher resource usage for real-time tasks, and can also dynamically adjust the corresponding resource thresholds when the resource usages of the first task group and the second task group meet the first condition.
[0063] Among them, the real-time tasks in the first task group can include tasks corresponding to the current interaction with the user, that is, tasks with time limits. The tasks in the second task group can be ordinary tasks (non-real-time tasks) and can include tasks without time limits, such as tasks running in the background, tasks that are always resident in the foreground and do not interact with the user, etc.
[0064] On the one hand, in order to conform to the characteristics of terminal interaction priority, an embodiment of the present application can divide tasks into different groups, and set a higher resource threshold for the task group including real-time tasks, so as to facilitate more flexible allocation and limitation of system resources according to the characteristics of the groups in the future. When the second task group includes a large number of background tasks created by an application, the embodiment of the present application can, by setting a lower resource threshold for the second task group and a higher resource threshold for the first task group, on the basis that resource allocation is more inclined to tasks that more affect the user experience, avoid the situation where a large number of background tasks are allocated more resources, and prevent resource abuse from affecting system stability.
[0065] On the other hand, embodiments of the present application can dynamically adjust the resource thresholds corresponding to different groups according to the load information corresponding to different groups. That is to say, the electronic device can, based on the system operation situation, adjust the resource thresholds corresponding to the first task group and the second task group when the load information meets the first condition. For example, if the number of real-time tasks in the first task group increases and the number of ordinary tasks in the second task group decreases, the resource threshold corresponding to the first task group can be increased. In this way, embodiments of the present application can ensure the resource allocation for important real-time tasks, avoid situations such as freezing, and achieve dynamic management of resources. Thus, the stability, performance of the system, and the user experience are improved.
[0066] Among them, the electronic device provided by embodiments of the present application is a device such as a terminal or a server. The terminal may include a mobile phone, a smart watch, a tablet computer, a foldable electronic device, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an Ultra-Mobile Personal Computer (UMPC), a netbook, a cellular phone, a Personal Digital Assistant (PDA), an Augmented Reality (AR) device, a Virtual Reality (VR) device, an Artificial Intelligence (AI) device, a wearable device, a vehicle-mounted device, etc. The server may be a single server or a server cluster composed of multiple servers.
[0067] The server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and the present application does not limit this. Embodiments of the present application do not impose special restrictions on the specific type of the electronic device.
[0068] Moreover, the operating system installed on the electronic device includes but is not limited to or other operating systems. The present application does not limit the specific type of the electronic device or the type of the operating system when an operating system is installed.
[0069] Next, the method will be described by taking a mobile phone in which the resource control method is applied to an electronic device as an example. Figure 1 The following shows a schematic diagram of the hardware structure of the mobile phone provided by embodiments of the present application.
[0070] As shown Figure 1 in the figure, the mobile phone 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0071] Among them, the above-mentioned sensor module 180 may include sensors such as a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, and a bone conduction sensor 180M.
[0072] It can be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0073] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0074] Among them, the controller can be the nerve center and command center of the mobile phone 100. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching instructions and executing instructions.
[0075] A memory can also be set in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0076] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0077] The wireless communication function of the mobile phone 100 can be implemented through antenna 1, antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0078] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the mobile phone 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: Antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0079] The mobile phone 100 realizes the display function through the GPU, the display screen 194, the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to execute mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0080] The display screen 194 is used to display the target interface, etc. The display screen 194 includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the mobile phone 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0081] The mobile phone 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, the application processor, etc.
[0082] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera sensor. The optical signal is converted into an electrical signal, and the camera sensor transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0083] The mobile phone 100 can realize the audio function through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc. Such as music playback, recording, etc.
[0084] In some embodiments, the processor 110 can configure a first task group and a second task group and configure corresponding resource thresholds. The processor 110 can also obtain the load information of the first task group and the second task group and adjust the corresponding resource thresholds of the first task group and the second task group when the load information meets the first condition.
[0085] The software system of the mobile phone 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the Android system with a layered architecture as an example, the software structure of the mobile phone 100 will be exemplarily described.
[0086] Figure 2 It is a schematic diagram of the software structure of the mobile phone in the embodiments of the present application.
[0087] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0088] The application layer may include a series of application packages.
[0089] As Figure 2 shown, the application packages may include applications such as the first application, the second application, and the third application.
[0090] In some embodiments of the present application, both the first application and the second application are foreground applications, and the third application may be a background application. Among them, the first application is the application corresponding to the operation currently being performed by the user, and the first application is visible to the user on the mobile phone side. It can be understood that the visible application refers to the application that the user can see on the display screen of the mobile phone. The second application is the application corresponding to the operation running on the foreground of the mobile phone except the first application, and the background application is the application corresponding to the operation running on the background of the mobile phone. It should be noted that the above-mentioned first application, second application, and third application may be a type of application, and the embodiments of the present application do not specifically limit the application types and the number of applications corresponding to the first application, second application, and third application.
[0091] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0092] As Figure 2 shown, the application framework layer may include a window manager, a content provider, a view system, a telephone manager, a resource manager, a notification manager, and a parameter configuration module, etc.
[0093] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0094] The content provider is used to store and retrieve data and make this data accessible to applications. The data can include videos, images, audio, incoming and outgoing calls, browsing history and bookmarks, phone books, etc.
[0095] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can consist of one or more views. For example, a display interface including a text message notification icon can include a view for displaying text and a view for displaying pictures.
[0096] The phone manager is used to provide the communication functions of the electronic device 100. For example, the management of call states (including answering, hanging up, etc.).
[0097] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, and so on.
[0098] The notification manager enables applications to display notification information in the status bar. It can be used to convey informative messages, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that the download is complete, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as the notification of a background-running application, or a notification that appears in the form of a dialogue window on the screen. For example, it prompts text information in the status bar, emits a prompt tone, the electronic device vibrates, the indicator light flashes, etc.
[0099] Android Runtime includes core libraries and a virtual machine. Android Runtime is responsible for the scheduling and management of the Android system.
[0100] The core libraries contain two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.
[0101] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0102] The system libraries can include multiple functional modules. For example: surface manager, Media Libraries, 3D graphics processing libraries (such as: OpenGL ES), 2D graphics engines (such as: SGL), etc.
[0103] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0104] The media library supports the playback and recording of multiple common audio and video formats, as well as static image files, etc. The media library can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0105] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.
[0106] The 2D graphics engine is the drawing engine for 2D drawing.
[0107] The kernel layer is the layer between hardware and software. The kernel layer at least includes a first task group, a second task group, a statistics module, a policy control module, and a dynamic adjustment module.
[0108] In some embodiments of the present application, there are a parameter configuration module, a statistics module, a policy control module, and a dynamic adjustment module. The parameter configuration module is used to configure the grouping parameters corresponding to the first task group and the second task group. The grouping parameters may include resource threshold parameters and task quantity parameters, etc. The statistics module is used to count the resource usage corresponding to the first task group and the second task group within a specified cycle time. The resource usage may be, for example, the CPU execution time. The resource usage is used to subsequently determine whether the resource threshold corresponding to the group is reached and as the input of the dynamic adjustment module. The policy control module is used to determine whether the resource usage of the first task group and the second task group meets the first condition. The dynamic adjustment module is used to adjust the resource thresholds corresponding to each group when it is determined that the resource usage of the first task group and the second task group meets the first condition.
[0109] The following will specifically introduce the resource control method provided by the embodiments of the present application in conjunction with the accompanying drawings. In the following embodiments, the first device (such as a mobile phone) will continue to be used as an example for illustration. The method may include:
[0110] In some embodiments of the present application, for the convenience of resource control, the embodiments of the present application may first pre-obtain multiple task groups. The task groups may be process groups or thread groups. For the convenience of description, the following will use process groups as an example for illustration.
[0111] Exemplarily, the mobile phone can group all processes through process groups and then perform resource control on different groups as a whole, such as time slice allocation. In a process group, a task is a process of the system. Among them, each process group may include one or more processes, or may not include any processes.
[0112] In some embodiments of the present application, when the mobile phone obtains multiple task groups, it may pre-divide the task groups according to the task attributes corresponding to the tasks.
[0113] Specifically, the mobile phone may divide the first task group and the second task group according to the task attributes of the tasks corresponding to the applications, and the task attributes are used to characterize the delay requirement situation corresponding to the tasks. Exemplarily, the task attributes corresponding to the tasks in the first task group are real-time tasks, and the real-time tasks include the frame drawing tasks in the applications currently used by the user, and the tasks related to the frame drawing tasks. For example, the Renderservice main thread, the ArkUI application main thread, and the RSHardward thread. The task attributes corresponding to the tasks in the second task group are ordinary tasks (non-real-time tasks), for example, the download tasks corresponding to the browser application running in the background, and the download tasks corresponding to the email application running in the background. That is to say, the first task group may include the real-time processes corresponding to the currently started applications, and the second task group may include the ordinary processes corresponding to the currently started applications.
[0114] In some other embodiments of the present application, referring to Figure 3 (A) therein, when the mobile phone obtains multiple task groups, it may also pre-divide different task groups according to the running attributes of the applications (which may also be referred to as tasks or processes).
[0115] Among them, the running attribute of an application refers to whether an application is running in the foreground or in the background, and whether the process corresponding to the application is a process running in the operating system kernel or a process interacting with the user. Of course, one or more processes corresponding to an application also have corresponding running attributes, and the running attribute of a process refers to whether one or more processes are foreground processes or background processes. Exemplarily, the running attributes corresponding to the tasks in the first task group are foreground tasks, and the running attributes corresponding to the tasks in the second task group are background tasks.
[0116] It should be noted that the task attributes and running states of the above tasks can be obtained through the description information corresponding to the tasks. For example, the process control block of a process may include process description information, and the process description information may include description information such as the unique identifier of the process, function information, task attributes, and running attributes.
[0117] In some other embodiments of the present application, referring to Figure 3 (B) therein, when the mobile phone obtains multiple task groups, it may also divide different task groups according to the task attributes and running attributes corresponding to the tasks.
[0118] Specifically, the mobile phone may divide the first task group and multiple second task groups according to the task attributes and running attributes of the tasks corresponding to the applications.
[0119] Exemplarily, the mobile phone can divide the first task group and multiple second task groups according to the task attributes of the tasks corresponding to the applications. The first task group includes real-time tasks, and the second task groups include ordinary tasks. The mobile phone can also divide the second task groups according to the running attributes corresponding to the applications to obtain multiple second task groups. For example, one second task group includes ordinary tasks running in the foreground, and another second task group includes ordinary tasks running in the background.
[0120] In some embodiments of the present application, the resource threshold can be the time slice threshold corresponding to the CPU core time slice of the central processing unit. The task is a process or a thread. The first task group includes real-time tasks corresponding to the applications currently interacting with the user. One task group in the second task groups includes foreground tasks running in the foreground of the electronic device, and one task group in the second task groups includes background tasks running in the background of the electronic device.
[0121] Exemplarily, the first task group can be the head process group, and the second task groups can include the foreground process group and the background process group. Among them, the head process group can include processes related to the current interaction with the user. Exemplarily, when the user is currently using a video application and a social application, the head process group can include the frame drawing process corresponding to the video application, the frame drawing process corresponding to the social application, etc. The foreground process group can include processes running in the foreground. Exemplarily, the foreground process group can include the Launcher process corresponding to the desktop application. The background process group can include processes running in the background and do not need to interact with the user.
[0122] It should be noted that the mobile phone can also pre-set other task groups in addition to the above-mentioned first task group and second task groups. The number and names of the task groups shown in the present application are only exemplary examples, and the present application does not make specific limitations on this. At the same time, the above-mentioned grouping is also only a schematic example, and the present application does not make specific limitations on this. It can be understood that in an embodiment of the present application, a task group includes a certain application, that is, this grouping includes the processes corresponding to this application. For example, the head process group includes one or more processes corresponding to the browser application.
[0123] In this way, the embodiments of the present application can divide different task groups according to the task attributes or according to the task attributes and running attributes, and add the running tasks corresponding to the currently launched applications to different groups, which is convenient for associating a large number of running tasks. At the same time, it is more conducive to the electronic device to meet the interaction priority requirements in the subsequent resource allocation process. Thus, the user experience is improved.
[0124] In some embodiments of the present application, the mobile phone can also pre-set the resource thresholds corresponding to the first task group and the second task groups.
[0125] Specifically, the mobile phone can set the first resource threshold corresponding to the first task group and the second resource threshold corresponding to the second task group according to the user usage information within the preset time. The user usage information may include the cumulative usage time corresponding to the used applications in the mobile phone and the download information corresponding to the used applications, such as the number of downloads and installations.
[0126] Exemplarily, the mobile phone can set the resource thresholds corresponding to the first task group and the second task group according to the accumulated usage time corresponding to the used applications within a preset time. For example, the mobile phone can determine that the application with a daily accumulated usage time greater than the time threshold is the first application, and the application with a daily accumulated usage time less than or equal to the time threshold is the second application or the third application according to the accumulated daily usage time corresponding to the used applications within 1 month.
[0127] As another example, the mobile phone can also set the resource thresholds corresponding to the first task group and the second task group based on the download information corresponding to the used applications within a preset time period. For example, the mobile phone can determine that the application with a download and installation count greater than the number threshold is the first application, and the application with a download and installation count less than or equal to the number threshold is the second application or the third application based on the download and installation count corresponding to the used applications within 1 month. It should be noted that the user usage information within the above preset time period can be obtained by the mobile phone through the application data corresponding to the application market application. The embodiment of the present application does not specifically limit the method of obtaining it.
[0128] In some embodiments of the present application, the preset resource threshold may refer to a preset resource amount. Wherein, in a scenario where the resource is a CPU resource, the resource threshold may represent the maximum value of the execution time corresponding to the task in the task group. Exemplarily, the first resource threshold may be the maximum value of the time slice corresponding to the task in the first task group. The second resource threshold may be the maximum value of the time slice corresponding to the task in the second task group.
[0129] In another exemplary embodiment, the resource threshold value may also represent the maximum proportion of the execution time corresponding to the task in the task group to the total CPU time slice. For example, the first resource threshold value may be the maximum proportion of the time slice corresponding to the first task group to the total CPU time slice. The second resource threshold value may be the maximum proportion of the time slice corresponding to the second task group to the total CPU time slice.
[0130] In order to favor tasks that have a greater impact on user experience during the resource control process, the resource threshold setting strategy proposed in the embodiment of the present application can set a higher resource threshold for the first task group corresponding to the task currently being interacted with by the user. Similarly, in order to prevent a large number of tasks running in the background from occupying resources, a lower resource threshold can be set for the second task group corresponding to the background task in the second task group.
[0131] In some embodiments of the present application, the first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group, and the second resource threshold corresponding to the second task group including foreground tasks is greater than the second resource threshold corresponding to the second task group including background tasks.
[0132] For ease of description, the resource threshold will be exemplarily described in the form of a ratio below. The first resource threshold is 80%, the second resource threshold corresponding to the second task group including foreground tasks is 50%, and the second resource threshold corresponding to the second task group including background tasks is 10%. Again exemplarily, the first resource threshold is 70%, the second resource threshold corresponding to the second task group including foreground tasks is 55%, and the second resource threshold corresponding to the second task group of background tasks is 15%. Again exemplarily, the first resource threshold is 85%, the second resource threshold corresponding to the second task group including foreground tasks is 45%, and the second resource threshold corresponding to the second task group of background tasks is 5%. It should be noted that the embodiments of the present application do not specifically limit the numerical values corresponding to the first resource threshold and the second resource threshold.
[0133] In some embodiments of the present application, refer to Figure 4 , the mobile phone can read the grouping configuration during system initialization. For example, the grouping includes a first task group and two second task groups, as well as the resource threshold corresponding to each task group. The mobile phone can also initialize the tree-shaped grouping structure using a tree-shaped grouping control data structure for the above different grouping configuration strategies. Among them, the tree-shaped grouping structure refers to a way of processing data in a tree-like structure grouping, which can clearly represent the hierarchical relationship between data. The tree-shaped grouping structure is usually used to process data with parent-child relationships or hierarchical structures, such as grouping a large number of execution tasks into different task groups, and different sub-task groups can be divided at the next level under each task group, etc.
[0134] The mobile phone can count the load information and add data to the tree-shaped grouping structure, such as adding the corresponding task to the corresponding task group. The mobile phone can also perform dynamic control and adjustment on the tasks in the tree-shaped grouping structure. When the used amount of resources corresponding to a task reaches the resource threshold, control and / or adjust the resource threshold for the task.
[0135] In some realizable ways, during the process of the mobile phone adding data to the tree-shaped grouping structure, the mobile phone can obtain the running tasks corresponding to the currently started applications, and add the running tasks to the first task group and the second task group according to the task attributes corresponding to the running tasks.
[0136] Exemplarily, the mobile phone can obtain all the processes corresponding to the currently started applications, and add the real-time processes to the first task group and the ordinary processes to the second task group according to the task attributes corresponding to the processes.
[0137] In some other implementable manners, the mobile phone can also obtain the running tasks corresponding to the currently started applications, and add the running tasks to the first task group and the second task group according to the task attributes and running attributes corresponding to the running tasks.
[0138] Exemplarily, the mobile phone can obtain all the processes corresponding to the currently started applications, add the real-time processes to the first task group, and add the normal processes to the second task group. Then, the mobile phone can add the foreground-running normal processes to one second task group and the background-running normal processes to another second task group according to the running attributes corresponding to the normal processes.
[0139] It should be noted that the embodiments of the present application do not specifically limit the adding process of adding the running tasks to the corresponding task groups.
[0140] In this way, the embodiments of the present application can pre-divide different task groups and set different resource thresholds for different task groups. Among them, the resource threshold of the task group corresponding to the real-time task is relatively high. At the same time, the running tasks corresponding to the started applications can also be added to different task groups according to the task attributes corresponding to the tasks, which is convenient for subsequent execution of the resource control process according to the running conditions of the tasks in the task groups. It can be seen that by setting different task groups, the system resources can be controlled more flexibly according to the characteristics of the groups. At the same time, the real-time tasks can use more resources during the execution process, so as to conform to the characteristics of the mobile phone for interaction priority. Furthermore, the user experience can be improved.
[0141] In some embodiments of the present application, when adding the running tasks to the first task group and the second task group, the mobile phone can sort the running tasks in ascending order according to the task identifiers of the running tasks, and add them to the first task group and the second task group.
[0142] That is to say, the mobile phone can sort the processes or threads in ascending order according to the identifiers corresponding to the processes or threads, such as process IDs or thread IDs, and add them to the first task group and the second task group.
[0143] In this way, by using the task identifiers of the running tasks to sort the running tasks in ascending order, the embodiments of the present application can find the corresponding running tasks more quickly. For example, the binary search algorithm can be used for retrieval to improve the search efficiency. At the same time, it is also convenient for subsequent statistics of the resource usage amounts corresponding to the running tasks in the first task group and the second task group, and improves the statistical efficiency.
[0144] In some embodiments of the present application, the mobile phone can obtain the resource usage amounts corresponding to different task groups within a preset period, and dynamically adjust the corresponding resource thresholds and limit the tasks in the task groups according to the resource usage amounts of different task groups.
[0145] In some embodiments, referring to Figure 5 , the mobile phone can also obtain load information (step 501). Among them, the load information is used to characterize the resource usage corresponding to the tasks in the first task group and the second task group. The mobile phone can also, every preset period, when the used amount of resources in the first task group in the load information is greater than the first resource threshold, suspend the execution of at least one unexecuted task in the first task group; and / or, when the used amount of resources in the second task group is greater than the second resource threshold, suspend the execution of at least one unexecuted task in the second task group (step 502).
[0146] Exemplarily, the first resource threshold is 80%, and the second resource threshold is 50%. The mobile phone can, every preset period, obtain the kernel time slices corresponding to the processes in the first task group and the second task group.
[0147] For example, the mobile phone obtains the kernel time slices corresponding to the processes in the first task group and the second task group every 5 seconds. If the ratio of the kernel time slice corresponding to the process in the first task group to the total CPU time slice is less than 80%, and the ratio of the kernel time slice corresponding to the process in the second task group to the total CPU time slice is greater than 50%, the mobile phone can limit the processes in the second task group in the next preset period, that is, suspend the execution of at least one unexecuted process in the second task group, and do not allocate CPU resources to at least one unexecuted process in the second task group, that is, reduce the execution of the tasks in this task group, so as to facilitate the preferential scheduling of the tasks of other task groups.
[0148] For another example, the mobile phone obtains the kernel time slices corresponding to the processes in the first task group and the second task group every 10 seconds. If the ratio of the kernel time slice corresponding to the process in the first task group to the total CPU time slice is greater than 80%, and the ratio of the kernel time slice corresponding to the process in the second task group to the total CPU time slice is less than 50%, the mobile phone can limit the processes in the first task group in the next preset period, that is, suspend the execution of at least one unexecuted process in the first task group, and do not allocate CPU resources to at least one unexecuted process in the first task group, that is, reduce the execution of the tasks in this task group, so as to facilitate the preferential scheduling of the tasks of other task groups.
[0149] It should be noted that this application does not limit the specific value corresponding to the preset period.
[0150] In this way, the embodiments of this application can control the tasks according to the running conditions of the tasks in the task group within the preset period. Specifically, when the used amount of resources of the tasks in the task group is greater than the resource threshold, at least one unexecuted task in the task group will be suspended from execution. This avoids a large number of background tasks created by background applications from occupying more resources, and prevents resource abuse from affecting system stability and performance. Thus, the user experience is improved.
[0151] In some embodiments, referring to Figure 6 , the mobile phone can also obtain load information (step 601). When the load information meets the first condition, the mobile phone can adjust the first resource threshold corresponding to the first task group to the third resource threshold and adjust the second resource threshold corresponding to the second task group to the fourth resource threshold (step 602).
[0152] Specifically, referring to Figure 7 in (A), when the amount of resources used by the first task group in the load information is greater than the first resource threshold and the amount of resources used by the second task group is less than the second resource threshold within N consecutive preset periods, the mobile phone can increase the first resource threshold and decrease the second resource threshold. Specifically, the third resource threshold is obtained by increasing the first resource threshold by the first ratio, and the fourth resource threshold is obtained by decreasing the second resource threshold by the first ratio, where N is greater than 1.
[0153] Alternatively, referring to Figure 7 in (B), when the amount of resources used by the first task group is less than the first resource threshold and the amount of resources used by the second task group is greater than the second resource threshold within N consecutive preset periods, the mobile phone can decrease the first resource threshold and increase the second resource threshold in the next preset period. Specifically, the third resource threshold is obtained by decreasing the first resource threshold by the second ratio, and the fourth resource threshold is obtained by increasing the second resource threshold by the second ratio, where N is greater than 1.
[0154] Exemplarily, the first resource threshold is 80% and the second resource threshold is 50%. The mobile phone can obtain the kernel time slices corresponding to the processes in the first task group and the second task group for N consecutive preset periods. For example, the mobile phone obtains the kernel time slices corresponding to the processes in the first task group and the second task group for 3 consecutive preset periods of 15 seconds. If the proportion of the kernel time slices corresponding to the processes in the first task group in the total CPU time slices is greater than 80% and the proportion of the kernel time slices corresponding to the processes in the second task group in the total CPU time slices is less than 50% within the 3 consecutive preset periods, the mobile phone can increase the first resource threshold to the third resource threshold, such as 90%, and decrease the second resource threshold to the fourth resource threshold, such as 40%, in the next preset period according to the second ratio.
[0155] For another example, the mobile phone obtains the kernel time slices corresponding to the processes in the first task group and the second task group for 3 consecutive preset periods, such as 15 seconds. If the proportion of the kernel time slices corresponding to the processes in the first task group in the total CPU time slices is less than 80% within 3 consecutive preset periods, and the proportion of the kernel time slices corresponding to the processes in the second task group in the total CPU time slices is greater than 50%, the mobile phone can reduce the first resource threshold to the third resource threshold, such as 70%, and increase the second resource threshold to the fourth resource threshold, such as 60%, according to the first proportion in the next preset period.
[0156] In this way, the embodiment of the present application can also determine the load information within N consecutive preset periods. If, within N consecutive preset periods, the used amount of resources in one of the two task groups is greater than the corresponding resource threshold, and the used amount of resources in the other task group is less than the corresponding resource threshold, increase the resource threshold of the task group with the used amount of resources greater than the resource threshold, and decrease the resource threshold of the task group with the used amount of resources less than the resource threshold. In the scenario where the used amount of resources corresponding to the task group is greater than the resource threshold, by dynamically adjusting the resource threshold of the task group, not only can the allocation of resources be more inclined to the tasks that more affect the user experience, but also the running requirements of the foreground and background of the mobile phone can be maximally met. The differences in the system running environment are maximally satisfied, and the running requirements of the mobile phone system are ensured.
[0157] In some embodiments of the present application, the mobile phone can determine the first proportion according to the difference between the used amount of resources in the second task group and the second resource threshold. The mobile phone can also determine the second proportion according to the difference between the used amount of resources in the first task group and the first resource threshold.
[0158] In some implementable ways, the mobile phone can determine the first difference between the second resource threshold and the used amount of resources in the second task group within N consecutive preset periods, and assign a preset weight to the first difference to obtain the first proportion.
[0159] Exemplarily, the first resource threshold of the first task group set in advance is 80%, and the second resource threshold of the second task group is 50%.
[0160] For example, in the first preset period, the proportion of the kernel time slice corresponding to the processes in the first task group in the total CPU time slice is 90%, and the proportion of the kernel time slice corresponding to the processes in the second task group in the total CPU time slice is 10%. In the second preset period, the proportion of the kernel time slice corresponding to the processes in the first task group in the total CPU time slice is 90%, and the proportion of the kernel time slice corresponding to the processes in the second task group in the total CPU time slice is 20%. It can be seen that within two consecutive preset periods, the proportion of the kernel time slice corresponding to the processes in the first task group in the total CPU time slice is greater than 80%, and the proportion of the kernel time slice corresponding to the processes in the second task group in the total CPU time slice is less than 50%.
[0161] The mobile phone determines that within two consecutive preset periods, the first difference between the second resource threshold and the used amount of resources of the second task group is 70%. Specifically, within the first preset period, the difference between the second resource threshold and the used amount of resources of the second task group is 40%. Within the second preset period, the difference between the second resource threshold and the used amount of resources of the second task group is 30%. In this way, the corresponding differences within the two preset periods are added together to obtain the first difference of 70%. The mobile phone can assign a preset weight such as 0.1 to the first difference to obtain the first ratio of 7%. In this way, subsequently, the mobile phone can increase the first resource threshold to the third resource threshold of 87% and decrease the second resource threshold to the fourth resource threshold of 43%.
[0162] In some other implementable ways, the mobile phone can determine the average difference between the second resource threshold and the used amount of resources of the second task group within N preset periods, and assign a preset weight to the average difference to obtain the first ratio.
[0163] In some implementable ways, the mobile phone can determine the second difference between the first resource threshold and the used amount of resources of the first task group within N consecutive preset periods, and assign a preset weight to the second difference to obtain the second ratio. It should be noted that the process of obtaining the second ratio is similar to the above process of obtaining the first ratio, and will not be elaborated here.
[0164] In some other implementable ways, the mobile phone can also determine the above first ratio according to the difference between the used amount of resources of the first task group and the first resource threshold. Of course, the mobile phone can also determine the above second ratio according to the difference between the used amount of resources of the second task group and the second resource threshold.
[0165] It should be noted that the above processes of obtaining the first ratio and the second ratio are only exemplary descriptions, and the embodiments of the present application do not specifically limit this. At the same time, the embodiments of the present application do not limit the specific values corresponding to the first ratio and the second ratio.
[0166] Thus, in the process of adjusting the resource threshold in the embodiments of the present application, the adjustment can be made according to the difference between the used amount of resources of the task group corresponding to the resource threshold and its resource threshold. That is to say, when the used amount of resources of the task group does not exceed the resource threshold, not all the unused part of the resources is allocated to the task group corresponding to the exceeded resource threshold. Instead, a suitable ratio is determined based on the difference between the used amount of resources and its resource threshold to adjust the resource thresholds of the two task groups. Thus, the system resources are allocated as evenly as possible, and at the same time, the operation requirements corresponding to the two task groups are met, improving the stability and performance of the system.
[0167] In some embodiments of the present application, the mobile phone can also accumulate N preset cycles within a preset duration. When the used amount of resources of the first task group in the load information is greater than the first resource threshold and the used amount of resources of the second task group is less than the second resource threshold, the first resource threshold is increased by a first ratio to obtain a third resource threshold, and the second resource threshold is decreased by the same ratio to obtain a fourth resource threshold.
[0168] Alternatively, within a preset duration, when N preset cycles are accumulated, and the used amount of resources of the first task group is less than the first resource threshold and the used amount of resources of the second task group is greater than the second resource threshold, the first resource threshold is decreased by a second ratio to obtain a third resource threshold, and the second resource threshold is increased by the same ratio to obtain a fourth resource threshold; N is greater than 1.
[0169] That is to say, the mobile phone can also set a preset duration, which is greater than N preset cycles. In this way, the mobile phone can also accumulate multiple preset cycles within a certain preset duration. When the used amount of resources of the first task group in the load information is greater than the first resource threshold and the used amount of resources of the second task group is less than the second resource threshold, the first resource threshold and the second resource threshold are adjusted.
[0170] Alternatively, the mobile phone can also accumulate multiple preset cycles within a certain preset duration. When the used amount of resources of the first task group in the load information is less than the first resource threshold and the used amount of resources of the second task group is greater than the second resource threshold, the first resource threshold and the second resource threshold are adjusted.
[0171] Thus, the embodiments of the present application can also determine the load information within N preset cycles accumulated within a preset duration. Within N preset cycles accumulated within the preset duration, if the used amount of resources in one of the two task groups is greater than the corresponding resource threshold, and the used amount of resources in the other task group is less than the corresponding resource threshold, the resource threshold of the task group with the used amount of resources greater than the resource threshold is increased, and the resource threshold of the task group with the used amount of resources less than the resource threshold is decreased. In the scenario where the used amount of resources corresponding to the task group is greater than the resource threshold, the resource threshold of the task group can be adjusted dynamically more flexibly. This can not only make the allocation of resources more inclined to the tasks that have a greater impact on the user experience, but also maximize the running requirements of the foreground and background of the mobile phone. It can meet the running requirements corresponding to different task groups to the greatest extent and improve the stability and performance of the system.
[0172] In some embodiments of the present application, the electronic device may include multiple second task groups. Based on the above strategy, within N consecutive preset cycles, when the used amount of resources in the first task group and the multiple second task groups is such that the used amount of resources in the first target task group is greater than its corresponding resource threshold, and the used amount of resources in the second target task group is less than its corresponding resource threshold, the resource threshold of the first target task group is increased by a third ratio and the resource threshold of the second target task group is decreased.
[0173] Exemplarily, within 3 consecutive preset cycles, the mobile phone can determine the task group with the used amount of resources greater than its corresponding resource threshold as the first target task group among the first task group and the multiple second task groups, and determine the task group with the used amount of resources less than its corresponding resource threshold as the second target task group. And increase the resource threshold of the first target task group and decrease the resource threshold of the second target task group according to the third ratio.
[0174] That is to say, the embodiments of the present application can, within N consecutive preset cycles, when one of the first task group and the multiple second task groups exceeds the upper limit and the other does not, increase the resource threshold of the task group corresponding to the one that exceeds the upper limit and decrease the resource threshold of the task group corresponding to the one that does not exceed the upper limit.
[0175] Among the first task group and the multiple second task groups, it is possible that the used amount of resources in multiple task groups is greater than their corresponding resource thresholds, and it is also possible that the used amount of resources in multiple task groups is less than their corresponding resource thresholds. That is to say, the first target task group and the second target task group do not only correspond to one task group, but can also correspond to multiple task groups.
[0176] In an implementable manner, if the used amount of resources of the first task group and a second task group among multiple second task groups is greater than its corresponding resource threshold, that is, the first target task group includes the first task group and a second task group, the mobile phone can preferentially increase the resource threshold corresponding to the first task group.
[0177] Exemplarily, continuing with the example where the first task group is the head process group and the second task groups include the foreground process group and the background process group. The used amounts of resources corresponding to the head process group and the foreground process group are both greater than their corresponding resource thresholds, and the used amount of resources corresponding to the background process group is less than its corresponding resource threshold. That is, the first target task group is the head process group and the foreground process group, and the second target task group is the background process group. The mobile phone can increase the resource threshold corresponding to the head process group according to a third ratio and decrease the resource threshold corresponding to the background process group according to the third ratio.
[0178] In another implementable manner, if the used amount of resources of the first task group is less than its corresponding resource threshold and the used amount of resources of a second task group among multiple second task groups is less than its corresponding resource threshold, that is, the second target task group includes the first task group and a second task group, the mobile phone can preferentially decrease the resource threshold corresponding to the second task group.
[0179] Exemplarily, the used amount of resources corresponding to the foreground process group is greater than its corresponding resource threshold, and the used amounts of resources corresponding to the head process group and the background process group are less than their corresponding resource thresholds. That is, the first target task group is the foreground process group, and the second target task group is the head process group and the background process group. The mobile phone can increase the resource threshold corresponding to the foreground process group according to a third ratio and decrease the resource threshold corresponding to the background process group according to the third ratio.
[0180] In this way, in the embodiments of the present application, when there are multiple task groups, the load information within consecutive N preset periods can also be determined. The resource thresholds of multiple task groups can be dynamically adjusted to meet the operation requirements corresponding to different task groups to the greatest extent, improving the adjustment flexibility, as well as the stability and performance of the system.
[0181] In some embodiments of the present application, the mobile phone can also divide different groups into different sub - groups according to a preset rule and set corresponding sub - resource thresholds for different sub - groups.
[0182] In some implementable manners, the mobile phone can divide the first task group according to the priorities of real - time tasks. Refer to Figure 8 , exemplarily, the first task group includes a first sub - task group and a second sub - task group, and the priorities of the real - time tasks in the first sub - task group are higher than the priorities of the real - time tasks in the second sub - task group.
[0183] Among them, the first sub-task group corresponds to a first sub-resource threshold, and the second sub-task group corresponds to a second sub-resource threshold. The first sub-resource threshold and the second sub-resource threshold can also be set according to the corresponding priorities of real-time tasks. For example, in real-time tasks, the priority of the download task is lower than that of the drawing task. In this way, the first sub-resource threshold corresponding to the first sub-task group including the drawing task is greater than the second sub-resource threshold corresponding to the second sub-task group including the download task.
[0184] In some other implementable ways, the mobile phone can also divide the first task group according to the corresponding quantity of real-time tasks. Exemplarily, it includes a first sub-task group and a second sub-task group, and the quantity of real-time tasks corresponding to the first sub-task group can be the same as or different from the quantity of real-time tasks corresponding to the second sub-task group.
[0185] Among them, when the quantity of real-time tasks in the first sub-task group is the same as that in the second sub-task group, the first sub-resource threshold is equal to the second sub-resource threshold. When the quantity of real-time tasks in the first sub-task group is different from that in the second sub-task group, the sub-resource threshold of the task group with a larger quantity is greater than the sub-resource threshold of the task group with a smaller quantity.
[0186] In some embodiments of the present application, the mobile phone can also obtain the load information of the first sub-task group and the load information of the second sub-task group. When the load information of the first sub-task group and the load information of the second sub-task group meet the second condition, the mobile phone can adjust the first sub-resource threshold corresponding to the first sub-task group to a third sub-resource threshold, and adjust the second sub-resource threshold corresponding to the second sub-task group to a fourth sub-resource threshold.
[0187] Specifically, within N consecutive preset cycles, when the used amount of resources of the third target task group in the first sub-task group and the second sub-task group is greater than its corresponding resource threshold, and the used amount of resources of the fourth target task group is less than its corresponding resource threshold, the mobile phone can increase the resource threshold of the third target task group according to the fourth ratio, and decrease the resource threshold of the fourth target task group according to the fourth ratio.
[0188] That is to say, in the embodiments of the present application, within N consecutive preset cycles, if any one of the first sub-task group and the second sub-task group exceeds the upper limit and the other does not exceed the upper limit, the resource threshold of the sub-task group corresponding to the one that exceeds the upper limit can be increased, and the resource threshold of the sub-task group corresponding to the one that does not exceed the upper limit can be decreased.
[0189] It should be noted that the process of adjusting the sub-resource threshold corresponding to the sub-task group is similar to the process of adjusting the resource threshold corresponding to the task group described above, and will not be elaborated here. The above first ratio, second ratio, third ratio, and fourth ratio may be the same or different. In the embodiments of the present application, the processes of determining the first ratio, second ratio, third ratio, and fourth ratio may be the same or different, and the specific processes corresponding to the first ratio, second ratio, third ratio, and fourth ratio are not specifically limited.
[0190] In this way, the embodiments of the present application can also perform a next-level grouping for different task groups to further obtain different sub-groupings. Grouping can facilitate the management of a large number of tasks. Specifically, grouping can be performed according to the different priorities of real-time tasks. This is more conducive to meeting the interactive priority requirements of the electronic device.
[0191] Similarly, the sub-resource thresholds corresponding to different sub-groupings can also be dynamically adjusted. Specifically, the sub-resource thresholds of each sub-group can be the same, which can reflect the fairness of threshold setting. Thus, the adjustment flexibility is improved.
[0192] In some embodiments of the present application, during the operation of the mobile phone, the tasks in different task groups will have changes in operation attributes over time. That is to say, the tasks in the first task group and the second task group are not fixed. The mobile phone can dynamically adjust the tasks in the first task group and the second task group over time, such as dynamically adding a process to the task group or deleting it from the task group.
[0193] Specifically, the mobile phone can also monitor each running task, such as monitoring the state changes of each running process. When it is detected that a process undergoes a foreground / background state change, the mobile phone can determine whether the running state of the process after the change is foreground running or background running.
[0194] Exemplarily, obtain the list of all running processes every 5 seconds and determine one by one whether the state of each running process in the process list is foreground running or background running. The running state of the process this time can be compared with the previous running state. If the previous running state of the process is different from the current running state, it can be determined that the process has undergone a foreground / background state change. The mobile phone can determine the current running state of the process and add the process to the corresponding task group after determining the running state.
[0195] For example, for a newly added interactive process, if the mobile phone determines that the running state of the interactive process is foreground running and the corresponding task attribute is a real-time task, the interactive process is added to the first task group. For a download process, if the mobile phone determines that the running state of the download process is background running, the background running is added to the second task group.
[0196] Thus, when the running status of a task changes in an embodiment of the present application, the tasks in the task group can be dynamically adjusted to implement setting the task in a suitable task group. In this way, when obtaining the load information corresponding to the task group and adjusting the resource threshold subsequently, it can be ensured that each task can be supplied in a timely manner, achieving the flexibility and dynamics of resource control.
[0197] An embodiment of the present application further provides a resource control device, which can be applied to an electronic device or can be independently set. Refer to Figure 9 , the resource control device includes a parameter configuration module 901, a statistics module 902, a policy management and control module 903, and a dynamic adjustment module 904.
[0198] The parameter configuration module 901 is configured to configure a first resource threshold corresponding to a first task group and a second resource threshold corresponding to a second task group; the first task group includes real-time tasks corresponding to an application currently interacting with the user, and the first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group, and the resource threshold is used to represent the maximum resource usage amount corresponding to the tasks in the task group.
[0199] The statistics module 902 is configured to obtain load information, and the load information is used to represent the resource usage amounts corresponding to the tasks in the first task group and the second task group.
[0200] The policy management and control module 903 is configured to determine that the load information satisfies a first condition.
[0201] The dynamic adjustment module 904 is configured to, when the load information satisfies the first condition, adjust the first resource threshold corresponding to the first task group to a third resource threshold, and adjust the second resource threshold corresponding to the second task group to a fourth resource threshold.
[0202] In some solutions, multiple embodiments of the present application can be combined and the combined solution can be implemented. Optionally, some operations in the processes of the method embodiments are optionally combined, and / or the order of some operations is optionally changed. And, the execution order between the steps of each process is only exemplary and does not constitute a limitation on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be executed.
[0203] Those of ordinary skill in the art will think of various ways to reorder the operations described in the embodiments of the present application. In addition, it should be noted that the process details involved in a certain embodiment of the present application are equally applicable to other embodiments in a similar manner, or different embodiments can be combined and used.
[0204] In addition, some steps in the method embodiments can be equivalently replaced by other possible steps. Or, some steps in the method embodiments can be optional and can be deleted in some usage scenarios. Or, other possible steps can be added to the method embodiments.
[0205] Moreover, the method embodiments can be implemented independently or in combination with each other.
[0206] The embodiments of the present application also provide an electronic device, which can be, for example, the above-mentioned mobile phone. As Figure 10 shown, the mobile phone can include one or more processors 1010, a memory 1020, and a communication interface 1030.
[0207] The memory 1020 and the communication interface 1030 are coupled to the processor 1010. For example, the memory 1020 and the communication interface 1030 can be coupled to the processor 1010 through a bus 1040.
[0208] The communication interface 1030 is used for data transmission with other devices. The memory 1020 stores computer program code. The computer program code includes computer instructions, which, when executed by the processor 1010, cause the electronic device to execute the relevant method steps in the embodiments of the present application.
[0209] The processor 1010 can be a processor or a controller. For example, it can be a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the present disclosure. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on.
[0210] The bus 1040 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The above bus 1040 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 10It is represented only by a thick line, but it does not mean that there is only one bus or one type of bus.
[0211] An embodiment of the present application further provides an electronic device, which includes a memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the relevant method steps in the above method embodiment.
[0212] An embodiment of the present application further provides a communication device, which includes a memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the communication device executes the relevant method steps in the above method embodiment.
[0213] An embodiment of the present application further provides a computer-readable storage medium, in which computer program code is stored. When the above processor executes the computer program code, the electronic device executes the relevant method steps in the above method embodiment.
[0214] An embodiment of the present application further provides a computer program product, which contains instructions. When the instructions run on a computer or a processor, the computer or the processor executes the relevant method steps in the above method embodiment.
[0215] An embodiment of the present application further provides a chip system, including: a processor, the processor is coupled to a memory, and the memory is used to store programs or instructions. When the programs or instructions are executed by the processor, the chip system implements the method in any of the above method embodiments.
[0216] Optionally, the processor in the chip system can be one or more. The processor can be implemented by hardware or by software. When implemented by hardware, the processor can be a logic circuit, an integrated circuit, etc. When implemented by software, the processor can be a general-purpose processor, which is implemented by reading the software code stored in the memory.
[0217] Optionally, the memory in the chip system can also be one or more. The memory can be integrated with the processor or can be separately arranged from the processor, which is not limited in the embodiments of the present application. Exemplarily, the memory can be a non-transitory processor, such as a read-only memory ROM, which can be integrated with the processor on the same chip or can be separately arranged on different chips. The embodiments of the present application do not make specific limitations on the type of the memory and the setting manner of the memory and the processor.
[0218] Exemplarily, the chip system may be a field programmable gate array (FPGA), may be an application specific integrated circuit (ASIC), may also be a system on chip (SoC), may also be a central processing unit (CPU), may also be a network processor (NP), may also be a digital signal processing circuit (DSP), may also be a microcontroller unit (MCU), may also be a programmable logic device (PLD), or other integrated chips.
[0219] The electronic device, computer storage medium, or computer program product provided in this application is all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here.
[0220] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0221] In several embodiments provided in this application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0222] The unit described as a separated component may or may not be physically separated. The component displayed as a unit may be a physical unit or multiple physical units, and may be located in one place or distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0223] In addition, each functional unit in various embodiments of the present application may be integrated into one processing unit, may exist physically alone for each unit, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0224] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that makes a contribution, or all or part of the technical solution, may be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a device (which may be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods of the various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0225] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A resource control method, characterized in that: Applied to electronic equipment, the method comprises: Obtaining load information, where the load information is used to characterize resource usage corresponding to tasks in a first task group and a second task group, where the first task group includes real-time tasks corresponding to applications currently interacting with a user, where a first resource threshold corresponding to the first task group is greater than a second resource threshold corresponding to the second task group, and where the resource threshold is a time slice threshold corresponding to a CPU core time slice; When the load information satisfies a first condition, a first resource threshold corresponding to the first task group is adjusted to a third resource threshold, and a second resource threshold corresponding to the second task group is adjusted to a fourth resource threshold.
2. The method according to claim 1, characterized in that: When the load information satisfies the first condition, adjusting the first resource threshold to a third resource threshold and adjusting the second resource threshold to a fourth resource threshold includes: When, in the load information, the resource usage of the first task group is greater than the first resource threshold, and the resource usage of the second task group is less than the second resource threshold within N consecutive preset cycles, the first resource threshold is increased according to a first ratio to obtain the third resource threshold, and the second resource threshold is reduced according to the first ratio to obtain the fourth resource threshold; Alternatively, within N consecutive preset cycles, when the resource usage of the first task group is less than the first resource threshold, and the resource usage of the second task group is greater than the second resource threshold, the first resource threshold is reduced according to the second ratio to obtain the third resource threshold, and the second resource threshold is increased according to the second ratio to obtain the fourth resource threshold; N is greater than 1.
3. The method according to claim 2, characterized in that The method further comprises: determining the first ratio according to a difference between the resource usage of the second task group and the second resource threshold; The second ratio is determined according to a difference between the resource usage of the first task group and the first resource threshold.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: At every preset period, when the resource usage of the first task group in the load information is greater than the first resource threshold, the execution of at least one unexecuted task in the first task group is suspended; and / or, when the resource usage of the second task group is greater than the second resource threshold, the execution of at least one unexecuted task in the second task group is suspended.
5. The method according to claim 1, characterized in that When the load information satisfies the first condition, adjusting the first resource threshold to a third resource threshold and adjusting the second resource threshold to a fourth resource threshold includes: When N preset cycles are accumulated within a preset time period, and the resource usage of the first task group in the load information is greater than the first resource threshold, and the resource usage of the second task group is less than the second resource threshold, the first resource threshold is increased according to a first ratio to obtain the third resource threshold, and the second resource threshold is reduced according to the first ratio to obtain the fourth resource threshold; Alternatively, when the resource usage of the first task group is less than the first resource threshold and the resource usage of the second task group is greater than the second resource threshold for N preset cycles accumulated within the preset time period, the first resource threshold is reduced according to the second ratio to obtain the third resource threshold, and the second resource threshold is increased according to the second ratio to obtain the fourth resource threshold; N is greater than 1.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Dividing the first task group and the second task group according to task attributes of the tasks corresponding to the application, wherein the task attributes are used to characterize the delay requirements corresponding to the tasks; Get the running task corresponding to the currently started application; According to the task attribute corresponding to the running task, the running task is added to the first task group and the second task group.
7. The method according to any one of claims 1 to 6, characterized in that: The electronic device includes a plurality of the second task groups, and adjusting the first resource threshold corresponding to the first task group to a third resource threshold, and adjusting the second resource threshold corresponding to the second task group to a fourth resource threshold, comprises: Within N consecutive preset cycles, among the first task group and multiple second task groups, when there is a first target task group whose resource usage is greater than its corresponding resource threshold, and a second target task group whose resource usage is less than its corresponding resource threshold, the resource threshold of the first target task group is increased according to a third ratio, and the resource threshold of the second target task group is reduced according to the third ratio.
8. The method according to any one of claims 1 to 7, characterized in that: The first task group includes a first subtask group and a second subtask group, the first subtask group corresponds to a first sub-resource threshold, and the second subtask group corresponds to a second sub-resource threshold; The acquiring of load information includes: Acquire load information of the first subtask group and load information of the second subtask group; The method further comprises: When the load information of the first subtask group and the load information of the second subtask group meet a second condition, the first sub-resource threshold corresponding to the first subtask group is adjusted to a third sub-resource threshold, and the second sub-resource threshold corresponding to the second subtask group is adjusted to a fourth sub-resource threshold.
9. The method according to claim 8, characterized in that When the load information of the first subtask group and the load information of the second subtask group meet the second condition, adjusting the first sub-resource threshold corresponding to the first subtask group to the third sub-resource threshold, and adjusting the second sub-resource threshold corresponding to the second subtask group to the fourth sub-resource threshold, includes: Within N consecutive preset cycles, in the first subtask group and the second subtask group, when the resource usage of the third target task group is greater than its corresponding resource threshold, and the resource usage of the fourth target task group is less than its corresponding resource threshold, the resource threshold of the third target task group is increased according to a fourth ratio, and the resource threshold of the fourth target task group is reduced according to the fourth ratio.
10. The method according to claim 7, characterized in that The task is a process or a thread, the first task group includes real-time tasks corresponding to the application currently interacting with the user, one task group in the first task group includes foreground tasks running in the foreground of the electronic device, and one task group in the second task group includes background tasks running in the background of the electronic device.
11. The method according to claim 10, characterized in that The second resource threshold corresponding to the second task group including the foreground task is greater than the second resource threshold corresponding to the second task group including the background task.
12. The method according to claim 6, characterized in that The adding the running task to the first task group and the second task group includes: The running tasks are arranged in ascending order according to the task identifiers of the running tasks, and are added to the first task group and the second task group.
13. A resource control device, characterized in that: The resource control device includes a parameter configuration module, a statistical module, a policy management module and a dynamic adjustment module; The parameter configuration module is configured to configure a first resource threshold corresponding to a first task group and a second resource threshold corresponding to a second task group; the first task group includes real-time tasks corresponding to an application currently interacting with a user, the first resource threshold corresponding to the first task group is greater than the second resource threshold corresponding to the second task group, and the resource threshold is a time slice threshold corresponding to a CPU core time slice; The statistical module is configured to obtain load information, where the load information is used to characterize resource usage corresponding to tasks in the first task group and the second task group; The policy control module is configured to determine whether the load information satisfies a first condition; The dynamic adjustment module is configured to adjust the first resource threshold corresponding to the first task group to a third resource threshold, and adjust the second resource threshold corresponding to the second task group to a fourth resource threshold when the load information meets the first condition.
14. An electronic device, characterized in that: The electronic device includes a memory and one or more processors; the memory is coupled to the processor; wherein computer program code is stored in the memory, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-12.
15. A computer readable medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 12.
16. A computer program product, characterized in that The computer program product includes instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Method and module of performance threshold value setting
CN102317900A
Resource dynamic adjustment method and device, equipment and storage medium
CN110502340A
Elastic scheduling method and system for cluster resources, electronic equipment and storage medium
CN117632414A
Task scheduling method and related equipment
CN117666755A
Resource management and control method and device, chip, electronic equipment and medium
CN117931418A