CPU resource allocation method and device, storage medium and electronic equipment
By reading the core configuration information of the target application and adjusting the core allocation of multi-core CPUs in real time, the problems of over-performance of the foreground application and insufficient core of the background application are solved, and the smoothness and user experience of the terminal are improved.
Patent Information
- Application Number
- CN202310791588.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2024-12-31
AI Technical Summary
The core allocation method of existing multi-core CPUs results in overperformance of the core of the foreground application, while the core of the backend application is not enough to support the task operation, resulting in inefficiency.
By reading the target core configuration information related to the target application, adjusting the core allocation in real time according to the correspondence between different types of tasks, ensuring that critical tasks, perceived tasks and unaware tasks obtain appropriate core resources respectively.
It realizes more accurate core allocation, avoids the problems of over-performance or insufficient, and improves the smoothness and user experience of the terminal.
Smart Images

Figure CN119225947A_ABST
Abstract
Description
Technical Field
[0001] The technical solution disclosed herein relates to the field of terminal technology, and in particular to a CPU resource allocation method and device, a storage medium, and an electronic device. Background Art
[0002] Core, also known as kernel, is an important part of CPU (Central Processing Unit). Single-core CPU has only one core and can only process one task at a time. Multi-core CPU means that multiple cores are integrated in one physical chip, which can process multiple tasks at the same time.
[0003] In order to improve task processing efficiency, most terminals use multi-core CPUs. In existing implementations, multiple cores in a multi-core CPU are allocated based on the priorities of different applications. For example, most cores are allocated to foreground applications with higher priorities, and a small number of cores are allocated to background applications with lower priorities. This processing method has the problem that the cores allocated to foreground applications have excess performance, while the cores allocated to background applications with lower priorities are insufficient to support background tasks. Summary of the invention
[0004] In view of this, embodiments of the present disclosure provide a CPU resource allocation method and device, a storage medium, and an electronic device.
[0005] According to a first aspect of the present disclosure, a CPU resource allocation method is proposed, the method comprising:
[0006] In response to determining that the target application is running in the foreground, reading target core configuration information related to the target application; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground;
[0007] According to the corresponding relationship in the target core configuration information, corresponding cores are allocated to the at least two different types of tasks respectively, so as to obtain initial cores corresponding to each task respectively;
[0008] The cores currently required for the at least two different types of tasks are evaluated respectively to obtain evaluation results; the evaluation results include the type and / or number of cores currently required for each task;
[0009] According to the evaluation result, the type and / or quantity of the initial cores corresponding to each task are adjusted.
[0010] In combination with any embodiment provided in the present disclosure, each target type of task includes at least one subtask;
[0011] The evaluating the cores currently required for the at least two different types of tasks respectively includes:
[0012] For each task of the target type, summing the loads of all subtasks included in the task of the target type to obtain the total load of the task of the target type;
[0013] The core currently required for the task of the target type is determined according to the total load of the task of the target type and the maximum load corresponding to each core of the multiple cores.
[0014] In combination with any embodiment provided by the present disclosure, the at least two different types of tasks include at least part of the following:
[0015] Key tasks; the key tasks include tasks corresponding to the target application running in the foreground for processing terminal screen feedback;
[0016] Perceivable tasks; the perceivable tasks include other tasks corresponding to the target application running in the foreground except the key tasks, and user-perceivable tasks corresponding to the application running in the background;
[0017] Imperceptible tasks; the imperceptible tasks include other tasks corresponding to the application running in the background except the perceptible tasks.
[0018] In combination with any embodiment provided in the present disclosure, the plurality of cores include: a large core, a medium core and a small core; wherein the maximum load of the large core is greater than the maximum load of the medium core, and the maximum load of the medium core is greater than the maximum load of the small core;
[0019] The evaluating the cores currently required for the at least two different types of tasks respectively includes:
[0020] Determine the total load of the critical tasks, perceptible tasks and imperceptible tasks respectively;
[0021] Determine the number of medium cores and / or large cores required for the key task according to the relationship between the total load of the key task and the maximum load of the medium core and the maximum load of the large core;
[0022] Determining the number of small cores and / or medium cores required for the perceptible task according to the relationship between the total load of the perceptible task and the maximum load of the small core and the maximum load of the medium core;
[0023] The number of small cores required for the perceptible task is determined according to the relationship between the total load of the imperceptible task and the maximum load of the small core.
[0024] In combination with any of the embodiments provided in the present disclosure, adjusting the type and / or quantity of the initial cores corresponding to each task respectively according to the evaluation result includes:
[0025] If it is determined based on the evaluation result that the sum of the number of cores required for the critical task and the perceptible task is greater than the total number of cores, the cores are preferentially allocated to the critical task.
[0026] In combination with any of the embodiments provided in the present disclosure, the evaluating the cores currently required for the at least two different types of tasks respectively includes:
[0027] In response to determining that the terminal is in a performance acceleration mode, an evaluation result of the cores currently required by the critical task is the multiple cores; wherein the performance acceleration mode is used to accelerate the operation of the critical task.
[0028] In combination with any implementation manner provided in the present disclosure, in response to determining that the target application is running in the foreground, before reading the target core configuration information related to the target application, the method further includes:
[0029] Obtaining a shell temperature of the terminal;
[0030] It is determined that the shell temperature of the terminal is lower than or equal to a preset temperature threshold.
[0031] According to a second aspect of the present disclosure, a CPU resource allocation device is provided, the device comprising:
[0032] A reading module, configured to read target core configuration information related to the target application in response to determining that the target application is running in the foreground; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground;
[0033] An allocation module, configured to allocate corresponding cores to the at least two different types of tasks respectively according to the corresponding relationship in the target core configuration information, so as to obtain initial cores corresponding to each task respectively;
[0034] An evaluation module, used to evaluate the cores currently required for the at least two different types of tasks respectively, and obtain evaluation results; the evaluation results include the type and / or number of cores currently required for each task;
[0035] The adjustment module is used to adjust the type and / or quantity of the initial cores corresponding to each task according to the evaluation result.
[0036] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, wherein the machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the processor is prompted to implement the CPU resource allocation method of any embodiment of the present disclosure.
[0037] According to a fourth aspect of the present disclosure, there is provided an electronic device, comprising:
[0038] processor;
[0039] a memory for storing processor-executable instructions;
[0040] The processor is configured to execute the CPU resource allocation method of any embodiment of the present disclosure.
[0041] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0042] The CPU resource allocation method and device, storage medium and electronic device provided by the embodiments of the present disclosure can read the target core configuration information related to the target application when it is determined that the target application is running in the foreground, and allocate different cores to at least two different types of tasks based on the target core configuration information, so as to obtain the initial cores corresponding to each task. The target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground, and the target core configuration information is obtained by relevant staff based on experimental tests. Then, the initial cores corresponding to each task are further adjusted in real time based on the type and / or number of cores currently required for different types of tasks, so as to achieve more accurate core allocation and avoid the problem of excess core performance caused by unreasonable core allocation.
[0043] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0045] Figure 1 is a flow chart of a CPU resource allocation method according to an exemplary embodiment of the present disclosure;
[0046] Figure 2 is a schematic diagram of a core required for evaluating different types of tasks according to an exemplary embodiment of the present disclosure;
[0047] Figure 3is a structural schematic diagram of a CPU resource allocation device according to an exemplary embodiment of the present disclosure;
[0048] Figure 4 is a structural schematic diagram of another CPU resource allocation device according to an exemplary embodiment of the present disclosure;
[0049] Figure 5 It is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0050] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0051] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0052] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0053] With the upgrade of CPU architecture, the underlying capabilities of CPU are constantly improving and the performance is constantly improving. For example, the core of CPU has been upgraded from the original single core to the current multi-core, which can improve the processing efficiency of tasks to a certain extent.
[0054] In existing implementations, when allocating multiple cores in a multi-core CPU, the allocation is mostly based on the priorities of different applications. For example, most cores are allocated to foreground applications with higher priorities, and a small number of cores are allocated to background applications with lower priorities. This core allocation method has the problem that the cores allocated to foreground applications with higher priorities have excess performance, while the cores allocated to background applications with lower priorities are insufficient to support background tasks.
[0055] In view of this, the present disclosure provides a CPU resource allocation method, in which the allocation status of multiple cores can be adjusted in real time based on the cores currently required by different types of tasks, thereby achieving more accurate core allocation.
[0056] The CPU resource allocation method of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0057] Figure 1 FIG. 1 is a flowchart of a CPU resource allocation method according to an exemplary embodiment of the present disclosure. In a specific implementation, the method may be executed by a terminal, wherein a CPU of the terminal is integrated with multiple cores. Figure 1 As shown, the exemplary embodiment method may include the following steps:
[0058] In step 101, in response to determining that a target application is running in the foreground, target core configuration information related to the target application is read.
[0059] The target core configuration information is used to represent the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground.
[0060] Common multi-core CPUs include: dual-core CPUs, quad-core CPUs, hexa-core CPUs and octa-core CPUs. For the convenience of description, an octa-core CPU is used as an example to introduce the following embodiments. The current octa-core CPU usually includes: 3 small cores, 4 medium cores and 1 large core. Among them, the maximum load of the large core is greater than the maximum load of the medium core, and the maximum load of the medium core is greater than the maximum load of the small core.
[0061] In an optional example, the at least two different types of tasks may include: foreground tasks and background tasks. The foreground tasks include tasks corresponding to the application running in the foreground, and the background tasks include tasks corresponding to the application running in the background. In another optional example, the at least two different types of tasks may include at least part of the following: critical tasks, perceptible tasks, and imperceptible tasks. The critical tasks include tasks corresponding to the application running in the foreground for processing terminal screen feedback, such as tasks related to the UI thread. The perceptible tasks include other tasks corresponding to the target application running in the foreground except the critical tasks, and user-perceptible tasks corresponding to the application running in the background. The user-perceptible tasks corresponding to the application running in the background may include, for example, tasks using audio resources or positioning service resources. The imperceptible tasks include other tasks corresponding to the application running in the background except the perceptible tasks. In this example, the at least two different types of tasks including critical tasks, perceptible tasks, and imperceptible tasks are taken as an example to introduce the subsequent embodiments.
[0062] In an optional example, relevant staff can determine the core configuration information related to different applications when they are running in the foreground based on experimental tests. Table 1 below shows the correspondence between different cores and key tasks, perceptible tasks, and imperceptible tasks when WeChat or Alipay is running in the foreground.
[0063] Table 1
[0064]
[0065] In another optional example, the correspondence between different cores and key tasks, perceptible tasks, and imperceptible tasks can be further tested when different scenarios of the same application are running in the foreground. Table 2 below shows the correspondence between different cores and different tasks when the WeChat Moments scenario or payment scenario is running in the foreground.
[0066] Table 2
[0067]
[0068] In one optional example, when the terminal determines that WeChat is running in the foreground, the core configuration information related to WeChat can be read according to Table 1: key tasks: one large core, one medium core; perceptible tasks: two medium cores; imperceptible tasks: one small core. In another optional example, when the terminal determines that WeChat's friend scene is running in the foreground, the core configuration information related to WeChat's circle of friends scene can be read according to Table 2: key tasks: one large core, two medium cores; perceptible tasks: one medium core; imperceptible tasks: one small core. For the convenience of description, Table 1 is used as an example to introduce the subsequent embodiments.
[0069] In step 102, corresponding cores are allocated to the at least two different types of tasks according to the corresponding relationship in the target core configuration information, so as to obtain initial cores corresponding to each task.
[0070] As can be seen from the above, when WeChat runs in the foreground, the corresponding relationship in the target core configuration information read is: critical tasks: one large core and one medium core; perceptible tasks: two medium cores; imperceptible tasks: one small core.
[0071] In actual applications, after the terminal reads the above correspondence, it can further modify the CPU bitmap data so that the key tasks run on a large core and a medium core, the perceptible tasks run on two medium cores, and the imperceptible tasks run on a small core.
[0072] In step 103, the cores currently required by the at least two different types of tasks are evaluated respectively to obtain evaluation results.
[0073] The evaluation result includes the type and / or quantity of cores currently required for each task.
[0074] In this example, the cores currently required for the critical tasks, perceptible tasks, and imperceptible tasks are evaluated respectively, and the evaluation results are obtained. It should be noted that in order to ensure the smooth operation of each task, large cores and medium cores are generally allocated to critical tasks, medium cores and small cores are allocated to perceptible tasks, and small cores are allocated to imperceptible tasks. The large core, medium core, and small core are the types of the core.
[0075] Take the evaluation of the cores currently required for the critical tasks as an example:
[0076] As can be seen above, the key task includes all subtasks for processing terminal screen feedback corresponding to the application running in the foreground. Therefore, the loads of all the subtasks can be summed up first to obtain the total load of the key task. Then, according to the total load of the key task and the maximum load corresponding to each core in the multiple cores, the core currently required by the key task is determined.
[0077] For example, the total load of the determined critical task is 100, the maximum load of the large core is 80, and the maximum load of the medium core is 40. Then, the cores currently required for the critical task are one large core and one medium core.
[0078] It should be noted that in order to ensure the smoothness of task operation, the above-mentioned maximum load does not refer to the theoretical maximum computing power of the core, but the value corresponding to a certain proportion of the maximum computing power. For example, it can be 75% of the maximum computing power, or 80% of the maximum computing power. The specific setting can be made by relevant staff based on actual conditions, and this disclosure does not limit this.
[0079] The process of evaluating the cores currently required by the perceptible task and the imperceptible task is the same as the process of evaluating the cores currently required by the critical task, and will not be repeated here. For the convenience of the introduction of the subsequent embodiments, suppose that the core currently required by the perceptible task is determined to be: one medium core. The core currently required by the imperceptible task is: two small cores.
[0080] In step 104, the type and / or quantity of the initial cores corresponding to each task are adjusted according to the evaluation result.
[0081] After obtaining the evaluation result, the CPU bitmap data may be further modified based on the evaluation result, so as to adjust the type and / or number of the initial cores corresponding to each task.
[0082] As can be seen from the above, the current core allocation is: critical tasks: one large core and one medium core; perceptible tasks: two medium cores; imperceptible tasks: one small core. The evaluation results obtained based on step 103 are: critical tasks: one large core and one medium core; perceptible tasks: one medium core; imperceptible tasks: two small cores. The evaluation results of the cores currently required for the critical tasks are the same as the cores allocated in step 102, so no adjustment is required. It is only necessary to modify the CPU bitmap data so that the perceptible tasks are adjusted from running on two medium cores to running on one medium core, and the imperceptible tasks are adjusted from running on one small core to running on two small cores.
[0083] The CPU resource allocation method provided by the embodiment of the present disclosure can read the target core configuration information related to the target application when it is determined that the target application is running in the foreground, and allocate different cores to at least two different types of tasks based on the target core configuration information, so as to obtain the initial cores corresponding to each task. The target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground, and the target core configuration information is obtained by relevant staff based on experimental tests. Then, the initial cores corresponding to each task are further adjusted in real time based on the type and / or number of cores currently required for different types of tasks, so as to achieve more accurate core allocation, avoid the problem of excess core performance caused by unreasonable core allocation, or the allocated cores are insufficient to support the operation of such tasks, improve the persistent fluency of the terminal, and achieve a better user experience.
[0084] To better understand the above CPU resource allocation method, the process of evaluating the cores required for different types of tasks will be further introduced below.
[0085] like Figure 2 As shown, first, the terminal can classify the currently running application into a foreground application and a background application based on the identifier of the currently running application.
[0086] For the foreground application, the terminal can further determine the task for processing the terminal screen feedback as a key task, and determine the task not for processing the terminal screen feedback as a perceptible task. For the background application, the terminal can further determine the tasks that can be perceived by the user, such as the tasks using audio resources or positioning service resources, as perceptible tasks, and determine the tasks that cannot be perceived by the user, such as the tasks that do not use audio resources and positioning service resources, as imperceptible tasks.
[0087] For the critical task, the terminal can count the number of subtasks in the critical task, the load of each subtask, and other information, and then further calculate the total load of the critical task. For the perceptible task, the terminal can count the number of subtasks in the perceptible task, the load of each subtask, and other information, and then further calculate the total load of the perceptible task. For the imperceptible task, the terminal can count the number of subtasks in the imperceptible task, the load of each subtask, and other information, and then further calculate the total load of the imperceptible task.
[0088] Then, based on the total load of the critical tasks, the total load of the perceptible tasks, and the total load of the imperceptible tasks, the corresponding CPU resources are determined respectively, that is, the corresponding cores are evaluated respectively.
[0089] In one embodiment, in order to further optimize power consumption while ensuring terminal performance, the terminal may perform the above step 103 based on the following:
[0090] First, the total load of the critical tasks, perceptible tasks and imperceptible tasks are determined respectively. The process of determining the total load can refer to the introduction of the aforementioned embodiment and will not be repeated here.
[0091] For the critical task, since the critical task only runs on large cores and medium cores, and the power consumption of a large core is greater than that of a medium core, and the power consumption of two medium cores is greater than that of a large core. Therefore, when the total load of the critical task is less than the maximum load of the medium core, it can be determined that the core currently required for the critical task is 1 medium core. When the total load of the critical task is greater than the maximum load of the medium core and less than the maximum load of the large core, it is determined that the core currently required for the critical task is 1 large core. And when the total load of the critical task is greater than the maximum load of the large core, it is determined that the core currently required for the critical task is 1 large core and The core.
[0092] For the perceptible task, since the perceptible task only runs on the small core and the medium core, and the power consumption of a medium core is greater than that of a small core, and usually only one small core is allocated to the perceptible task, when the total load of the perceptible task is less than the maximum load of the small core, it can be determined that the core currently required by the perceptible task is 1 small core. When the total load of the perceptible task is greater than the maximum load of the small core, it can be determined that the core currently required by the perceptible task is 1 small core and The core.
[0093] For the imperceptible task, since the imperceptible task only runs on the small core, when the total load of the imperceptible task is less than the maximum load of the small core, it can be determined that the core currently required by the imperceptible task is 1 small core. When the total load of the imperceptible task is greater than the maximum load of the small core, it can be determined that the core currently required by the imperceptible task is 2 small cores.
[0094] The CPU resource allocation method provided in the embodiment of the present disclosure can allocate cores with as little power consumption as possible to different types of tasks under the premise of meeting the running requirements of different types of tasks, thereby reducing the power consumption of the terminal as much as possible under the premise of meeting the terminal performance.
[0095] In one embodiment, since both critical tasks and perceptible tasks may run on middle cores, and the number of middle cores is limited, in a specific implementation, when it is determined based on the result of the evaluation that the sum of the number of middle cores required for the critical tasks and the perceptible tasks is greater than the total number of middle cores, middle cores can be preferentially allocated to the critical tasks.
[0096] For example, when it is determined that the number of cores required for the critical task is 3 and the number of cores required for the perceptible task is 2, since 2+3=5, 5>4, 3 cores can be allocated to the critical task and 1 core can be allocated to the perceptible task.
[0097] The CPU resource allocation method provided in the embodiment of the present disclosure can prioritize the allocation of cores to the critical tasks when it is determined based on the evaluation results that the sum of the number of cores required for the critical tasks and the perceptible tasks is greater than the total number of cores, thereby maximizing the guarantee of the operation of the critical tasks, minimizing the impact on the user's viewing experience, and improving the user's usage experience.
[0098] In one embodiment, the evaluating the cores currently required for the at least two different types of tasks respectively includes:
[0099] In response to determining that the terminal is in a performance acceleration mode, an evaluation result of the cores currently required by the critical task is the multiple cores; wherein the performance acceleration mode is used to accelerate the operation of the critical task.
[0100] When evaluating the cores currently required for different types of tasks respectively, it can be determined first whether the terminal is in performance acceleration mode. When it is determined that the terminal is in performance acceleration mode, it indicates that the current terminal does not consider power consumption and needs to accelerate the operation of key tasks, so it can be determined that the cores currently required for the key tasks are the multiple cores. When it is determined that the terminal is not in performance acceleration mode, the method in the above embodiment is used to determine the cores required for different types of tasks respectively.
[0101] The CPU resource allocation method provided in the embodiment of the present disclosure can determine that the cores currently required for the key task are the multiple cores when the terminal is in the performance acceleration mode, thereby accelerating the operation of the key task and improving the user experience.
[0102] In one embodiment, in response to determining that the target application is running in the foreground, before reading the target core configuration information related to the target application, the method further includes:
[0103] The shell temperature of the terminal is obtained, and it is determined that the shell temperature of the terminal is lower than or equal to a preset temperature threshold.
[0104] In this example, the shell temperature of the terminal can be used as the temperature of the terminal, and when it is determined that the shell temperature of the terminal is lower than or equal to a preset temperature threshold, the step of reading the target core configuration information related to the target application in response to determining that the target application is running in the foreground is executed.
[0105] Since the terminal will unplug the core when the temperature is higher than the preset temperature threshold, causing some cores to be offline, the use of this method may result in the cores assigned to critical tasks or perceptible tasks being offline, affecting the operation of critical tasks or perceptible tasks, and further affecting the normal use of the user. Therefore, in this example, it can be set that when it is determined that the shell temperature of the terminal is lower than or equal to the preset temperature threshold, the CPU resource allocation method of the embodiment of the present disclosure is used, and when it is determined that the shell temperature of the terminal is higher than the preset temperature threshold, the method of allocating most cores to foreground tasks and a small number of cores to background tasks in the existing implementation is adopted, thereby avoiding the situation where the load-based allocation to different types of cores cannot support the operation of tasks and affects the normal use of users.
[0106] For the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described order of actions, because according to the present disclosure, certain steps can be performed in other orders or simultaneously.
[0107] Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0108] Corresponding to the aforementioned application function implementation method embodiment, the present disclosure also provides an application function implementation device and a corresponding terminal embodiment.
[0109] Figure 3 is a schematic diagram of a CPU resource allocation device according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the CPU resource allocation device may include:
[0110] The reading module 31 is used to read the target core configuration information related to the target application in response to determining that the target application is running in the foreground; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground.
[0111] The allocation module 32 is used to allocate corresponding cores to the at least two different types of tasks according to the corresponding relationship in the target core configuration information, so as to obtain initial cores corresponding to each task.
[0112] The evaluation module 33 is used to evaluate the cores currently required by the at least two different types of tasks respectively to obtain evaluation results; the evaluation results include the type and / or number of cores currently required by each task.
[0113] The adjustment module 34 is used to adjust the type and / or quantity of the initial cores corresponding to each task according to the evaluation result.
[0114] Optionally, each target type task includes at least one subtask.
[0115] The evaluation module 33, when used to evaluate the cores currently required by the at least two different types of tasks respectively, includes:
[0116] For each task of the target type, the loads of all subtasks included in the task of the target type are summed to obtain the total load of the task of the target type.
[0117] The core currently required for the task of the target type is determined according to the total load of the task of the target type and the maximum load corresponding to each core of the multiple cores.
[0118] Optionally, the at least two different types of tasks include at least part of the following:
[0119] Key tasks: The key tasks include tasks corresponding to the target application running in the foreground for processing terminal screen feedback.
[0120] Perceivable tasks; the perceivable tasks include other tasks corresponding to the target application running in the foreground except the key tasks, and user-perceivable tasks corresponding to the application running in the background.
[0121] Imperceptible tasks; the imperceptible tasks include other tasks corresponding to the application running in the background except the perceptible tasks.
[0122] Optionally, the multiple cores include: a large core, a medium core and a small core; wherein the maximum load of the large core is greater than the maximum load of the medium core, and the maximum load of the medium core is greater than the maximum load of the small core.
[0123] The evaluation module 33, when used to evaluate the cores currently required by the at least two different types of tasks respectively, includes:
[0124] The total load of the critical tasks, perceptible tasks and imperceptible tasks are determined respectively.
[0125] The number of medium cores and / or large cores required for the key task is determined based on the relationship between the total load of the key task and the maximum load of the medium core and the maximum load of the large core.
[0126] The number of small cores and / or medium cores required for the perceptible task is determined according to the relationship between the total load of the perceptible task and the maximum load of the small core and the maximum load of the medium core.
[0127] The number of small cores required for the perceptible task is determined according to the relationship between the total load of the imperceptible task and the maximum load of the small core.
[0128] Optionally, the adjustment module 34, when used to adjust the type and / or quantity of the initial cores corresponding to each task according to the evaluation result, includes:
[0129] If it is determined based on the evaluation result that the sum of the number of cores required for the critical task and the perceptible task is greater than the total number of cores, the cores are preferentially allocated to the critical task.
[0130] Optionally, the evaluation module 33, when used to evaluate the cores currently required for the at least two different types of tasks respectively, includes:
[0131] In response to determining that the terminal is in a performance acceleration mode, an evaluation result of the cores currently required by the critical task is the multiple cores; wherein the performance acceleration mode is used to accelerate the operation of the critical task.
[0132] Optional, such as Figure 4 As shown, in Figure 3 Based on the modules shown, the CPU resource allocation device may further include:
[0133] The acquisition module 41 is used to acquire the shell temperature of the terminal.
[0134] The determination module 42 is configured to determine whether the shell temperature of the terminal is lower than or equal to a preset temperature threshold.
[0135] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art may understand and implement it without creative work.
[0136] Accordingly, an embodiment of the present disclosure provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the CPU resource allocation method of any embodiment of the present disclosure.
[0137] Figure 5 A schematic diagram of the structure of an electronic device 500 is shown according to an exemplary embodiment. For example, the electronic device 500 may be a user equipment, and may be specifically a server or the like.
[0138] Reference Figure 5 , the electronic device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .
[0139] The processing component 502 generally controls the overall operation of the electronic device 500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 502 may include one or more modules to facilitate the interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate the interaction between the multimedia component 508 and the processing component 502.
[0140] The memory 504 is configured to store various types of data to support operations on the device 500. Examples of such data include instructions for any application or method operating on the electronic device 500, contact data, phone book data, messages, pictures, videos, etc. The memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0141] The power supply component 506 provides power to the various components of the electronic device 500. The power supply component 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 500.
[0142] The multimedia component 508 includes a screen that provides an output interface between the electronic device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the electronic device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0143] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), and when the electronic device 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 504 or sent via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.
[0144] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0145] The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the electronic device 500. For example, the sensor assembly 514 can detect the open / closed state of the electronic device 500, the relative positioning of the components, such as the display and keypad of the electronic device 500, and the sensor assembly 514 can also detect the position change of the electronic device 500 or a component of the electronic device 500, the presence or absence of contact between the user and the electronic device 500, the orientation or acceleration / deceleration of the electronic device 500, and the temperature change of the electronic device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0146] The communication component 516 is configured to facilitate wired or wireless communication between the electronic device 500 and other devices. The electronic device 500 can access a wireless network based on a communication standard, such as WiFi, 4G or 5G, 4G LTE, 5G NR or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0147] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0148] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory 504 including instructions, which, when executed by a processor 520 of an electronic device 500, enables the electronic device 500 to perform a CPU resource allocation method.
[0149] Wherein, the CPU resource allocation method includes:
[0150] In response to determining that the target application is running in the foreground, target core configuration information related to the target application is read; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground.
[0151] According to the corresponding relationship in the target core configuration information, corresponding cores are respectively allocated to the at least two different types of tasks.
[0152] The cores currently required for the at least two different types of tasks are evaluated respectively.
[0153] According to the evaluation result, the cores allocated to the at least two different types of tasks according to the target core configuration information are adjusted.
[0154] The non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0155] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0156] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for allocating central processing unit (CPU) resources, characterized in that: The CPU resource includes multiple cores, and the method includes: In response to determining that the target application is running in the foreground, reading target core configuration information related to the target application; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground; According to the corresponding relationship in the target core configuration information, corresponding cores are allocated to the at least two different types of tasks respectively, so as to obtain initial cores corresponding to each task respectively; The cores currently required for the at least two different types of tasks are evaluated respectively to obtain evaluation results; the evaluation results include the type and / or number of cores currently required for each task; According to the evaluation result, the type and / or quantity of the initial cores corresponding to each task are adjusted.
2. The method according to claim 1, characterized in that Each target type task includes at least one subtask; The evaluating the cores currently required for the at least two different types of tasks respectively includes: For each task of the target type, summing the loads of all subtasks included in the task of the target type to obtain the total load of the task of the target type; The core currently required for the task of the target type is determined according to the total load of the task of the target type and the maximum load corresponding to each core of the multiple cores.
3. The method according to claim 1, characterized in that The at least two different types of tasks include at least part of the following: Key tasks; the key tasks include tasks corresponding to the target application running in the foreground for processing terminal screen feedback; Perceivable tasks; the perceivable tasks include other tasks corresponding to the target application running in the foreground except the key tasks, and user-perceivable tasks corresponding to the application running in the background; Unperceivable tasks; The imperceptible tasks include other tasks corresponding to the application program running in the background except the perceptible tasks.
4. The method according to claim 3, characterized in that The multiple cores include: a large core, a medium core and a small core; wherein the maximum load of the large core is greater than the maximum load of the medium core, and the maximum load of the medium core is greater than the maximum load of the small core; The evaluating the cores currently required for the at least two different types of tasks respectively includes: Determine the total load of the critical tasks, perceptible tasks and imperceptible tasks respectively; Determine the number of medium cores and / or large cores required for the key task according to the relationship between the total load of the key task and the maximum load of the medium core and the maximum load of the large core; Determine the number of small cores and / or medium cores required for the perceptible task according to the relationship between the total load of the perceptible task and the maximum load of the small core and the maximum load of the medium core; The number of small cores required for the perceptible task is determined according to the relationship between the total load of the imperceptible task and the maximum load of the small core.
5. The method according to claim 4, characterized in that The adjusting, according to the evaluation result, the type and / or quantity of the initial cores corresponding to each task respectively, comprises: If it is determined based on the evaluation result that the sum of the number of cores required for the critical task and the perceptible task is greater than the total number of cores, the cores are preferentially allocated to the critical task.
6. The method according to claim 3, characterized in that: The evaluating the cores currently required for the at least two different types of tasks respectively includes: In response to determining that the terminal is in a performance acceleration mode, an evaluation result of the cores currently required by the critical task is the multiple cores; wherein the performance acceleration mode is used to accelerate the operation of the critical task.
7. The method according to claim 1, characterized in that In response to determining that the target application is running in the foreground, before reading the target core configuration information related to the target application, the method further includes: Obtaining a shell temperature of the terminal; It is determined that the shell temperature of the terminal is lower than or equal to a preset temperature threshold.
8. A CPU resource allocation device, characterized in that: The CPU resource includes multiple cores, and the device includes: A reading module, configured to read target core configuration information related to the target application in response to determining that the target application is running in the foreground; wherein the target core configuration information is used to characterize the correspondence between different cores and at least two different types of tasks when the target application is running in the foreground; An allocation module, configured to allocate corresponding cores to the at least two different types of tasks respectively according to the corresponding relationship in the target core configuration information, so as to obtain initial cores corresponding to each task respectively; An evaluation module, used to evaluate the cores currently required for the at least two different types of tasks respectively, and obtain evaluation results; the evaluation results include the type and / or number of cores currently required for each task; The adjustment module is used to adjust the type and / or quantity of the initial cores corresponding to each task according to the evaluation result.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of any method described in claims 1-7 are implemented.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the steps of any one of the methods of claims 1-7.
