Task scheduling method and device, equipment, storage medium and program product
By determining the target processor core according to task affinity and priority in the symmetric multi-processor system, the problem of inefficiency of the scheduling algorithm in the SMP system is solved, and efficient hard real-time task scheduling and load balancing are achieved.
Patent Information
- Application Number
- CN202410763268.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-13
AI Technical Summary
Current scheduling algorithms have low task scheduling efficiency in symmetric multi-processor systems and cannot effectively utilize the principles of task affinity and locality, resulting in low efficiency of hard real-time task scheduling.
By obtaining the affinity and priority information between the target task and multiple processor cores, the target processor core is determined from multiple processor cores to run the target task first, ensuring that the priority of the target task is higher than the target processing The priority and affinity of the task currently running on the processor core.
It improves the efficiency of task scheduling in symmetric multi-processor systems, realizes hard real-time task scheduling with a time complexity of O(1), simplifies the scheduling framework, and enhances load balancing and task core migration management.
Smart Images

Figure CN118642822A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task scheduling method, device, equipment, storage medium and program product. Background Art
[0002] An embedded real-time operating system (RTOS) is an operating system that can control the coordinated and unified operation of all real-time tasks when external events occur. Current RTOS can select the task with the highest priority to run based on the scheduling algorithm to implement task scheduling.
[0003] However, with the development of technology, single-core processor systems used in various fields have gradually evolved into symmetric multiprocessing (SMP) systems (such as vehicle cockpit instrument systems and vehicle control systems). SMP systems include multiple processor cores and can run multiple tasks simultaneously (such as multiple vehicle tasks that need to be run by cockpit instrument systems).
[0004] The current scheduling algorithm can only meet the real-time task scheduling of a single-core processor system (a system with only one processor core that can only run one task at a time), and is less efficient when scheduling tasks on an SMP system. As a result, the efficiency of task scheduling on an SMP system is low. Summary of the invention
[0005] The present application provides a task scheduling method, device, equipment, storage medium and program product to at least solve the problem of low efficiency of scheduling algorithms in related technologies when performing task scheduling on SMP systems. The technical solution of the present application is as follows:
[0006] According to the first aspect of the present application, a task scheduling method is provided, comprising: obtaining task information of a target task and the priority of a currently running task of each processor core in a plurality of processor cores; the task information comprising: the affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core; based on the task information and the priority of the currently running task of each processor core, determining a target processor core from a plurality of processor cores, the target processor core being used to run the target task, the target task having affinity with the target processor core, and the priority of the target task being higher than the priority of the currently running task of the target processor core.
[0007] According to the above technical means, the present application can determine the target processor core for running the target task from multiple processor cores according to the affinity between the target task and each processor core in the multiple processor cores, the priority of the target task and the priority of the currently running task of each processor core, so as to run the target task through the target processor core. That is, the processor core usually gives priority to running tasks with higher priorities. Then, when the priority of the target task is greater than the priority of the currently running task of a processor core in the multiple processor cores, and the target task has affinity with the processor core (that is, the target task is allowed to run on the processor core), the target task can run on the processor core. The technical problem of low efficiency of the current scheduling algorithm in the prior art when scheduling tasks for the SMP system is solved. Thereby, the efficiency of scheduling tasks for the SMP system is improved.
[0008] In a possible implementation, a target processor core is determined from multiple processor cores based on task information and the priority of a task currently running on each processor core, including: when the priority of the target task is higher than a first priority, the target processor core is determined from the multiple processor cores based on the affinity between the target task and each processor core; the first priority is the lowest priority among multiple priorities corresponding to the multiple processor cores.
[0009] According to the above technical means, the present application can determine the target processor core from multiple processor cores according to the affinity between the target task and each processor core when the priority of the target task is higher than the lowest priority among the multiple priorities corresponding to the multiple processor cores. That is, the priority of the target task is higher than the lowest priority corresponding to the multiple processor cores, indicating that the target task can be run on the processor core corresponding to the lowest priority, thereby ensuring that the target task can be run by the processor core.
[0010] In a possible implementation, when the priority of the target task is higher than the first priority, the target processor core is determined from multiple processor cores based on the affinity between the target task and each processor core, including: when the first processor core set and the second processor core set have an intersection, the target processor core is determined from the second processor core set; the first processor core set includes: at least one processor core that has affinity with the target task among the multiple processor cores; the second processor core set includes: at least one processor core corresponding to the lowest priority among the multiple priorities; or, when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced, the third processor core is determined as the target processor core, the third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core other than the third processor core among the multiple processor cores.
[0011] According to the above technical means, the present application can determine the processor core corresponding to the lowest priority as the target processor core when there is an intersection between the processor core with affinity to the target task and the processor core corresponding to the lowest priority. That is, usually when the target task has affinity with each processor core, there will be an intersection between the processor core with affinity to the target task and the processor core corresponding to the lowest priority, then the target task can be determined from the processor core corresponding to the lowest priority. It is also possible to determine the processor core as the target task when there is no intersection between the processor core with affinity to the target task and the processor core corresponding to the lowest priority, the target task has affinity only with a certain processor core, and the target task and the currently running task are allowed to be replaced. That is, usually when the target task has affinity only with a certain processor core, there will be an intersection between the processor core with affinity to the target task and the processor core corresponding to the lowest priority, and the target task can only run on this processor core. Thereby determining the processor core for running the task.
[0012] In a possible implementation, when the first processor core set and the second processor core set have an intersection, determining a target processor core from the second processor core set includes: when the first processor core set and the second processor core set have an intersection and the processor core that last ran the target task is a processor core in the second processor core set, determining the processor core that last ran the target task as the target processor core; or, when the first processor core set and the second processor core set have an intersection and the processor core that last ran the target task is not a processor core in the second processor core set, determining any second processor core in the second processor core set as the target processor core.
[0013] According to the above technical means, the present application can determine the processor core that last ran the target task as the target processor core, that is, usually running the target task through the processor core that last ran the target task can increase the speed of the target task.
[0014] In a possible implementation, when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced, the third processor core is determined as the target processor core, including: when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core, the third processor core is determined as the target processor core; or when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value, the third processor core is determined as the target processor core, and the fifth processor core is determined as the processor core that runs the currently running task of the third processor core, and the fifth processor core is any processor core in the second processor core set.
[0015] According to the above technical means, the present application can determine the processor core currently running the task as the target processor core, and determine other processor cores as the processor cores running the currently running task when the currently running task of the processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value. That is, when the currently running task of the processor core has affinity with each processor core, it means that the currently running task can be migrated to other processor cores for running, but it will cause the current running task to be frequently migrated. By setting a preset value, the current running task can be avoided from being frequently migrated. Thereby, the processor core that runs the task is determined.
[0016] In a possible implementation, when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core, the third processor core is determined as the target processor core, including: when the first processor core set and the second processor core set do not have an intersection, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task, the third processor core is determined as the target processor core.
[0017] According to the above technical means, the present application can determine the third processor core as the target processor core when the priority of the task currently running on the third processor core is lower than the priority of the target task, ensuring that the target task can replace the currently running task and run on the third processor core.
[0018] According to the second aspect provided by the present application, a task scheduling device is provided, including an acquisition module and a determination module; the acquisition module is used to acquire task information of a target task and the priority of a currently running task of each processor core in a plurality of processor cores; the task information includes: the affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core; the determination module is used to determine a target processor core from a plurality of processor cores based on the task information and the priority of the currently running task of each processor core, the target processor core being used to run the target task, the target task having affinity with the target processor core, and the priority of the target task being higher than the priority of the currently running task of the target processor core.
[0019] In one possible implementation, the determination module is also used to determine the target processor core from multiple processor cores based on the affinity between the target task and each processor core when the priority of the target task is higher than the first priority; the first priority is the lowest priority among the multiple priorities corresponding to the multiple processor cores.
[0020] In a possible implementation, the determination module is further used to determine the target processor core from the second processor core set when there is an intersection between the first processor core set and the second processor core set; the first processor core set includes: at least one processor core having affinity with the target task among the multiple processor cores; the second processor core set includes: at least one processor core corresponding to the lowest priority among multiple priorities; the determination module is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced, the third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core other than the third processor core among the multiple processor cores.
[0021] In one possible implementation, the determination module is further used to determine the processor core that last ran the target task as the target processor core when there is an intersection between the first processor core set and the second processor core set, and the processor core that last ran the target task is a processor core in the second processor core set; the determination module is further used to determine any second processor core in the second processor core set as the target processor core when there is an intersection between the first processor core set and the second processor core set, and the processor core that last ran the target task is not a processor core in the second processor core set.
[0022] In a possible implementation, the determination module is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core; the determination module is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value, and determine the fifth processor core as the processor core that runs the currently running task of the third processor core, and the fifth processor core is any processor core in the second processor core set.
[0023] In a possible implementation, the determination module is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task.
[0024] According to the third aspect provided by the present application, an electronic device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement the method of the above-mentioned first aspect and any possible implementation manner thereof.
[0025] According to the fourth aspect provided by the present application, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method in the above-mentioned first aspect and any possible implementation method thereof.
[0026] According to the fifth aspect provided by the present application, a computer program product is provided, the computer program product comprising computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method of the above-mentioned first aspect and any possible implementation manner thereof.
[0027] Therefore, the above technical features of the present application have the following beneficial effects:
[0028] (1) The present application can determine the target processor core for running the target task from multiple processor cores based on the affinity between the target task and each processor core in the multiple processor cores, the priority of the target task and the priority of the currently running task of each processor core, so as to run the target task through the target processor core. That is, the processor core usually gives priority to running tasks with higher priorities. Then, when the priority of the target task is greater than the priority of the currently running task of a processor core in the multiple processor cores and the target task has affinity with the processor core (that is, the target task is allowed to run on the processor core), the target task can run on the processor core. The technical problem of low efficiency of the current scheduling algorithm in the prior art when scheduling tasks for the SMP system is solved. Thereby, the efficiency of task scheduling for the SMP system is improved.
[0029] (2) When the priority of the target task is higher than the lowest priority among the multiple priorities corresponding to the multiple processor cores, the present application can determine the target processor core from the multiple processor cores according to the affinity between the target task and each processor core. That is, the priority of the target task is higher than the lowest priority corresponding to the multiple processor cores, indicating that the target task can be run on the processor core corresponding to the lowest priority, thereby ensuring that the target task can be run by the processor core.
[0030] (3) The present application can determine the processor core corresponding to the lowest priority as the target processor core when the processor core with affinity to the target task and the processor core corresponding to the lowest priority have an intersection. That is, usually when the target task has affinity with each processor core, the processor core with affinity to the target task and the processor core corresponding to the lowest priority will have an intersection, then the target task can be determined from the processor core corresponding to the lowest priority. It is also possible to determine the processor core as the target task when the processor core with affinity to the target task and the processor core corresponding to the lowest priority do not have an intersection, the target task has affinity with only one processor core, and the target task and the currently running task are allowed to be replaced. That is, usually when the target task has affinity with only one processor core, the processor core with affinity to the target task and the processor core corresponding to the lowest priority will have an intersection, and the target task can only run on this processor core. Thereby determining the processor core that runs the task.
[0031] (4) The present application can determine the processor core that last ran the target task as the target processor core, that is, in general, running the target task through the processor core that last ran the target task can increase the speed of running the target task.
[0032] (5) The present application can determine the processor core currently running the task as the target processor core, and determine other processor cores as the processor cores running the currently running task when the currently running task of the processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value. That is, when the currently running task of the processor core has affinity with each processor core, it means that the currently running task can be migrated to other processor cores for running, but this will cause the currently running task to be frequently migrated. By setting a preset value, the frequent migration of the currently running task can be avoided. In this way, the processor core running the task is determined.
[0033] (6) The present application can determine the third processor core as the target processor core when the priority of the task currently running on the third processor core is lower than the priority of the target task, thereby ensuring that the target task can replace the currently running task and run on the third processor core.
[0034] It should be noted that the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here.
[0035] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0037] Figure 1 is a structural diagram of a task scheduling system according to an exemplary embodiment;
[0038] Figure 2 is a flowchart of a task scheduling method according to an exemplary embodiment;
[0039] Figure 3 is a schematic diagram of an SMP system and a ready list according to an exemplary embodiment;
[0040] Figure 4 is a flowchart of another task scheduling method according to an exemplary embodiment;
[0041] Figure 5 is a flowchart of another task scheduling method according to an exemplary embodiment;
[0042] Figure 6 is a flowchart of another task scheduling method according to an exemplary embodiment;
[0043] Figure 7 is a flowchart of another task scheduling method according to an exemplary embodiment;
[0044] Figure 8 is a flowchart of another task scheduling method according to an exemplary embodiment;
[0045] Fig. 9 is a schematic diagram of a flow chart of determining a set of processor cores to be scheduled according to an exemplary embodiment;
[0046] Fig.10 is a schematic diagram of a process of executing a scheduling task according to an exemplary embodiment;
[0047] Fig.11 is a block diagram of a task scheduling device according to an exemplary embodiment;
[0048] Fig.12 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0049] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0051] SMP system refers to a group of processor cores gathered on a computer, and the processor cores share the memory subsystem and bus structure. SMP system is a widely used parallel technology relative to asymmetric multi-processing technology. RTOS is an operating system that can quickly process external events and complete specified steps within a specified time, and control the coordinated and unified operation of all real-time tasks. RTOS is widely used in consumer electronics, industrial equipment, and scientific research equipment, and plays a key role in safety-critical fields such as aviation control systems, automotive industry, and banking and financial control.
[0052] The current RTOS can select the task with the highest priority to run based on the preemptive priority scheduling algorithm to implement task scheduling.
[0053] However, in order to ensure the real-time performance of RTOS, the time complexity of its task scheduling algorithm should be O(1), that is, the task scheduling algorithm is independent of the number of tasks in RTOS, CPU load, etc. If this time complexity is not met, the real-time performance of RTOS will not be guaranteed. The current scheduling algorithm can only meet the real-time task scheduling of single-core processor systems, and is inefficient when scheduling tasks on SMP systems. It is impossible to consider task affinity and locality principles when scheduling tasks, and cannot meet the hard real-time task scheduling requirements of O(1). The scheduling framework is complex, inefficient, lacks scalability, does not consider the load balancing between bound core tasks (i.e., tasks that have affinity only with a certain processor core) and global tasks (i.e., tasks that have affinity only with each processor core), and cannot manage and restrict the migration between task cores. Therefore, how to implement a hard real-time task scheduling algorithm that takes into account task affinity settings and has a time complexity of O(1) on an SMP system has become an urgent problem to be solved in the RTOS field.
[0054] For ease of understanding, the task scheduling method provided in this application is specifically introduced below with reference to the accompanying drawings.
[0055] A task scheduling method provided in an embodiment of the present application can be applied to a task scheduling system. Figure 1 FIG. 1 is a schematic diagram showing a structure of a task scheduling system according to an exemplary embodiment. Figure 1 As shown, the task scheduling system 10 includes: an electronic device 11 and an SMP system 12. The SMP system 12 includes a plurality of processor cores (ie, cores).
[0056] The electronic device 11 is used to obtain task information of the target task and the priority of the currently running task of each processor core in the multiple processor cores included in the SMP system 12, and determine the target processor core from the multiple processor cores based on the task information and the priority of the currently running task of each processor core. The target processor core in the SMP system 12 is used to run the target task.
[0057] Figure 2 is a flowchart of a task scheduling method according to an exemplary embodiment, which is applied to an electronic device, such as Figure 2 As shown, the task scheduling method includes the following steps:
[0058] S201: Obtain task information of a target task and a priority of a currently running task of each processor core among multiple processor cores.
[0059] The task information includes: the affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core.
[0060] Optionally, the electronic device can make necessary data structure arrangements for the task. Specifically, the ready table (i.e., ready_table) to which the task belongs includes four main data members, namely, bitmap data (i.e., bit_map, used to speed up the index of the ready table), the highest priority of the task in the ready table (i.e., highest_ready_priority), the highest priority task in the ready table (i.e., highest_ready_task), and the ready queue (i.e., ready_queue, including ready tasks of each priority).
[0061] The electronic device can abstract the data structure of the processor core, namely cpu_core and cpu_set. Specifically, cpu_core has two data members, one is the local ready table of each processor core (i.e. local_ready_table), and the other is each processor core included in the processor core set (i.e. global_cpu_set), and global_cpu_set is globally shared by all processor cores. Therefore, each processor core can understand the operation status of each processor core in the entire processor core set through global_cpu_set.
[0062] cpu_set is used to characterize the running status of each processor core in the processor core set. cpu_set has four data members, namely low_set, global_ready_table, lowest_priority and all_cpu_mask. low_set represents the processor core with the lowest priority of the running task in the processor core set; global_ready_table is the global ready table, and the tasks in this table have global affinity (that is, the tasks in this table have affinity with each processor core); lowest_priority records the priority of the tasks in low_set; all_cpu_mask is the set of online processor cores in the entire SMP system.
[0063] In addition to the above data structures, the electronic device can maintain some other necessary data members of the task, namely affinity_cpu_set, last_sched_cpu and task_priority. affinity_cpu_set is the set of processor cores with affinity to the task, which indicates which processor cores the task can run on; last_sched_cpu records the unique code (Identity document, ID) of the processor core on which the task was last put into operation. In order to effectively utilize the principle of locality, it is necessary to put the task on the processor core on which it was previously running as much as possible; task_priority is the priority of the task.
[0064] Optionally, when an external event or an internal event triggers a task to become a ready task (i.e., a target task) and the target task is added to a corresponding ready queue in the ready table to which it belongs, when the target task is added to the ready table and becomes the first task of a ready queue, the SMP system will be triggered to perform a task scheduling check. Furthermore, the electronic device can obtain the task information of the target task and the priority of the currently running task of each processor core in the multiple processor cores.
[0065] For example, Figure 3 As shown, the SMP system includes n (n is an integer greater than 1) processor cores (i.e., core-1, ..., core-n), the target task is task-a, and the ready list to which the target task is added includes 256 ready queues. One ready queue corresponds to one priority, priority-0 is the highest priority, and so on, priority-255 is the lowest priority. The priority of task-a and task-b in the ready list is priority-0, the priority of task-c is priority-2, and the priority of task-d is priority-255.
[0066] It should be noted that in an SMP system, each processor core has its own local ready list, which is used to store tasks bound to this processor core (i.e., tasks that have affinity only with this processor core). At the same time, the SMP system maintains a global ready list, and tasks stored in the global ready list can be delegated to any processor core for execution (i.e., the global ready list is used to store tasks that have affinity with each processor core). A highest priority task and a highest priority task pointer are maintained in the data structure of the local ready table as local candidate tasks for the local ready table (i.e., the next task to be run in the local ready table). In the global ready table, a global highest priority and a highest priority task are also maintained as global candidate tasks (i.e., the next task to be run in the global ready table).
[0067] S202: Determine a target processor core from multiple processor cores based on the task information and the priority of the task currently running on each processor core.
[0068] The target processor core is used to run the target task, the target task has affinity with the target processor core, and the priority of the target task is higher than the priority of the task currently running on the target processor core.
[0069] When the target task becomes the first task of a ready queue in the global ready list or the local ready list, the target task has the possibility of being scheduled, which will trigger the first stage of the process of determining the set of processor cores to be scheduled. If the target task does not meet the scheduling conditions after checking, an empty set is returned, otherwise the set of processor cores that need to be scheduled is returned (the set of processor cores that need to be scheduled includes the target processor core).
[0070] If the first stage returns an empty set, the scheduling of the second stage will not be executed; if the set returned by the first stage is not an empty set, then the scheduling task execution process of the second stage will be entered. In the second stage, the electronic device can determine whether there are other processor cores that need to be scheduled other than the processor core corresponding to the electronic device. If necessary, the electronic device can send an Inland Common Points (IPI) notification under the transportation terms to other processor cores to notify other processor cores to schedule tasks. If the processor core corresponding to the electronic device is in the set of processor cores that need to be scheduled, then the processor core corresponding to the electronic device executes the task scheduling, otherwise it directly returns the scheduling completion.
[0071] It should be noted that the electronic device may be any processor core among a plurality of processor cores included in the SMP system.
[0072] In one possible implementation, by dynamically maintaining low_set and the lowest priority corresponding to low_set, the lowest priority of tasks currently running on all processor cores can be directly obtained without traversing all processor cores. At the same time, a preliminary determination can be made as to whether the target task can meet the prerequisites for scheduling checks, thereby improving the efficiency of task scheduling.
[0073] This application divides the scheduling framework of the entire task into two stages. One stage is used to determine which processor cores among multiple processor cores need to be scheduled for task scheduling (searching the set of processor cores to be scheduled), and the second stage is used to execute scheduling tasks and notify scheduling, which simplifies the system scheduling framework. The framework has high flexibility and scalability. According to the requirements of different business scenarios, the algorithm models of the two stages can be flexibly adjusted to improve the efficiency of task scheduling.
[0074] Figure 4 is a flowchart of a task scheduling method according to an exemplary embodiment. Figure 4 As shown, the method in the above step S202 specifically includes the following steps:
[0075] S301 : When the priority of the target task is higher than the first priority, determine a target processor core from multiple processor cores according to the affinity between the target task and each processor core.
[0076] The first priority is the lowest priority among multiple priorities corresponding to multiple processor cores.
[0077] Optionally, when the priority of the target task is higher than the first priority (ie, lowest_priority), the electronic device may determine the target processor core from the plurality of processor cores according to the affinity between the target task and each processor core.
[0078] In a possible implementation, the priority of the target task is higher than the lowest priority of the tasks currently running on each processor core among the multiple processor cores, and the lowest priority of the tasks currently running on each processor core is the highest priority of the tasks in the ready queues of the local ready table and the global ready table of each processor core. Therefore, the priority of the target task is higher than the priority of the tasks in the ready queues of the local ready table and the global ready table of each processor core, thereby implementing a hard real-time scheduling algorithm that supports task affinity on an RTOS system and has a scheduling algorithm time complexity of O(1), and the time complexity is independent of the CPU load and the number of tasks.
[0079] Specifically, the highest priority task and the task pointer are dynamically maintained in the ready queues included in the local ready list and the ready queues included in the global ready list. When a processor core selects a task to be put into operation, it only needs to compare the highest priority corresponding to the processor core with the highest priority corresponding to the global ready list, without having to care about how many tasks are put into operation in the system, and it has nothing to do with the number of tasks in the system. In addition, in the two-stage scheduling framework, there is no need to traverse any ready queue, so the time complexity is O(1), not O(n).
[0080] Figure 5 is a flowchart of another task scheduling method according to an exemplary embodiment. Figure 5 As shown, the method in the above step S301 specifically includes step S401 or S402:
[0081] S401: When there is an intersection between the first set of processor cores and the second set of processor cores, determine a target processor core from the second set of processor cores.
[0082] The first processor core set (ie affinity_cpu_set) includes: at least one processor core having affinity with the target task among the multiple processor cores; the second processor core set (ie low_set) includes: at least one processor core corresponding to the lowest priority among the multiple priorities.
[0083] Optionally, when the first set of processor cores and the second set of processor cores have an intersection, the electronic device may determine the target processor core from the second set of processor cores.
[0084] S402: When there is no intersection between the first processor core set and the second processor core set, the target task and the third processor core have affinity, and the target task and the currently running task are allowed to be replaced, determine the third processor core as the target processor core.
[0085] The third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core other than the third processor core among the multiple processor cores.
[0086] Optionally, when the first processor core set and the second processor core set have no intersection, the target task and the third processor core have affinity, and the target task and the currently running task are allowed to be replaced, the electronic device may determine the third processor core as the target processor core.
[0087] Figure 6 is a flowchart of another task scheduling method according to an exemplary embodiment. Figure 6 As shown, the method in the above step S401 specifically includes step S501 or S502:
[0088] S501: When the first processor core set and the second processor core set have an intersection and the processor core that last executed the target task is a processor core in the second processor core set, determine the processor core that last executed the target task as a target processor core.
[0089] Optionally, when the processor core that last executed the target task is a processor core in the second set of processor cores, the electronic device may determine the processor core that last executed the target task as the target processor core.
[0090] S502: When the first processor core set and the second processor core set have an intersection and the processor core that last executed the target task is not a processor core in the second processor core set, determine any second processor core in the second processor core set as a target processor core.
[0091] Optionally, when the processor core that last ran the target task is not a processor core in the second processor core set, the electronic device may determine any second processor core in the second processor core set as the target processor core, or may determine the processor core with the highest ranking as the target processor core according to the order of each processor core in the second processor core set.
[0092] Figure 7 is a flowchart of another task scheduling method according to an exemplary embodiment. Figure 7 As shown, the method in the above step S402 specifically includes step S601 or S602:
[0093] S601. When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core, determine the third processor core as the target processor core.
[0094] Optionally, when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core, the electronic device may determine the third processor core as the target processor core.
[0095] S602: When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value, the third processor core is determined as the target processor core, and the fifth processor core is determined as the processor core that runs the currently running task of the third processor core.
[0096] The fifth processor core is any processor core in the second processor core set.
[0097] Optionally, when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value, the electronic device may determine the third processor core as the target processor core, and determine the fifth processor core as the processor core that runs the task currently running by the third processor core.
[0098] In one possible implementation, in order to avoid a task being ready and causing a large number of processor cores to migrate tasks, the present application controls the number of processor cores included in low_set during scheduling, and uses a threshold to limit the probability of inter-core task migration. According to the system operating environment, the probability of inter-core migration of tasks can be reduced, thereby improving the stability and efficiency of system operation.
[0099] Figure 8 is a flowchart of another task scheduling method according to an exemplary embodiment. Figure 8 As shown, the method in the above step S601 specifically includes the following steps:
[0100] S701. When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task, the third processor core is determined as the target processor core.
[0101] Optionally, when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task, the electronic device may determine the third processor core as the target processor core.
[0102] For example, Fig. 9 is a flow chart showing a method of determining a set of processor cores to be scheduled according to an exemplary embodiment. Fig. 9As shown, when the target task becomes the first task of a ready queue of the ready list to which it belongs, the electronic device determines whether the priority of the target task is higher than the lowest_priority. If the priority of the target task is not higher than the lowest_priority, the target task cannot be scheduled, and the electronic device directly returns an empty set to end the process. If the priority of the target task is higher than the lowest_priority, the electronic device checks whether the affinity_cpu_set of the target task and the low_set have an intersection.
[0103] If affinity_cpu_set and low_set have an intersection, the electronic device determines whether the processor core that last ran the target task is in low_set; if affinity_cpu_set and low_set do not have an intersection, the electronic device determines whether the target task is bound to a processor core. If the processor core that last ran the target task is in low_set, the processor core that last ran the target task is marked as needing to be scheduled; if the processor core that last ran the target task is not in low_set, the electronic device marks any processor core in low_set as needing to be scheduled.
[0104] If the target task is not bound to a processor core, the target task cannot be scheduled, and the electronic device directly returns an empty set; if the target task is bound to a processor core, the electronic device determines whether the bound processor core (i.e., the third processor core in this application) can be preempted. If the bound processor core cannot be preempted, the target task cannot be scheduled, and the electronic device directly returns an empty set; if the bound processor core can be preempted (i.e., the currently running task in this application is allowed to be replaced), the electronic device determines whether the task running on the bound processor core is bound to the processor core.
[0105] If the task running on the bound processor core is bound to the processor core, the electronic device determines whether the priority of the target task is higher than the priority of the task running on the bound processor core. If the priority of the target task is higher than the priority of the task running on the bound processor core, the electronic device marks the bound processor core as needing to be scheduled; if the priority of the target task is not higher than the priority of the task running on the bound processor core, the target task cannot be scheduled, and the electronic device directly returns an empty set.
[0106] If the task running on the bound processor core is not bound to the processor core, the electronic device determines whether the number of processor cores included in low_set is less than the preset value. If the number of processor cores included in low_set is less than the preset value, the target task cannot be scheduled, and the electronic device directly returns an empty set; if the number of processor cores included in low_set is not less than the preset value, the electronic device marks that the bound processor core needs to be scheduled, and marks that all processor cores included in low_set need to be scheduled.
[0107] Fig.10 According to an exemplary embodiment, a flowchart of executing a scheduling task is shown. Fig.10 As shown, the processor core corresponding to the electronic device inputs a set of processor cores that need to be scheduled, and the processor core corresponding to the electronic device checks whether there are processor cores other than the processor core corresponding to the electronic device in the set of processor cores that need to be scheduled that need to be scheduled. If there are processor cores other than itself in the set of processor cores that need to be scheduled that need to be scheduled, the processor core corresponding to the electronic device sends an IPI notification to the processor cores other than itself; if there are no processor cores other than itself in the set of processor cores that need to be scheduled that need to be scheduled, the processor core corresponding to the electronic device does not send an IPI notification.
[0108] Furthermore, each processor core checks whether it needs to be scheduled. When a processor core needs to be scheduled, the processor core moves the currently running task back to its ready list, or enters a specified suspended state to abandon the running right of the processor core. Furthermore, the task with the highest priority is selected from the local ready table and the global ready table corresponding to the processor core, and the task with the highest running priority is removed from the ready table to which it belongs, and the highest_ready_task and highest_ready_priority of the ready table to which it belongs are updated. Furthermore, the context of the task with the highest priority is restored, and the task with the highest priority is put into operation to complete the task scheduling on the processor core. When each processor core checks that it does not need to be scheduled, the process ends.
[0109] It should be noted that if the priority of the highest priority task in the local ready table corresponding to the processor core is the same as the priority of the highest priority task in the global ready table, then it is necessary to consider the load balancing between local tasks (i.e., tasks in the local ready table) and global tasks. If the last task run by the processor core was a global task, then the local task is selected. If the last task run by the processor core was a local task, then the global task is selected.
[0110] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, the task scheduling device or electronic device includes a hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0111] The embodiment of the present application can divide the functional modules of the task scheduling device or electronic device according to the above method. For example, the task scheduling device or electronic device can include various functional modules corresponding to the various functional divisions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0112] Fig.11 is a block diagram of a task scheduling device according to an exemplary embodiment. Fig.11 The task scheduling device 130 includes: an acquisition module 1301 and a determination module 1302.
[0113] Acquisition module 1301 is used to obtain task information of the target task and the priority of the currently running task of each processor core in multiple processor cores; the task information includes: the affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core.
[0114] The determination module 1302 is used to determine a target processor core from multiple processor cores based on the task information and the priority of the task currently running on each processor core. The target processor core is used to run the target task. The target task has affinity with the target processor core, and the priority of the target task is higher than the priority of the task currently running on the target processor core.
[0115] In one possible implementation, the determination module 1302 is also used to determine the target processor core from multiple processor cores based on the affinity between the target task and each processor core when the priority of the target task is higher than the first priority; the first priority is the lowest priority among the multiple priorities corresponding to the multiple processor cores.
[0116] In one possible implementation, the determination module 1302 is further used to determine a target processor core from the second processor core set when there is an intersection between the first processor core set and the second processor core set; the first processor core set includes: at least one processor core among multiple processor cores that has affinity with the target task; the second processor core set includes: at least one processor core corresponding to the lowest priority among multiple priorities; the determination module 1302 is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced, the third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core among the multiple processor cores except the third processor core.
[0117] In one possible implementation, the determination module 1302 is further used to determine the processor core that last ran the target task as the target processor core when the first processor core set and the second processor core set have an intersection and the processor core that last ran the target task is a processor core in the second processor core set; the determination module 1302 is further used to determine any second processor core in the second processor core set as the target processor core when the first processor core set and the second processor core set have an intersection and the processor core that last ran the target task is not a processor core in the second processor core set.
[0118] In one possible implementation, the determination module 1302 is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core; the determination module 1302 is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each processor core, and the number of processor cores included in the second processor core set is less than a preset value, and determine the fifth processor core as the processor core that runs the currently running task of the third processor core, and the fifth processor core is any processor core in the second processor core set.
[0119] In one possible implementation, the determination module 1302 is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task.
[0120] Fig.12 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Fig.12 As shown, the electronic device 160 includes but is not limited to: a processor 1601 and a memory 1602 .
[0121] The memory 1602 is used to store executable instructions of the processor 1601. It can be understood that the processor 1601 is configured to execute instructions to implement the task scheduling method in the above embodiment.
[0122] It should be noted that those skilled in the art can understand that Fig.12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Fig.12 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0123] The processor 1601 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1602, and calling data stored in the memory 1602, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1601 may include one or more processing modules. Optionally, the processor 1601 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1601.
[0124] The memory 1602 may be used to store software programs and various data. The memory 1602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one functional module (such as an acquisition unit, a determination unit, a processing unit, etc.), etc. In addition, the memory 1602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0125] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1602 including instructions. The above instructions can be executed by the processor 1601 of the electronic device 160 to implement the task scheduling method in the above embodiment.
[0126] In actual implementation, Fig.11 The functions of the acquisition module 1301 and the determination module 1302 in Fig.12 The processor 1601 in the memory 1602 calls the computer program stored in the memory 1602. The specific execution process can refer to the description of the task scheduling method in the above embodiment, which will not be repeated here.
[0127] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0128] In an exemplary embodiment, the embodiment of the present application further provides a computer program product including one or more instructions, and the one or more instructions can be executed by the processor 1601 of the electronic device to complete the task scheduling method in the above embodiment.
[0129] It should be noted that when the instructions in the above-mentioned computer-readable storage medium or one or more instructions in the computer program product are executed by the processor of the electronic device, the various processes of the above-mentioned task scheduling method embodiment are implemented, and the same technical effect as the above-mentioned task scheduling method can be achieved. To avoid repetition, they will not be repeated here.
[0130] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0131] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0132] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0134] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the full classification part or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute the full classification part or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD and other media that can store program code.
[0135] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A task scheduling method, characterized in that: The method comprises: Acquire task information of a target task and the priority of a currently running task of each processor core in a plurality of processor cores; the task information includes: affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core; Based on the task information and the priority of the task currently running on each processor core, a target processor core is determined from the multiple processor cores, the target processor core is used to run the target task, the target task has affinity with the target processor core, and the priority of the target task is higher than the priority of the task currently running on the target processor core.
2. The method according to claim 1, characterized in that The step of determining a target processor core from the plurality of processor cores based on the task information and the priority of the task currently running on each processor core comprises: When the priority of the target task is higher than the first priority, the target processor core is determined from the multiple processor cores according to the affinity between the target task and each of the processor cores; the first priority is the lowest priority among the multiple priorities corresponding to the multiple processor cores.
3. The method according to claim 2, characterized in that When the priority of the target task is higher than the first priority, determining the target processor core from the multiple processor cores according to the affinity between the target task and each of the processor cores includes: When the first processor core set and the second processor core set have an intersection, determining the target processor core from the second processor core set; the first processor core set includes: at least one processor core having affinity with the target task among the multiple processor cores; the second processor core set includes: at least one processor core corresponding to the lowest priority among the multiple priorities; or, When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced, the third processor core is determined as the target processor core, the third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core among the multiple processor cores except the third processor core.
4. The method according to claim 3, characterized in that When the first processor core set and the second processor core set have an intersection, determining the target processor core from the second processor core set includes: When the first processor core set and the second processor core set have an intersection, and the processor core that last ran the target task is a processor core in the second processor core set, determining the processor core that last ran the target task as the target processor core; or, When the first set of processor cores and the second set of processor cores have an intersection, and the processor core that last ran the target task is not a processor core in the second set of processor cores, any second processor core in the second set of processor cores is determined as the target processor core.
5. The method according to claim 3, characterized in that: The method of determining the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task and the third processor core have affinity, and the target task and the currently running task are allowed to be replaced, includes: When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core has no affinity with the fourth processor core, the third processor core is determined as the target processor core; or, When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with each of the processor cores, and the number of processor cores included in the second processor core set is less than a preset value, the third processor core is determined as the target processor core, and the fifth processor core is determined as the processor core that runs the currently running task of the third processor core, and the fifth processor core is any processor core in the second processor core set.
6. The method according to claim 5, characterized in that The method of determining the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, and the currently running task of the third processor core does not have affinity with the fourth processor core includes: When there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, the target task and the currently running task are allowed to be replaced, the currently running task of the third processor core has affinity with the third processor core, the currently running task of the third processor core does not have affinity with the fourth processor core, and the priority of the currently running task of the third processor core is lower than the priority of the target task, the third processor core is determined as the target processor core.
7. A task scheduling device, characterized in that: Including acquisition module and determination module; The acquisition module is used to acquire task information of the target task and the priority of the currently running task of each processor core in the multiple processor cores; The task information includes: the affinity between the target task and each processor core, and the priority of the target task; the affinity is used to indicate whether the target task is allowed to run on the processor core; The determination module is used to determine a target processor core from the multiple processor cores based on the task information and the priority of the task currently running on each processor core, the target processor core is used to run the target task, the target task has affinity with the target processor core, and the priority of the target task is higher than the priority of the task currently running on the target processor core.
8. The device according to claim 7, characterized in that The determination module is further configured to determine the target processor core from the multiple processor cores according to the affinity between the target task and each of the processor cores when the priority of the target task is higher than the first priority; The first priority is the lowest priority among multiple priorities corresponding to the multiple processor cores.
9. The device according to claim 8, characterized in that The determination module is further configured to determine the target processor core from the second set of processor cores when there is an intersection between the first set of processor cores and the second set of processor cores; The first processor core set includes: at least one processor core among the multiple processor cores having affinity with the target task; the second processor core set includes: at least one processor core corresponding to the lowest priority among the multiple priorities; The determination module is further used to determine the third processor core as the target processor core when there is no intersection between the first processor core set and the second processor core set, the target task has affinity with the third processor core, and the target task and the currently running task are allowed to be replaced. The third processor core is any one of the multiple processor cores, and the fourth processor core is a processor core among the multiple processor cores except the third processor core.
10. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 6.
11. A computer-readable storage medium, characterized in that: When the computer-executable instructions stored in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can perform the method as claimed in any one of claims 1 to 6.
12. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device performs the method according to any one of claims 1 to 6.
Citation Information
Cited By
Task scheduling method and device, equipment, storage medium and chip
CN119025248A
Task scheduling method, device, equipment, storage medium and chip
CN119025248B
