Resource allocation method and apparatus
Patent Information
- Application Number
- CN202211328407.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-27
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2042-10-27
AI Technical Summary
[0005]本申请实施例的目的是提供一种资源分配方法及其装置,能够解决CPU资源无法进行实时分配的问题
[0018]在本申请实施例中,首先获取目标拍摄场景下每个目标模块的算力占比,然后基于每个目标模块的算力占比确定每个目标模块所在控制组的调度阈值,基于每个控制组的调度阈值为对应控制组分配目标CPU资源,实现了不同拍照场景下每个控制组的CPU资源的实时分配。
Smart Images

Figure CN115686786B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communication technology, and specifically relates to a resource allocation method and apparatus. Background Technology
[0002] To meet consumers' ever-increasing demands for imaging capabilities, imaging technology in smartphones and other electronic devices has been developing rapidly in recent years. From large-sensor cameras, multi-camera setups, and micro-gimbals to image signal processor (ISP) algorithms, the computational demands on each module of the System on a Chip (SOC) are increasing. While significantly improving photo quality, this has inevitably introduced performance bottlenecks. In particular, the Central Processing Unit (CPU), as an important sub-module of the SOC, is severely overloaded. Therefore, it is necessary to optimize CPU resource scheduling.
[0003] In related technologies, a control group (cgroup) mechanism is introduced. Figure 1 One of the schematic diagrams of the control group mechanism, such as Figure 1 As shown, place the camera module in the foreground group or a custom control group, other background applications in the background group, and system services in the system group, and allocate CPU resources proportionally according to the shares value (score) of each group; Figure 2 This is the second schematic diagram of the control group mechanism, as shown below. Figure 2 As shown, the five threads within the dashed box 101 are the threads corresponding to the camera module, and the threads within the dotted-line box 102 are the threads of the root cgroup. The weights of the five threads of the camera module are 1:2:1:2:1, with 3 / 7 of the threads executing on CPU0 and 4 / 7 of the threads executing on CPU1. Figure 1It can be seen that on CPU0, the two threads running the camera module and the root cgroup thread have a share value of 1024*3 / 7 = 439, and the root cgroup thread has a share value of 1024. Therefore, the CPU resources allocated to the camera module on CPU0 are: 439 / (1024+439) = 30%, and the resources allocated to the root cgroup thread on CPU0 are: 1-30% = 70%. On CPU1, the three threads running the camera module, as well as root cgroup thread 1 and root cgroup thread 2 have a share value of 1024*4 / 7 = 585, the share value of root cgroup thread 1 is 1024, and the share value of root cgroup thread 2 is 512. Therefore, the CPU resources allocated to the camera module on CPU1 are: 585 / (1024+585+512) = 28%. The resources allocated to thread 1 in cgroup are: 1024 / (1024+585+512) = 48%; the resources allocated to thread 2 in the root cgroup on CPU1 are: 512 / (1024+585+512) = 24%, thus realizing the allocation of CPU resources according to the proportion of shares value of each group.
[0004] However, in the aforementioned technologies, CPU resources cannot be allocated in real time when the CPU frequency is limited due to high temperatures or when background applications in the background group occupy fluctuating CPU resources. Summary of the Invention
[0005] The purpose of this application is to provide a resource allocation method and apparatus that can solve the problem of CPU resources not being allocated in real time.
[0006] In a first aspect, embodiments of this application provide a resource allocation method, the method comprising:
[0007] Obtain the computing power percentage of at least one target module in the target shooting scene;
[0008] Based on the computing power ratio of each target module, the scheduling threshold of the control group to which each target module belongs is determined;
[0009] Target CPU resources are allocated to the corresponding control group based on the scheduling threshold of each control group.
[0010] Secondly, embodiments of this application provide a resource allocation device, including:
[0011] The acquisition module is used to acquire the computing power percentage of at least one target module in the target shooting scene;
[0012] The determination module is used to determine the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module;
[0013] The allocation module is used to allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group.
[0014] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0015] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0016] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.
[0017] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.
[0018] In this embodiment, the computing power ratio of each target module in the target shooting scene is first obtained, and then the scheduling threshold of the control group to which each target module belongs is determined based on the computing power ratio of each target module. Based on the scheduling threshold of each control group, target CPU resources are allocated to the corresponding control group, thereby realizing the real-time allocation of CPU resources of each control group in different shooting scenes. Attached Figure Description
[0019] Figure 1 This is one of the schematic diagrams of the control group mechanism in the prior art;
[0020] Figure 2 This is the second schematic diagram of the control group mechanism in the prior art;
[0021] Figure 3 This is one of the flowcharts illustrating the resource allocation method provided in the embodiments of this application;
[0022] Figure 4 This is a schematic diagram of the computing power model corresponding to the portrait photography scene provided in the embodiments of this application;
[0023] Figure 5 This is a second flowchart illustrating the resource allocation method provided in the embodiments of this application;
[0024] Figure 6 This is the third flowchart illustrating the resource allocation method provided in the embodiments of this application;
[0025] Figure 7 This is a schematic diagram of the resource allocation framework provided in the embodiments of this application;
[0026] Figure 8 This is a schematic diagram of the structure of the resource allocation device provided in the embodiments of this application;
[0027] Figure 9 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;
[0028] Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0030] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0031] The resource allocation method, resource allocation device, electronic device, and readable storage medium provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0032] Figure 3 This is one of the flowcharts illustrating the resource allocation method provided in the embodiments of this application, such as... Figure 3 As shown, the resource allocation method includes the following steps 301, 302, and 303:
[0033] Step 301: Obtain the computing power ratio of at least one target module in the target shooting scene.
[0034] The shooting scenarios of the electronic device include portrait photography, professional photography, ordinary photography, night scene photography, and video recording. The at least one target module includes a shooting module, an image preview module, a system service module, and a background module, and the shooting module, the image preview module, the system service module, and the background module are located in different control groups.
[0035] For example, a corresponding computing power model is pre-designed for each shooting scenario, and the shooting scenarios and computing power models are stored in correspondence. The computing power model is used to indicate the computing power ratio of each target module. Figure 4 This is a schematic diagram of the computing power model corresponding to the portrait photography scene provided in the embodiments of this application, such as... Figure 4 As shown, in a portrait photography scenario, the computing power of the shooting module 301 can account for 30%, the computing power of the image preview module 302 can account for 30%, the computing power of the system service module 303 can account for 30%, and the computing power of the background module 304 can account for 10%. Therefore, when the target shooting scene is identified, the computing power model corresponding to the target shooting scene can be obtained, which means the computing power percentage of each target module in the target shooting scene can be obtained.
[0036] Step 302: Based on the computing power ratio of each target module, determine the scheduling threshold of the control group to which each target module belongs.
[0037] For example, when obtaining the computing power percentage of each target module in the target shooting scene, the scheduling threshold of the control group to which the target module belongs is determined based on the computing power percentage of the target module. For instance, by default, the control group to which the shooting module belongs, the control group to which the image preview module belongs, the control group to which the system service module belongs, and the control group to which the background module belongs all share CPU resources, that is, the computing power percentage of the four control groups is 25% each, and the scheduling threshold of the four control groups, that is, the shares value, is 1024 by default. Taking the target shooting scene as a portrait photography scene as an example, from the computing power model corresponding to the portrait photography scene, we can know that... If the computing power of the shooting module accounts for 30%, then the scheduling threshold of the control group where the shooting module is located is 1024*30% / 25%≈1228; if the computing power of the image preview module accounts for 30%, then the scheduling threshold of the control group where the image preview module is located is 1024*30% / 25%≈1228; if the computing power of the background module accounts for 10%, then the scheduling threshold of the control group where the background module is located is 1024*10% / 25%=496; if the computing power of the system service module accounts for 30%, then the scheduling threshold of the control group where the system service module is located is 1024*30% / 25%≈1228.
[0038] It should be noted that the above method for calculating the scheduling threshold of the control group to which the target module belongs based on the computing power ratio of the target module is only an example. In practice, it can be dynamically calculated based on CPU temperature rise frequency limiting, CPU load, or more control groups. This invention will not elaborate further here.
[0039] Step 303: Allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group.
[0040] For example, when the scheduling threshold of the control group where each target module is located in the target shooting scene is obtained, target CPU resources are allocated to the corresponding control group based on each scheduling threshold; for example, if the scheduling threshold of the control group where the shooting module is located is 1228, then 30% of the CPU resources are allocated to the control group where the shooting module is located.
[0041] The resource allocation method provided in this application first obtains the computing power ratio of each target module in the target shooting scene, then determines the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module, and allocates target CPU resources to the corresponding control group based on the scheduling threshold of each control group, thereby realizing the real-time allocation of CPU resources of each control group in different shooting scenes.
[0042] In one embodiment, Figure 5 This is a second schematic flowchart of the resource allocation method provided in the embodiments of this application, such as... Figure 5 As shown, step 303 above can be implemented through the following steps:
[0043] Step 3031: If the CPU temperature is determined to be greater than or equal to the preset temperature, adjust the scheduling threshold of the corresponding control group based on the priority of each target module.
[0044] The preset temperature can be set according to needs, such as a preset temperature of 50 degrees.
[0045] For example, the remaining CPU resources are related to the CPU temperature. When the CPU temperature is high, the remaining CPU resources will decrease to ensure normal CPU operation; when the CPU temperature is low, the remaining CPU resources will increase. Therefore, when obtaining the scheduling threshold of the control group to which the corresponding target module belongs based on the computing power ratio of each target module, the CPU temperature can be further obtained. If the CPU temperature is determined to be greater than or equal to the preset temperature, since the remaining CPU resources decrease, the scheduling threshold of at least one control group needs to be lowered to reduce the allocation of CPU resources to the control group with the lowered scheduling threshold, so that the remaining CPU resources match the actual CPU resources required by each control group. Specifically, a priority can be set for each control group first, and the control group with the highest priority will start lowering the corresponding scheduling threshold first. For example, if the priority of the background module is higher than that of the shooting module, and the priority of the shooting module is higher than that of the image preview module and the system service module, then the scheduling threshold of the control group to which the background module belongs can be lowered first.
[0046] Step 3032: Allocate target CPU resources to the corresponding control group based on the adjusted scheduling threshold of each control group.
[0047] For example, after adjusting the scheduling threshold of a control group, target CPU resources can be allocated to the corresponding control group based on the adjusted scheduling threshold of each control group; it is understood that if only the scheduling threshold of one control group is adjusted, the scheduling thresholds of other control groups will remain the previous scheduling thresholds.
[0048] The resource allocation method provided in this application, when obtaining the scheduling threshold of the control group to which the corresponding target module belongs based on the computing power ratio of each target module, can further adjust the scheduling threshold of the relevant control group based on the CPU temperature and the priority of each target module, thereby realizing the dynamic real-time adjustment of the scheduling threshold and making the allocation of remaining CPU resources more reasonable.
[0049] In one embodiment, the target module includes a shooting module and a background module; step 3031 above can be implemented in the following ways:
[0050] Acquire the first CPU resources required by all control groups;
[0051] If it is determined that the first CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the background module is located is reduced based on a first preset ratio, and the second CPU resource required by all control groups is reacquired; the remaining CPU resource is the available CPU resource corresponding to the CPU temperature.
[0052] If it is determined that the second CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group to which the shooting module is located is reduced based on the second preset ratio.
[0053] The specific values of the first preset ratio and the second preset ratio can be set according to the requirements, for example, both the first preset ratio and the second preset ratio can be 80%.
[0054] For example, if the CPU temperature is determined to be greater than or equal to a preset temperature, in order to ensure that the CPU can work normally, it is necessary to reduce the total CPU resources to obtain the remaining CPU resources. Therefore, if the CPU temperature is determined to be greater than or equal to the preset temperature, firstly, the CPU resources required by each control group are obtained. Then, the sum of the CPU resources required by each control group is taken as the first CPU resources required by all control groups. The first CPU resources required by all control groups are compared with the remaining CPU resources. If it is determined that the first CPU resources required by all control groups are greater than the remaining CPU resources, it means that the remaining CPU resources cannot meet the needs of each control group. At this time, in the shooting scenario, in order to ensure the performance of the shooting function, the scheduling threshold of the control group where the background module is located can be reduced first based on a first preset ratio, thus reducing the CPU resources allocated to the control group where the background module is located. Then, the second CPU resources required by all control groups are obtained. If the second CPU resources required by all control groups are still greater than the remaining CPU resources, the scheduling threshold of the control group where the shooting module is located is reduced again based on a second preset ratio, prioritizing the CPU resources of the control group where the image preview module is located and the control group where the system service module is located. For example, assuming the total CPU resources are t and the CPU resources required by all control groups are c, then the CPU load is c / t. When the CPU temperature is greater than or equal to the preset temperature, the total CPU resources t decrease, resulting in a higher CPU load. At this time, the scheduling threshold of the control group where the background module is located is lowered first, thus reducing the CPU resources allocated to the control group where the background module is located.
[0055] The resource allocation method provided in this application embodiment can prioritize reducing the scheduling threshold of the control group where the background module is located when it is determined that the first CPU resources required by all control groups are greater than the remaining CPU resources. If the second CPU resources required by all newly acquired control groups are still greater than the remaining CPU resources, the scheduling threshold of the control group where the shooting module is located will be further reduced to prioritize ensuring the CPU resources of the control group where the image preview module is located and the control group where the system service module is located, so as to ensure that the image preview is smooth and does not lag during shooting.
[0056] In one embodiment, Figure 6 This is the third flowchart illustrating the resource allocation method provided in the embodiments of this application, as shown below. Figure 6 As shown, step 303 above can be implemented through the following steps:
[0057] Step 3033: If the first load of the CPU is determined to be greater than the preset percentage, adjust the scheduling threshold of the corresponding control group based on the priority of each target module.
[0058] The specific value of the preset percentage can be set based on the needs, such as a preset percentage of 100%.
[0059] For example, when obtaining the scheduling threshold of the control group to which the corresponding target module belongs based on the computing power ratio of each target module, the first load of the CPU can be further obtained. If the first load of the CPU is greater than or equal to the preset ratio, it indicates that the load is excessive. For example, assuming the total CPU resources are t and the CPU resources required by all control groups are c, the CPU load is c / t. When the number of tasks in the control group increases, the CPU resources c increase, resulting in a higher CPU load.
[0060] When the CPU load increases, the scheduling threshold of at least one control group needs to be lowered to reduce the allocation of CPU resources to the control group whose scheduling threshold has been lowered, so that the CPU load is less than or equal to a preset percentage. Specifically, a priority can be set for each control group first, and the control group with the highest priority will start lowering its corresponding scheduling threshold first. For example, if the priority of the background module is higher than that of the shooting module, and the priority of the shooting module is higher than that of the image preview module and the system service module, then the scheduling threshold of the control group where the background module is located can be lowered first.
[0061] Step 3034: Allocate target CPU resources to the corresponding control group based on the adjusted scheduling threshold for each control group.
[0062] For example, after adjusting the scheduling threshold of a control group, target CPU resources can be allocated to the corresponding control group based on the adjusted scheduling threshold of each control group; it is understood that if only the scheduling threshold of one control group is adjusted, the scheduling thresholds of other control groups will remain the previous scheduling thresholds.
[0063] The resource allocation method provided in this application, when obtaining the scheduling threshold of the control group to which the corresponding target module belongs based on the computing power ratio of each target module, can further adjust the scheduling threshold of the relevant control group based on the first load of the CPU and the priority of each target module, thereby realizing the dynamic real-time adjustment of the scheduling threshold and making the allocation of remaining CPU resources more reasonable.
[0064] In one embodiment, the target module includes a shooting module and a background module; step 3033 above can be implemented in the following ways:
[0065] The scheduling threshold of the control group where the background module is located is reduced based on the third preset ratio, and the second load of the CPU is reacquired.
[0066] If the second load of the CPU is determined to be greater than the preset percentage, the scheduling threshold of the control group to which the shooting module is located is reduced based on the fourth preset percentage.
[0067] The specific values of the third and fourth preset ratios can be set according to requirements, for example, both the third and fourth preset ratios can be 80%.
[0068] For example, if the CPU's first load is determined to be greater than a preset percentage, it indicates excessive load. In this case, during the shooting scenario, to ensure the performance of the shooting function, the scheduling threshold of the control group containing the background module can be reduced based on a third preset percentage. This reduces the CPU resources allocated to the control group containing the background module, thus reducing the resources occupied by tasks within that control group and increasing the time required for task completion, thereby reducing the CPU load per unit time. Then, the CPU's second load is obtained. If the second CPU load is still greater than a preset percentage, the scheduling threshold of the control group containing the shooting module is further reduced based on a fourth preset percentage. This reduces the CPU resources allocated to the control group containing the shooting module, further reducing the resources occupied by tasks within that control group and increasing the time required for task completion, thus further reducing the CPU load per unit time. This prioritizes ensuring CPU resources for the control groups containing the image preview module and the system service module. Taking the background module running instant messaging software 1 and instant messaging software 2, and the foreground module running a portrait photography scene as an example, when instant messaging software 1 and instant messaging software 2 are running in the background, 30% of the CPU computing power resources can be allocated to the control group where the shooting module is located, 30% of the CPU computing power resources can be allocated to the control group where the image preview module is located, and 10% of the CPU computing power resources can be allocated to the control group where the background module is located. When no application is running in the background, 40% of the CPU computing power resources can be allocated to the control group where the shooting module is located, and 30% of the CPU computing power resources can be allocated to the control group where the image preview module is located. The 30% CPU computing power resources can ensure smooth preview. When no application is running in the background, more CPU computing power resources can be allocated to the control group where the shooting module is located, so that the image can be completed faster.
[0069] The resource allocation method provided in this application embodiment can prioritize reducing the scheduling threshold of the control group where the background module is located when the first CPU load is determined to be greater than the preset percentage. If the second CPU load that is re-acquired is still greater than the preset percentage, the scheduling threshold of the control group where the shooting module is located will be further reduced to prioritize the CPU resources of the control group where the image preview module is located and the control group where the system service module is located, so as to ensure that the shooting module can take pictures or record videos quickly.
[0070] For example, Figure 7 This is a schematic diagram of the resource allocation framework provided in the embodiments of this application, such as... Figure 7 As shown, the resource allocation framework includes Energy Aware Scheduling (EAS) 701, small core clusters 702, large core clusters 703, super-large core clusters 704, cgroup mechanism 705, and camera dynamic performance framework 706. Among them, EAS scheduling 701 is used to control the output of actual CPU resources based on CPU temperature rise power consumption strategy, and allocate CPU resources to small core clusters 702, large core clusters 703, and super-large core clusters 704. The cgroup mechanism 705 can specifically divide the shooting module into camera-snap group 707, the image preview module into camera-preview group 708, the system service module into system group 709, and the background module into background group 710. The camera dynamic performance framework 706 allocates corresponding CPU resources to each control group based on CPU temperature and CPU load.
[0071] It should be noted that this application does not limit the number of control groups, and in practical applications, other control groups may also be included.
[0072] The resource allocation method provided in this application can be executed by a resource allocation device. This application uses the example of a resource allocation device executing the resource allocation method to illustrate the resource allocation device provided in this application.
[0073] Figure 8 This is a schematic diagram of the structure of the resource allocation device provided in the embodiments of this application, as shown below. Figure 8 As shown, the resource allocation device 800 includes an acquisition module 801, a determination module 802, and an allocation module 803; wherein:
[0074] The acquisition module 801 is used to acquire the computing power ratio of at least one target module in the target shooting scene;
[0075] The determining module 802 is used to determine the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module;
[0076] The allocation module 803 is used to allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group.
[0077] The resource allocation device provided in this application first obtains the computing power ratio of each target module in the target shooting scene, then determines the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module, and allocates target CPU resources to the corresponding control group based on the scheduling threshold of each control group, thereby realizing the real-time allocation of CPU resources of each control group in different shooting scenes.
[0078] Optionally, the allocation module 803 is further configured to:
[0079] If the CPU temperature is determined to be greater than or equal to the preset temperature, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module.
[0080] Target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
[0081] Optionally, the target module includes a shooting module and a background module; the allocation module 803 is further configured to:
[0082] Acquire the first CPU resources required by all control groups;
[0083] If it is determined that the first CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the background module is located is reduced based on a first preset ratio, and the second CPU resource required by all control groups is reacquired; the remaining CPU resource is the available CPU resource corresponding to the CPU temperature.
[0084] If it is determined that the second CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group to which the shooting module is located is reduced based on the second preset ratio.
[0085] Optionally, the allocation module 803 is further configured to:
[0086] If the initial CPU load is determined to be greater than a preset percentage, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module.
[0087] Target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
[0088] Optionally, the target module includes a shooting module and a background module; the allocation module 803 is further configured to:
[0089] The scheduling threshold of the control group where the background module is located is reduced based on the third preset ratio, and the second load of the CPU is reacquired.
[0090] If the second load of the CPU is determined to be greater than the preset percentage, the scheduling threshold of the control group to which the shooting module is located is reduced based on the fourth preset percentage.
[0091] The resource allocation device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.
[0092] The resource allocation device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0093] The resource allocation device provided in this application embodiment can achieve... Figures 1 to 7 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0094] Optionally, such as Figure 9 As shown, this application embodiment also provides an electronic device 900, including a processor 901 and a memory 902. The memory 902 stores a program or instructions that can run on the processor 901. When the program or instructions are executed by the processor 901, they implement the various steps of the above-described resource allocation method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0095] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0096] Figure 10 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.
[0097] The electronic device 1000 includes, but is not limited to, components such as: radio frequency unit 1001, network module 1002, audio output unit 1003, input unit 1004, sensor 1005, display unit 1006, user input unit 1007, interface unit 1008, memory 1009, and processor 1010.
[0098] Those skilled in the art will understand that the electronic device 1000 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 1010 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 10 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0099] Among them, the processor 1010 is used to obtain the computing power ratio of at least one target module in the target shooting scene;
[0100] The processor 1010 is also configured to determine the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module;
[0101] The processor 1010 is also used to allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group.
[0102] In the above implementation, the computing power ratio of each target module in the target shooting scene is first obtained, and then the scheduling threshold of the control group to which each target module belongs is determined based on the computing power ratio of each target module. Based on the scheduling threshold of each control group, target CPU resources are allocated to the corresponding control group, thereby realizing the real-time allocation of CPU resources of each control group in different shooting scenes.
[0103] Optionally, the at least one target module includes a shooting module, an image preview module, a system service module, and a background module, and the shooting module, the image preview module, the system service module, and the background module are located in different control groups.
[0104] Optionally, the processor 1010 is further configured to adjust the scheduling threshold of the corresponding control group based on the priority of each target module when it is determined that the temperature of the CPU is greater than or equal to a preset temperature.
[0105] Target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
[0106] In the above implementation, when the scheduling threshold of the control group to which the corresponding target module belongs is obtained based on the computing power ratio of each target module, the scheduling threshold of the relevant control group can be further adjusted based on the CPU temperature and the priority of each target module, thereby realizing the dynamic real-time adjustment of the scheduling threshold and making the allocation of the remaining CPU resources more reasonable.
[0107] Optionally, the target module includes a shooting module and a background module; the processor 1010 is also used to acquire the first CPU resources required by all control groups;
[0108] If it is determined that the first CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the background module is located is reduced based on a first preset ratio, and the second CPU resource required by all control groups is reacquired; the remaining CPU resource is the available CPU resource corresponding to the CPU temperature.
[0109] If it is determined that the second CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group to which the shooting module is located is reduced based on the second preset ratio.
[0110] In the above implementation, when it is determined that the first CPU resources required by all control groups are greater than the remaining CPU resources, the scheduling threshold of the control group where the background module is located can be reduced first. If the second CPU resources required by all newly acquired control groups are still greater than the remaining CPU resources, the scheduling threshold of the control group where the shooting module is located is further reduced. Priority is given to ensuring the CPU resources of the control group where the image preview module is located and the control group where the system service module is located, so as to ensure that the image preview is smooth and does not lag during the shooting.
[0111] Optionally, the processor 1010 is further configured to adjust the scheduling threshold of the corresponding control group based on the priority of each target module when it is determined that the first load of the CPU is greater than a preset percentage.
[0112] Target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
[0113] In the above implementation, when the scheduling threshold of the control group to which the corresponding target module belongs is obtained based on the computing power ratio of each target module, the scheduling threshold of the relevant control group can be further adjusted based on the first load of the CPU and the priority of each target module, thereby realizing the dynamic real-time adjustment of the scheduling threshold and making the allocation of the remaining CPU resources more reasonable.
[0114] Optionally, the target module includes a shooting module and a background module; the processor 1010 is further configured to reduce the scheduling threshold of the control group to which the background module is located based on a third preset ratio, and to reacquire the second load of the CPU;
[0115] If the second load of the CPU is determined to be greater than the preset percentage, the scheduling threshold of the control group to which the shooting module is located is reduced based on the fourth preset percentage.
[0116] In the above implementation, when the first CPU load is determined to be greater than the preset percentage, the scheduling threshold of the control group where the background module is located can be reduced first. If the second CPU load that is reacquired is still greater than the preset percentage, the scheduling threshold of the control group where the shooting module is located will be reduced again. Priority will be given to ensuring the CPU resources of the control group where the image preview module is located and the control group where the system service module is located, so as to ensure that the shooting module can take pictures or record videos quickly.
[0117] It should be understood that, in this embodiment, the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042. The GPU 10041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 1006 may include a display panel 10061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
[0118] The memory 1009 can be used to store software programs and various data. The memory 1009 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 1009 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 1009 in this embodiment includes, but is not limited to, these and any other suitable types of memory.
[0119] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into the processor 1010.
[0120] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described resource allocation method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0121] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0122] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above resource allocation method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0123] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0124] This application provides a computer program product that is stored in a storage medium and executed by at least one processor to implement the various processes of the resource allocation method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0125] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0127] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A resource allocation method, characterized in that, include: Obtain the computing power percentage of at least one target module in the target shooting scene; Based on the computing power ratio of each target module, the scheduling threshold of the control group to which each target module belongs is determined; Allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group; The allocation of target CPU resources to the corresponding control group based on the scheduling threshold of each control group includes: When the CPU temperature is greater than or equal to the preset temperature, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module. The target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold of each control group. The target module includes a shooting module, a background module, an image preview module, and a system service module; adjusting the scheduling threshold of the corresponding control group based on the priority of each target module includes: Acquire the first CPU resources required by all control groups; If it is determined that the first CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the background module is located is reduced based on a first preset ratio, and the second CPU resource required by all control groups is reacquired; the remaining CPU resource is the available CPU resource corresponding to the CPU temperature. If it is determined that the second CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the shooting module is located is reduced based on the second preset ratio to ensure the CPU resources of the control group where the image preview module is located and the control group where the system service module is located.
2. The resource allocation method according to claim 1, characterized in that, The allocation of target CPU resources to the corresponding control group based on the scheduling threshold of each control group also includes: If the initial CPU load is determined to be greater than a preset percentage, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module. The target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
3. The resource allocation method according to claim 2, characterized in that, The step of adjusting the scheduling threshold of the corresponding control group based on the priority of each target module includes: The scheduling threshold of the control group where the background module is located is reduced based on the third preset ratio, and the second load of the CPU is reacquired. If the second load of the CPU is determined to be greater than the preset percentage, the scheduling threshold of the control group to which the shooting module is located is reduced based on the fourth preset percentage.
4. A resource allocation device, characterized in that, include: The acquisition module is used to acquire the computing power percentage of at least one target module in the target shooting scene; The determination module is used to determine the scheduling threshold of the control group to which each target module belongs based on the computing power ratio of each target module; The allocation module is used to allocate target CPU resources to the corresponding control group based on the scheduling threshold of each control group. The allocation module is also used for: If the CPU temperature is determined to be greater than or equal to the preset temperature, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module. The target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold of each control group. The target module includes a shooting module, a background module, an image preview module, and a system service module; the allocation module is also used for: Acquire the first CPU resources required by all control groups; If it is determined that the first CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the background module is located is reduced based on a first preset ratio, and the second CPU resource required by all control groups is reacquired; the remaining CPU resource is the available CPU resource corresponding to the CPU temperature. If it is determined that the second CPU resource is greater than the remaining CPU resource, the scheduling threshold of the control group where the shooting module is located is reduced based on the second preset ratio to ensure the CPU resources of the control group where the image preview module is located and the control group where the system service module is located.
5. The resource allocation device according to claim 4, characterized in that, The allocation module is also used for: If the initial CPU load is determined to be greater than a preset percentage, the scheduling threshold of the corresponding control group is adjusted based on the priority of each target module. The target CPU resources are allocated to the corresponding control group based on the adjusted scheduling threshold for each control group.
6. The resource allocation device according to claim 5, characterized in that, The target module includes a shooting module and a background module; the allocation module is also used for: The scheduling threshold of the control group where the background module is located is reduced based on the third preset ratio, and the second load of the CPU is reacquired. If the second load of the CPU is determined to be greater than the preset percentage, the scheduling threshold of the control group to which the shooting module is located is reduced based on the fourth preset percentage.
Citation Information
Patent Citations
Control method and control device for application programs as well as storage medium and electronic equipment
CN107729216A
Resource allocation method, device and system
CN108965364A