Task processing method and apparatus, and electronic device
By determining the scheduling priority based on the task type and important level and selecting the appropriate processor core to process tasks, the problem that fair scheduling algorithm is difficult to ensure the task processing effect, and the task processing speed and efficiency are improved.
Patent Information
- Application Number
- PCT/CN2024/095062
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-30
- Filing Date
- 2024-05-24
- Publication Date
- 2024-12-05
AI Technical Summary
The existing fair scheduling algorithms are difficult to ensure the processing effect of tasks, resulting in poor processing speed of some tasks.
The scheduling priority is determined based on the type and importance level of the task, and select the appropriate target processor core from multiple processor cores for task processing based on the computing power requirement information.
It realizes priority scheduling and efficient processing of tasks, improving the processing speed and fluency of tasks.
Smart Images

Figure CN2024095062_05122024_PF_FP_ABST
Abstract
Description
Task processing method, device and electronic equipment
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on May 30, 2023, with application number 202310626134.3 and titled “Task processing method, device and electronic device,” the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a task processing method, device, and electronic device. Background Art
[0004] A multi-core central processing unit (CPU) is a CPU with multiple processor cores, each of which can independently execute instructions, and multiple processor cores can simultaneously execute different tasks, thereby improving the performance and efficiency of the processor. In addition, current operating systems are typically multi-threaded environments, where each processor core can simultaneously execute multiple threads, thereby achieving concurrent execution. Currently, fair scheduling of tasks on the CPU is usually implemented based on the Completely Fair Scheduler (CFS), a time-based scheduling algorithm that divides the CPU time into time slices and allocates a certain time slice to each process. Each task is processed within its corresponding time slice. However, this fair scheduling method cannot guarantee the processing effect of some tasks.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a task processing method, device, and electronic device, which can ensure the processing speed of some tasks and thereby improve the fluency of these tasks.
[0007] In a first aspect, an embodiment of the present application provides a task processing method, the method comprising:
[0008] Determining a scheduling priority of the first task according to first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level;
[0009] Selecting a target processor core from N processor cores according to second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1;
[0010] The first task is executed on the target processor core according to the scheduling priority of the first task.
[0011] In a second aspect, an embodiment of the present application provides a task processing device, the device comprising:
[0012] A first determining module, configured to determine a scheduling priority of the first task according to first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level;
[0013] a first selection module, configured to select a target processor core from N processor cores according to second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1;
[0014] An execution module is configured to execute the first task on the target processor core according to the scheduling priority of the first task.
[0015] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps in the task processing method described in the first aspect are implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps in the task processing method described in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method described in the first aspect.
[0018] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the method described in the first aspect.
[0019] In a seventh aspect, an embodiment of the present application provides an electronic device, which is configured to execute the method described in the first aspect.
[0020] In an embodiment of the present application, the scheduling priority of a task is determined based on at least one of the task type and the task importance level, and the task is processed based on the scheduling priority. This can achieve priority scheduling of some tasks (for example, foreground tasks, etc.), thereby improving the processing speed of these tasks. In addition, in an embodiment of the present application, a target processor core is selected from N processor cores to process the task based on computing power demand information and scheduling priority. This is conducive to selecting a more suitable processor core (for example, the processor core with the strongest processing power or the largest remaining computing power, etc.) for processing some tasks, thereby improving the processing efficiency and fluency of these tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] FIG1 is a flowchart of a task processing method provided in an embodiment of the present application;
[0022] FIG2 is a schematic diagram of a multi-processor core provided in an embodiment of the present application;
[0023] FIG3 is a flowchart of another task processing method provided in an embodiment of the present application;
[0024] FIG4 is a schematic diagram of the structure of a task processing device provided in an embodiment of the present application;
[0025] FIG5 is a schematic diagram of a structure of an electronic device provided in an embodiment of the present application;
[0026] FIG6 is a second structural diagram of an electronic device provided in an embodiment of the present application. Specific embodiments
[0027] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.
[0028] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of a class and do not limit the number of objects; for example, the first object can be one or more. Furthermore, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0029] The task processing method, device, and electronic device provided in the embodiments of the present application are described in detail below with reference to specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0030] Referring to FIG1 , FIG1 is a flowchart of a task processing method provided in an embodiment of the present application, as shown in FIG1 , comprising the following steps:
[0031] Step 101: Determine a scheduling priority of a first task according to first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level.
[0032] In this embodiment, the first task may be any task to be processed or scheduled.
[0033] The above-mentioned task types can be reasonably set according to actual needs. For example, the above-mentioned task types can include foreground tasks or background tasks, or the above-mentioned task types can include multimedia tasks (for example, audio tasks, video tasks or game tasks, etc.) or non-multimedia tasks, etc. In some optional embodiments, the above-mentioned front and back tasks can be further divided into video tasks located in the foreground, game tasks located in the foreground, tasks of small window applications located in the foreground, etc. Exemplarily, the task type can be identified based on one or more information such as the application package name, whether it is visible, whether it has focus, the audio status, and whether the input operation is frequent.
[0034] The above-mentioned task importance level is determined based on at least one of the task type, load size, computing power requirement information, etc. The above-mentioned computing power requirement information can be used to indicate the computing power value required to execute the task. For example, it can be a computing power value obtained by statistics based on the computing power values consumed by executing the same task multiple times in history. Alternatively, it can be pre-divided into multiple computing power levels. The above-mentioned computing power requirement information can be used to indicate the computing power level corresponding to the task. For example, it can be pre-divided into a first computing power level and a second computing power level. The first computing power level is used to indicate that the required computing power is relatively large, and the second computing power level is used to indicate that the required computing power is relatively small. The correspondence between different tasks and computing power levels can be pre-established. For example, multimedia tasks (for example, audio tasks, video tasks, or game tasks, etc.) correspond to the first computing power level, and non-multimedia tasks correspond to the second computing power level.
[0035] In some optional embodiments, the task types can be divided first. For tasks of the same task type, the task importance level of each task can be further determined. For example, the tasks can be divided into foreground tasks and background tasks. For foreground tasks, the task importance level of each foreground task can be further determined. For example, the task importance level of multimedia foreground tasks (for example, audio tasks, video tasks, or game tasks, etc.) is greater than the task importance level of non-multimedia foreground tasks.
[0036] The above scheduling priority can be used to indicate the order in which tasks are scheduled, where the task with the higher scheduling priority is scheduled first. For example, in the same processor core, the scheduling priority of task a is scheduling priority a1, and the scheduling priority of task b is scheduling priority b1. If scheduling priority a1 is higher than scheduling priority b1, task a is scheduled before task b.
[0037] In one embodiment, if the first parameter information includes a task type, the scheduling priority of the first task can be determined based on the task type of the first task. For example, a correspondence between the task type and the scheduling priority can be established in advance. For example, the foreground task corresponds to the scheduling priority a1, and the background task corresponds to the second scheduling priority b1. The first scheduling priority a1 is higher than the second scheduling priority b1. Then, the scheduling priority of the first task can be quickly determined based on the above correspondence and the task type of the first task.
[0038] In another embodiment, if the first parameter information includes the task importance level, the scheduling priority of the first task can be determined based on the task importance level of the first task. For example, a correspondence between the task importance level and the scheduling priority can be established in advance. For example, the higher the task importance level, the higher the corresponding scheduling priority of the task. Then, the scheduling priority of the first task can be quickly determined based on the above correspondence and the task importance level of the first task.
[0039] In another embodiment, if the first parameter information includes the task type and the task importance level, the scheduling priority of the first task can be determined based on the task type and the task importance level of the first task. For example, a correspondence between the task type, the task importance level and the scheduling priority can be established. For example, the foreground task with the task importance level of a corresponds to the scheduling priority a11, the foreground task with the task importance level of b corresponds to the scheduling priority a12, and the background task corresponds to the scheduling priority a2. If a is greater than b, the scheduling priority a11 is higher than the scheduling priority a12, and the scheduling priority a12 is higher than the scheduling priority a2. Therefore, the scheduling priority of the first task can be quickly determined based on the above correspondence and the task type and the task importance level of the first task.
[0040] Step 102: Select a target processor core from N processor cores based on second parameter information of the first task, where the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1.
[0041] In this embodiment, the above-mentioned computing power demand information and scheduling priority can be found in the above-mentioned related descriptions and will not be repeated here.
[0042] The processing capabilities of each of the N processor cores may be the same; or, the N processor cores may include at least two types of processor cores with different processing capabilities. For example, the N processor cores may include a first type of processor core, a second type of processor core, and a third type of processor core, wherein the processing capability of the first type of processor core is stronger than that of the second type of processor core, and the processing capability of the second type of processor core is stronger than that of the third type of processor core. For example, as shown in FIG2 , there is one large processor core, four medium processor cores, and three small processor cores, wherein processor cores of different sizes correspond to different processing capabilities. For example, the capability of a large processor core may be three times or even four times greater than that of a small processor core. The measurement indicators of the processing capabilities of the processor cores may include, but are not limited to, the total computing power value of the processor core, that is, the greater the total computing power value, the stronger the processing capability. The measurement indicators of the total computing power value may include, but are not limited to, computing speed, cache size, etc.
[0043] Exemplarily, when the scheduling priority of the first task is higher than the preset priority, the processor core selection range of the first task can be determined from N processor cores based on the computing power requirement information of the first task, and the target processor core can be selected from the processor core selection range; alternatively, the target load of each processor core can be calculated based on the scheduling priority of the first task, wherein the above-mentioned target load can be the sum of the loads of all tasks on the processor core whose scheduling priorities meet the preset conditions, and the target processor core can be selected from the N processor cores based on the computing power requirement information of the first task and the target load of each processor core. For example, the processor core selection range of the first task can be determined from N processor cores based on the computing power requirement information of the first task, and the processor core with the smallest target load can be selected as the target processor core from the processor core selection range.
[0044] Step 103: Execute the first task on the target processor core according to the scheduling priority of the first task.
[0045] In this embodiment, tasks with higher scheduling priorities are scheduled more preferentially by the target processor core. For example, if the target processor core includes a foreground task a and a background task b, and the scheduling priority of foreground task a is higher than that of background task b, the target processor core will prioritize scheduling foreground task a and schedule background task b after all foreground tasks a have been processed. It should be noted that tasks with the same scheduling priority can be scheduled sequentially based on their order in the task queue.
[0046] The task processing method provided in the embodiment of the present application determines the scheduling priority of the task according to at least one of the task type and the task importance level, and processes the task based on the scheduling priority. In this way, priority scheduling of some tasks (for example, foreground tasks, etc.) can be achieved, thereby improving the processing speed of these tasks. In addition, the embodiment of the present application selects a target processor core from N processor cores to process the task based on computing power demand information and scheduling priority. This is conducive to selecting a more suitable processor core (for example, the processor core with the strongest processing power or the largest remaining computing power, etc.) for processing some tasks, thereby improving the processing efficiency and fluency of these tasks.
[0047] Optionally, selecting a target processor core from N processor cores according to the second parameter information of the first task includes:
[0048] Calculating a first remaining computing power value for each of the N processor cores based on the scheduling priority of the first task, where the first remaining computing power value of the processor core is the difference between the total computing power value of the processor core and the first computing power value, where the first computing power value is the sum of the computing power values required for the load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task;
[0049] A target processor core is determined according to the computing power requirement information of the first task and a first remaining computing power value of each processor core in the N processor cores.
[0050] The above-mentioned computing power requirement information, scheduling priority and N processor cores can be found in the relevant description of the previous embodiment and will not be repeated here.
[0051] In this embodiment, the sum of the load-required computing power values of all tasks with a scheduling priority greater than or equal to the scheduling priority of the first task in each processor core can be calculated, i.e., the first computing power value of each processor core. The difference between the total computing power value of each processor core and the first computing power value is then used as the first remaining computing power value of the processor core. For example, if the scheduling priority of the first task is 3, for processor core CPU-7, the load-required computing power value load-7 of all tasks with a scheduling priority greater than or equal to 3 in CPU-7 can be calculated. The first remaining computing power value free-7 can then be calculated based on the total computing power value cap-7 of CPU-7, i.e., free-7 = cap-7 – load-7.
[0052] After obtaining the first remaining computing power value of each of the N processor cores, the target processor core can be determined based on the computing power requirement information of the first task and the first remaining computing power value of each of the N processor cores. For example, a processor core can be selected as the target processor core from the processor cores whose first remaining computing power values can meet the computing power requirement information of the first task.
[0053] In this embodiment, when the above-mentioned N processor cores include at least two types of processor cores with different processing capabilities, processor core selection is performed based on the first remaining computing power value of each processor core, which is conducive to preferentially selecting processor cores with stronger processing capabilities to process tasks with higher scheduling priorities, thereby improving the processing speed and smoothness of tasks with higher scheduling priorities; when the processing capabilities of each processor core of the above-mentioned N processor cores can be the same, processor core selection is performed based on the first remaining computing power value of each processor core, which is conducive to reducing the impact of tasks with lower scheduling priorities on tasks with higher scheduling priorities, thereby improving the processing speed of tasks with higher scheduling priorities.
[0054] Optionally, determining the target processor core according to the computing power requirement information of the first task and the first remaining computing power value of each processor core of the N processor cores includes:
[0055] determining a first processor core selection range based on the computing power requirement information of the first task, wherein the N processor cores include at least two types of processor cores, different types of processor cores in the at least two types of processor cores have different processing capabilities, and the first processor core selection range includes at least two processor cores in the N processor cores;
[0056] A target processor core is determined according to the first remaining computing power values of the processor cores within the first processor core selection range.
[0057] In this embodiment, each type of processor core may include one or more processor cores. For example, the N processor cores may include a first type of processor core and a second type of processor core, where the first type of processor core includes L processor cores and the second type of processor core includes K processor cores, where L + K = N, and the processing capability of the first type of processor core is greater than that of the second type of processor core. In this case, the processor core with the smallest first load may be selected from the L processor cores as the first processor core.
[0058] It should be noted that the processing capabilities of the multiple processor cores included in each of the above-mentioned processor core categories can all be the same, or the difference in processing capabilities between the multiple processor cores included in each of the above-mentioned processor core categories can be within a preset range. It should also be noted that the structures or models of the multiple processor cores included in each of the above-mentioned processor core categories can be the same or different.
[0059] In actual applications, the computing power requirement information of each task can be pre-stated through experimental simulation and other methods, and then a correspondence between the computing power requirement information and the processor core selection range can be established based on the computing power requirement information of each task, wherein the computing power of the processor core within the above-mentioned processor core selection range can meet the computing power requirement information of the corresponding task.
[0060] In some optional embodiments, when the above-mentioned computing power requirement information is the computing power level, a correspondence between the computing power level and the processor core selection range can be established, wherein different computing power levels correspond to different processor core selection ranges, and the higher the computing power level (that is, the more computing power required), the stronger the processing capability of the processor core within the corresponding processor core selection range. This is conducive to preferentially selecting processor cores with stronger processing capabilities to process tasks requiring greater computing power.
[0061] For example, the above-mentioned N processor cores include 8 processor cores, namely CPU-0 to CPU-7, among which CPU-7 is a large processor core, CPU-4 to CPU-6 are all medium processor cores, and CPU-0 to CPU-3 are all small processor cores, among which the processing capability of the large processor core is stronger than that of the medium processor core, and the processing capability of the medium processor core is stronger than that of the small processor core. Task A is a task of a small window application (for example, a small window task of a video application or a small window task of an instant messaging application, etc.), which requires less computing power. The corresponding processor core selection range is CPU-0 to CPU-6, that is, Task A can select a processor core from CPU-0 to CPU-6; Task B is a game task, which requires more computing power. The corresponding processor core selection range is CPU-0 to CPU-7, that is, Task B can select a processor core from CPU-0 to CPU-7.
[0062] In this embodiment, when there are multiple tasks with the same scheduling priority (for example, multiple foreground tasks), the processor core selection range corresponding to each task can be determined based on the computing power requirement information of each task, and the processor core corresponding to each task can be selected from the processor core selection range corresponding to each task. This can reduce the situation where multiple tasks with the same scheduling priority but different computing power requirements are selected to the same processor core, which can not only reduce the mutual influence between the above-mentioned multiple tasks, but also reduce the overhead of migrating tasks to different processor cores.
[0063] In some optional embodiments, the first processor core selection range can be determined based on the computing power requirement information of the first task, and then the first remaining computing power value of each processor core within the first processor core selection range can be calculated based on the scheduling priority of the first task, and the target processor core can be determined based on the first remaining computing power value of each processor core within the first processor core selection range. This can reduce the calculation of the remaining computing power of the processor core and save system resources.
[0064] Optionally, determining the target processor core according to the first remaining computing power value of each processor core within the first processor core selection range includes:
[0065] Determine the processor core with the largest first remaining computing power value within the first processor core selection range as the target processor core;
[0066] or,
[0067] A processor core with the largest first remaining computing power value among target-type processor cores within the first processor core selection range is determined as a target processor core, wherein the target-type processor core is a type of processor core with the strongest processing capability within the first processor core selection range.
[0068] In one embodiment, the processor core with the largest first remaining computing power value within the first processor core selection range is determined as the target processor core, which can ensure that the first task can be processed as quickly as possible, thereby improving the timeliness of the first task processing.
[0069] In another embodiment, selecting the processor core with the largest first residual computing power value from a class of processor cores with the strongest processing capabilities can ensure that the first task is processed by the processor core with the strongest processing capabilities. This can not only improve the processing speed of the first task, but also improve the fluency of the first task.
[0070] The processor core of the type with the strongest processing capability in the first processor core selection range may be, for example, a processor core of the type with the largest total computing power value in the first processor core selection range.
[0071] Optionally, selecting a target processor core from N processor cores according to the second parameter information of the first task includes:
[0072] When the first task satisfies a first condition, selecting a target processor core from the N processor cores according to second parameter information of the first task;
[0073] The first condition includes any one of the following: the task type is a foreground task, the task importance level is greater than a preset level, and the scheduling priority is greater than a preset priority.
[0074] The above-mentioned preset levels and preset priorities can be reasonably set according to actual needs, and this embodiment does not limit this.
[0075] Specifically, the processor core selection method provided in the embodiment of the present application can be used to select a processor core for the first task only when the first task meets the first condition. For example, the first computing power value of each of the N processor cores is calculated separately according to the scheduling priority of the first task, wherein the first computing power value is the sum of the computing power values required for the load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task, and the first remaining computing power value of each of the N processor cores is determined separately according to the first computing power value and the total computing power value of each processor core in the N processor cores, and the processor core used to execute the first task is determined according to the computing power requirement information of the first task and the first remaining computing power value of each processor core in the N processor cores.
[0076] If the first task does not meet the first condition, the existing processor core selection method can be used. For example, the load computing power value corresponding to each processor core in the above-mentioned N processor cores is calculated separately. The load computing power value is the sum of the computing power values required for all loads in the processor core, and the processor core with the smallest load computing power value can be selected as the processor core for executing the above-mentioned first task.
[0077] In this embodiment, when the first condition is met, the target processor core is selected from N processor cores according to the second parameter information of the first task. This not only ensures the processing effect of foreground tasks or some more important tasks, such as processing efficiency and fluency, but also reduces the complexity of processor core selection for tasks that do not meet the first condition (for example, background tasks or some less important tasks, etc.), thereby reducing system resource overhead.
[0078] Optionally, the first parameter information includes the task type, and the task type includes a foreground task or a background task;
[0079] The determining the scheduling priority of the first task according to the first parameter information of the first task includes:
[0080] In a case where the task type of the first task is a foreground task, determining the scheduling priority of the first task to be a first scheduling priority;
[0081] In a case where the task type of the first task is a background task, determining the scheduling priority of the first task to be a second scheduling priority;
[0082] The first scheduling priority is higher than the second scheduling priority.
[0083] For example, a task can be distinguished as a foreground task or an acquired task based on whether there is a visible interface for the task, whether there is a foreground service and a service that the foreground depends on is being executed, whether there is a broadcast being executed, whether there is a database that the foreground depends on is being executed, etc. For example, if there is no visible interface for a task, no foreground service and a service that the foreground depends on is being executed, no broadcast being executed, and no database that the foreground depends on is being executed, then the task is determined to be a background task; otherwise, the task is determined to be a foreground task.
[0084] In this embodiment, the scheduling priority of the foreground task is higher than the scheduling priority of the background task. This ensures that the foreground task can be scheduled before the background task, thereby reducing the jamming of the foreground task and improving the fluency of the foreground task.
[0085] The embodiment of the present application is described below with reference to FIG3 .
[0086] Step 201: scene recognition.
[0087] In this embodiment, the scene recognition module can be used to identify the scenes of multiple foreground applications, and the highest scheduling priority can be set for the foreground processes (i.e., tasks). Otherwise, under unfair scheduling, low-priority foreground applications can be easily affected by high-priority foreground applications, which can easily cause lag.
[0088] For example, application A switches to the foreground, triggering a scene change notification to the scene recognition module; application B switches to the foreground, triggering a scene change notification to the scene recognition module.
[0089] Step 202: Determine whether there are multiple foreground applications.
[0090] For example, the scene recognition module determines the foreground processes of application A and application B. If both application A and application B are foreground applications, then it belongs to a multi-foreground application scenario. In this step, if there are multiple foreground applications, step 203 can be executed.
[0091] Step 203: Calculate the computing power required by each foreground application (ie, the computing power requirement information mentioned above).
[0092] For example, the CPU power requirements of each foreground process (i.e., task) can be evaluated based on its type to allocate CPU resources. For example, the usage scenario (e.g., playing games, listening to music, sliding small windows, etc.) can be identified based on information such as the application package name, visibility, focus, audio status, and frequency of input operations, and the computing power requirements of the application process can be determined.
[0093] For example, game processes that require high computing power can be run on large and medium processor cores first. Foreground processes that require slightly lower computing power (such as small window application processes) can be run on other medium or small processor cores. This can reduce the additional system overhead caused by frequent migration of different foreground processes running on the same processor core.
[0094] It should be noted that the scheduling system can only manage the scheduling of processes without caring about information such as the type of application and computing power requirements. Therefore, the above process can be completed through the above-mentioned scenario recognition module.
[0095] Step 204: If the scene recognition module determines that application A has a high demand for CPU computing power, the processor core selection range for application A (such as a game application) may be determined to be CPU-0 to CPU-7.
[0096] For example, CPU-7 is a large processor core, CPU-4 to CPU-6 are medium processor cores, and CPU-0 to CPU-3 are small processor cores. The processing capability of the large processor core is stronger than that of the medium processor core, and the processing capability of the medium processor core is stronger than that of the small processor core.
[0097] It should be noted that the computing power required for each application process can be determined in advance through experimental simulation. For example, each application process can be tested through experimental simulation to determine how much computing power is required to avoid frame drops and sound jams, and then the range of processor core selection corresponding to each application process can be determined.
[0098] Step 205: Select processor cores through unfair scheduling, and prioritize processor cores CPU-7 and CPU-6 for application A.
[0099] Because application A is a high-priority process, it can run on CPU-7 and CPU-6 without any restrictions on the CPU cores it can run on. Therefore, according to the unfair scheduling load core selection logic, it will be scheduled preferentially on CPU-7 and CPU-6. This is because CPU-7 and CPU-6 have strong computing power and there is no other high-priority process running, so there is more spare capacity.
[0100] For example, if application A is a foreground process and has a high demand for CPU computing power, application A can be preferentially scheduled to large and medium processor cores through unfair scheduling. For example, if application A is identified as a game application (such as determined as a game application based on the application package name) and is in the foreground (for example, it is known that it is in a battle scene based on the game software development kit (SDK)), the scheduling priority of application A can be set to the highest scheduling priority, for example, to set its scheduling priority to 3, which is the highest scheduling priority, and application A can be preferentially scheduled to CPU-7 and CPU-6.
[0101] Step 206: If the scene recognition module determines that application B has a low CPU computing power requirement, the processor core selection range for application B (eg, small window application) may be determined to be CPU-0 to CPU-5.
[0102] Step 207: Select processor cores through unfair scheduling, and prioritize processor cores CPU-5 and CPU-4 for application B.
[0103] Because application B can only run on CPUs 0 to 5, it will be preferentially scheduled on CPUs 5 and 4 according to the unfair scheduling load selection logic. Because application B is selected from CPUs 0 to 5, CPUs 5 and 4 have strong processing power and more spare computing capacity, so it is easier for it to run on CPUs 5 and 4. In addition, there are not many application processes with high scheduling priority running on CPUs 5 and 4.
[0104] As can be seen from the above, in the example, application B (such as a video window application) occupies CPU-4 to CPU-5 at most, and can avoid competing with application A (such as a game application) for CPU-6 and CPU-7. In this way, when application A and application B have the highest scheduling priority, they are scheduled at the highest priority on each processor core, which can ensure the smoothness of each application.
[0105] It should be noted that in the unfair scheduling processor core selection method of this example, the processor core selected by the process with high scheduling priority will ignore the load of the low scheduling priority process on each processor core, and calculate the remaining computing power value on each processor core (that is, the first remaining computing power value mentioned above), and then select the processor core with the largest remaining computing power value. For example, when selecting a processor core for application process A with a scheduling priority of 3, since CPU-7 to CPU-0 can be selected, when calculating the remaining computing power value of CPU-7, the load of processes greater than or equal to 3 in the task queue on CPU-7 will be calculated, and the load of processes less than 3 will not be calculated (because the load of processes with priority 2 and priority 1 will not affect the process with priority 3, where the scheduling priority order is: 3 is higher than 2, and 2 is higher than 1).
[0106] It should also be noted that, for background tasks, their scheduling priority can be set to a low scheduling priority for unfair scheduling, for example, their scheduling priority can be set to 0.
[0107] The task processing method provided in the embodiment of the present application can be executed by a task processing device. In the embodiment of the present application, the task processing device provided in the embodiment of the present application is described by taking the task processing method executed by the task processing device as an example.
[0108] 4 , which is a schematic diagram of the structure of a task processing device provided in an embodiment of the present application. As shown in FIG4 , the task processing device 400 includes:
[0109] A first determining module 401 is configured to determine a scheduling priority of a first task based on first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level;
[0110] A first selection module 402 is configured to select a target processor core from N processor cores based on second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1;
[0111] The execution module 403 is configured to execute the first task on the target processor core according to the scheduling priority of the first task.
[0112] Optionally, the second parameter information includes computing power requirement information and scheduling priority;
[0113] The first selection module includes:
[0114] a calculation unit, configured to calculate, based on the scheduling priority of the first task, a first remaining computing power value of each processor core of the N processor cores, where the first remaining computing power value of the processor core is the difference between the total computing power value of the processor core and the first computing power value, where the first computing power value is the sum of the computing power values required by the load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task;
[0115] A determination unit is configured to determine a target processor core based on the computing power requirement information of the first task and a first remaining computing power value of each processor core in the N processor cores.
[0116] Optionally, the determining unit is specifically configured to:
[0117] determining a first processor core selection range based on the computing power requirement information of the first task, wherein the N processor cores include at least two types of processor cores, different types of processor cores in the at least two types of processor cores have different processing capabilities, and the first processor core selection range includes at least two processor cores in the N processor cores;
[0118] A target processor core is determined according to the first remaining computing power values of the processor cores within the first processor core selection range.
[0119] Optionally, the determining unit is specifically configured to:
[0120] Determine the processor core with the largest first remaining computing power value within the first processor core selection range as the target processor core;
[0121] or,
[0122] A processor core with the largest first remaining computing power value among target-type processor cores within the first processor core selection range is determined as a target processor core, wherein the target-type processor core is a type of processor core with the strongest processing capability within the first processor core selection range.
[0123] Optionally, the first selection module is specifically configured to:
[0124] When the first task satisfies a first condition, selecting a target processor core from the N processor cores according to second parameter information of the first task;
[0125] The first condition includes any one of the following: the task type is a foreground task, the task importance level is greater than a preset level, and the scheduling priority is greater than a preset priority.
[0126] Optionally, the first parameter information includes the task type, and the task type includes a foreground task or a background task;
[0127] The first determining module is specifically configured to:
[0128] In a case where the task type of the first task is a foreground task, determining the scheduling priority of the first task to be a first scheduling priority;
[0129] In a case where the task type of the first task is a background task, determining the scheduling priority of the first task to be a second scheduling priority;
[0130] The first scheduling priority is higher than the second scheduling priority.
[0131] The task processing device in the embodiment of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other device other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. It can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not specifically limit it.
[0132] The task processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0133] The task processing device provided in the embodiment of the present application can implement each process implemented in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0134] Optionally, as shown in Figure 5, an embodiment of the present application also provides an electronic device 500, including a processor 501 and a memory 502, and the memory 502 stores a program or instruction that can be run on the processor 501. When the program or instruction is executed by the processor 501, the various steps of the above-mentioned task processing method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0135] It should be noted that the electronic devices in the embodiments of the present application include mobile electronic devices and non-mobile electronic devices.
[0136] FIG6 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
[0137] The electronic device 600 includes but is not limited to components such as a radio frequency unit 601 , a network module 602 , an audio output unit 603 , an input unit 604 , a sensor 605 , a display unit 606 , a user input unit 607 , an interface unit 608 , a memory 609 , and a processor 610 .
[0138] Those skilled in the art will appreciate that the electronic device 600 may further include a power source (e.g., a battery) to power various components. The power source may be logically connected to the processor 610 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The electronic device structure shown in FIG6 does not limit the electronic device. The electronic device may include more or fewer components than shown, or may combine certain components or arrange the components differently, which will not be described in detail here.
[0139] The processor 610 is configured to determine a scheduling priority of the first task based on first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level;
[0140] The processor 610 is further configured to select a target processor core from N processor cores based on second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1;
[0141] The processor 610 is further configured to execute the first task on the target processor core according to the scheduling priority of the first task.
[0142] Optionally, the second parameter information includes computing power requirement information and scheduling priority;
[0143] The processor 610 is specifically configured to:
[0144] Calculating a first remaining computing power value for each of the N processor cores based on the scheduling priority of the first task, where the first computing power value is the sum of computing power values required by the load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task;
[0145] A target processor core is determined according to the computing power requirement information of the first task and a first remaining computing power value of each processor core in the N processor cores.
[0146] Optionally, the processor 610 is specifically configured to:
[0147] determining a first processor core selection range based on the computing power requirement information of the first task, wherein the N processor cores include at least two types of processor cores, different types of processor cores in the at least two types of processor cores have different processing capabilities, and the first processor core selection range includes at least two processor cores in the N processor cores;
[0148] A target processor core is determined according to the first remaining computing power values of the processor cores within the first processor core selection range.
[0149] Optionally, the processor 610 is specifically configured to:
[0150] Determine the processor core with the largest first remaining computing power value within the first processor core selection range as the target processor core;
[0151] or,
[0152] A processor core with the largest first remaining computing power value among target-type processor cores within the first processor core selection range is determined as a target processor core, wherein the target-type processor core is a type of processor core with the strongest processing capability within the first processor core selection range.
[0153] Optionally, the processor 610 is specifically configured to:
[0154] When the first task satisfies a first condition, selecting a target processor core from the N processor cores according to second parameter information of the first task;
[0155] The first condition includes any one of the following: the task type is a foreground task, the task importance level is greater than a preset level, and the scheduling priority is greater than a preset priority.
[0156] Optionally, the first parameter information includes the task type, and the task type includes a foreground task or a background task;
[0157] The processor 610 is specifically configured to:
[0158] In a case where the task type of the first task is a foreground task, determining the scheduling priority of the first task to be a first scheduling priority;
[0159] In a case where the task type of the first task is a background task, determining the scheduling priority of the first task to be a second scheduling priority;
[0160] The first scheduling priority is higher than the second scheduling priority.
[0161] It should be understood that in an embodiment of the present application, the input unit 604 may include a graphics processing unit (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0162] The memory 609 can be used to store software programs and various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 609 may include a volatile memory or a non-volatile memory, or the memory 609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (DRRAM). The memory 609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0163] Processor 610 may include one or more processing units. Optionally, processor 610 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 610.
[0164] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned task processing method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0165] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0166] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned task processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0167] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0168] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned task processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0169] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0170] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course 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 the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0171] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A task processing method, the method comprising: Determining a scheduling priority of the first task according to first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level; Selecting a target processor core from N processor cores according to second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1; The first task is executed on the target processor core according to the scheduling priority of the first task.
2. The method according to claim 1, wherein: The selecting a target processor core from the N processor cores according to the second parameter information of the first task includes: Calculate a first remaining computing power value of each processor core of the N processor cores according to the scheduling priority of the first task, the first remaining computing power value of the processor core is the difference between the total computing power value of the processor core and the first computing power value, and the first computing power value is the sum of the computing power values required for the load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task; A target processor core is determined according to the computing power requirement information of the first task and a first remaining computing power value of each processor core of the N processor cores.
3. The method according to claim 2, wherein: The determining the target processor core according to the computing power requirement information of the first task and the first remaining computing power value of each processor core of the N processor cores includes: Determining a first processor core selection range according to the computing power requirement information of the first task, wherein the N processor cores include at least two types of processor cores, different types of processor cores in the at least two types of processor cores have different processing capabilities, and the first processor core selection range includes at least two processor cores in the N processor cores; The target processor core is determined according to the first remaining computing power values of the processor cores within the first processor core selection range.
4. The method according to claim 3, wherein: The determining the target processor core according to the first remaining computing power value of each processor core within the first processor core selection range includes: Determine the processor core with the largest first remaining computing power value within the first processor core selection range as the target processor core; or, A processor core with the largest first remaining computing power value among target class processor cores within the first processor core selection range is determined as a target processor core, wherein the target class processor core is a class of processor cores with the strongest processing capability within the first processor core selection range.
5. The method according to any one of claims 1 to 4, wherein: The selecting a target processor core from the N processor cores according to the second parameter information of the first task comprises: When the first task satisfies the first condition, selecting a target processor core from the N processor cores according to the second parameter information of the first task; The first condition includes any one of the following: the task type is a foreground task, the task importance level is greater than a preset level, and the scheduling priority is greater than a preset priority.
6. The method according to any one of claims 1 to 4, wherein: The first parameter information includes the task type, and the task type includes a foreground task or a background task; The determining the scheduling priority of the first task according to the first parameter information of the first task includes: In a case where the task type of the first task is a foreground task, determining the scheduling priority of the first task to be a first scheduling priority; When the task type of the first task is a background task, determining the scheduling priority of the first task to be a second scheduling priority; The first scheduling priority is higher than the second scheduling priority.
7. A task processing device, comprising: A first determination module, configured to determine a scheduling priority of the first task according to first parameter information of the first task, wherein the first parameter information includes at least one of a task type and a task importance level; A first selection module, configured to select a target processor core from N processor cores according to second parameter information of the first task, wherein the second parameter information includes computing power requirement information and scheduling priority, and N is an integer greater than 1; An execution module is used to execute the first task on the target processor core according to the scheduling priority of the first task.
8. The device according to claim 7, wherein: The first selection module comprises: a calculation unit, configured to calculate a first remaining computing power value of each of the N processor cores according to the scheduling priority of the first task, the first remaining computing power value of the processor core being a difference between a total computing power value of the processor core and a first computing power value, the first computing power value being a sum of computing power values required for a load of all tasks in the processor core whose scheduling priority is higher than or equal to the scheduling priority of the first task; A determination unit is used to determine a target processor core according to the computing power requirement information of the first task and a first remaining computing power value of each processor core in the N processor cores.
9. The device according to claim 8, wherein: The determining unit is specifically used for: Determining a first processor core selection range according to the computing power requirement information of the first task, wherein the N processor cores include at least two types of processor cores, different types of processor cores in the at least two types of processor cores have different processing capabilities, and the first processor core selection range includes at least two processor cores in the N processor cores; The target processor core is determined according to the first remaining computing power values of the processor cores within the first processor core selection range.
10. The device according to claim 9, wherein: The determining unit is specifically used for: Determine the processor core with the largest first remaining computing power value within the first processor core selection range as the target processor core; or, A processor core with the largest first remaining computing power value among target class processor cores within the first processor core selection range is determined as a target processor core, wherein the target class processor core is a class of processor cores with the strongest processing capability within the first processor core selection range.
11. The device according to any one of claims 7 to 10, wherein: The first selection module is specifically used for: When the first task satisfies the first condition, selecting a target processor core from the N processor cores according to the second parameter information of the first task; The first condition includes any one of the following: the task type is a foreground task, the task importance level is greater than a preset level, and the scheduling priority is greater than a preset priority.
12. The device according to any one of claims 7 to 10, wherein: The first parameter information includes the task type, and the task type includes a foreground task or a background task; The first determining module is specifically used for: In a case where the task type of the first task is a foreground task, determining the scheduling priority of the first task to be a first scheduling priority; When the task type of the first task is a background task, determining the scheduling priority of the first task to be a second scheduling priority; The first scheduling priority is higher than the second scheduling priority.
13. An electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the task processing method according to any one of claims 1 to 6 are implemented.
14. A readable storage medium storing a program or an instruction, wherein the program or the instruction, when executed by a processor, implements the steps of the task processing method according to any one of claims 1 to 6.
15. A chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the steps of the task processing method according to any one of claims 1 to 6.
16. A computer program product, wherein the computer program product is executed by at least one processor to implement the steps of the task processing method according to any one of claims 1 to 6.
17. An electronic device, configured to execute the steps of the task processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Task allocation method and device, storage medium and electronic equipment
CN112925616A
Scheduling system and scheduling optimization algorithm in engineering field based on CPU resources
CN113867907A
Unified management method and device for heterogeneous computing clusters, electronic equipment and storage medium
CN114461355A
Task processing method and device and electronic equipment
CN116661964A
Task scheduling method for dispatching tasks based on computing power of different processor cores in heterogeneous multi-core system and related non-transitory computer readable medium
US20150121387A1
Cited By
Model selection method and system for complex scene tasks
CN119440854A
Steel pipe flexible conveying scheduling method and system
CN121094489A
Multi-core-based task scheduling method and device, equipment and medium
CN121681074A
A multi-core-based task scheduling method, apparatus, device, and medium
CN121681074B
Camera computing power dynamic allocation method and system based on heterogeneous computing power cutting
CN121792873A
