Grouping binding-based many-core processor task scheduling method and device
By adopting a task scheduling method based on packet binding in the multi-core processor, the problems of cache division and shared resource management between multiple cores are solved, the effective scheduling and real-time requirements of tasks are realized, and the system maintenance overhead is reduced.
Patent Information
- Application Number
- CN202510330261.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-04-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In a multi-core processor environment, problems such as cache division, shared resource management and parallel computing task division between multiple cores have increased system maintenance overhead, making it difficult to ensure real-time tasks and comprehensive system management requirements.
The multi-core processor task scheduling method based on packet binding is adopted. By dividing the CPU core into multiple CPU groups, each group maintains a local scheduling queue, and using a hierarchical scheduling algorithm and the best priority allocation method, task allocation and priority setting are performed to achieve effective task scheduling.
It effectively solves the problems of cache division, shared resource management and parallel computing task division among multiple cores, reduces the maintenance overhead of parallel tasks, and ensures real-time and comprehensive management requirements of system tasks.
Smart Images

Figure CN119829260A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of many-core processors, and specifically provides a many-core processor task scheduling method and device based on group binding. Background Art
[0002] With the improvement of embedded technology and the expansion of product demand, the industry now has stricter requirements on processor performance and efficiency. The traditional single-core mode has performance bottlenecks, so multi-core processors are introduced. In a multi-core environment, the frequency requirements for each core in the processor are relaxed, and the processor performance is easy to improve. However, when configuring an operating system for it, it is necessary to consider issues such as cache partitioning and shared resource management between multiple cores. With the increase in the number of cores, from multi-core to many-core, the maintenance overhead of the above system gradually increases and becomes more and more important. On the other hand, with the increase in the application scenarios of embedded systems, the functions that need to be integrated in a single system are becoming more diversified, and tasks are difficult to compare through a single metric. For example, in some areas of radar electronic reconnaissance, the embedded operating system deployed on the device not only needs to meet the real-time response requirements of the task, but also needs to have other general functions such as complex computing processing and integrated management modules.
[0003] Embedded technology is becoming more and more popular in people's work and life. Embedded applications are widely used in industrial flow control, vehicle manufacturing, smart terminals, Internet of Things products and other fields. In these fields, most integrated devices will deploy embedded operating systems on-chip instead of loading bare metal drivers to manage the devices. With the expansion of the scope of application and the deepening of application, in order to cope with huge demands, the complexity of embedded systems has gradually increased, and a single system needs to realize more and more functions, which puts certain requirements on the operating system deployed on it.
[0004] Therefore, how to effectively solve the problems of cache partitioning, shared resources and parallel computing task partitioning among multiple cores of a many-core processor, and reduce the maintenance overhead of parallel tasks while ensuring the real-time performance of system tasks is an urgent problem to be solved by technical personnel in this field. Summary of the invention
[0005] The present invention aims at solving the above-mentioned deficiencies of the prior art and provides a highly practical multi-core processor task scheduling method based on group binding.
[0006] A further technical task of the present invention is to provide a multi-core processor task scheduling device based on group binding that is reasonably designed, safe and applicable.
[0007] The technical solution adopted by the present invention to solve its technical problem is: A multi-core processor task scheduling method based on group binding is divided into two parts: CPU core processing and real-time task processing; First, for CPU core processing, tasks that are not bound to a CPU core belong to the global ready queue, and tasks that are bound to a specified CPU core belong to the core affinity queue of the corresponding core; The divider divides the CPU cores into several CPU groups according to the physical grouping of the chip. Each CPU group maintains a local scheduling queue. When a task starts to be processed, it is first placed in the global scheduler, and the task is assigned to each CPU group through a hierarchical scheduling algorithm. The task is then preemptively scheduled based on priority on the local scheduling queue of each CPU group. For the processing of real-time tasks, the first thing is to set the task priority. The best priority allocation method is used to calculate the task response time and schedulability of the input tasks to determine the priority order of each task.
[0008] Furthermore, the priority allocation for real-time tasks is as follows: The tasks are first divided into two different task sets, the assigned task set A and the unassigned task set U. Task set A consists of low-priority tasks with a given priority, while task set B consists of tasks without a given priority. Before priority assignment, all tasks are placed in task set B by default, and are assumed to have a higher priority than the tasks in task set A.
[0009] Furthermore, tasks in task set B are taken out in turn and temporarily assigned a higher priority than the tasks in task set A, and the schedulability of the tasks in task set A is calculated; If the task can be scheduled, it is placed in task set A and given a priority. If the task is not schedulable, it is still placed in task set B. Repeat the above steps until all tasks in task set B have been tried and found unschedulable, or all tasks have been moved to task set A and the final priority assignment has been established; After the priority of the task is configured, the task is assigned to different groups by the global scheduler for scheduling.
[0010] Furthermore, for CPU core processing, any task can run on any set of CPUs in the system, and the interrupt will be routed to the default CPU0 processor.
[0011] Furthermore, when a high-priority task switch occurs in a group of CPU cores in the system, it is scheduled in the following execution order: (1) First, select the task P with the lowest priority from the tasks to be scheduled on the CPU core; (2) Replace task P with a high-priority task.
[0012] Furthermore, when a low-priority task is switched on a CPU core in the system, it is scheduled in the following execution order: (1) First, select the task C with the highest priority from the CPU core's core-friendly ready queue as the backup task; (2) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task C, replace task C with that task as a backup task. (3) Transfer in backup tasks for execution.
[0013] Furthermore, when a group of CPU cores in the system rotate or actively give up tasks of the same priority, they are scheduled in the following execution order: (1) Add the current task D to the tail of the queue with the same priority; (2) Select the task Z with the highest priority from the CPU core's core-friendly ready queue as the backup task; (3) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task Z, replace task Z with that task as a backup task. (4) Replace the current task D with the backup task.
[0014] Furthermore, in the task affinity binding, the affinity flag is expanded to the affinity group flag. The flag is an unsigned long integer. Each bit represents the corresponding CPU core. Setting it to 1 means binding the core, and setting it to 0 means not binding. When calling the affinity group binding interface, the CPU group is bound by setting the CPU position in the CPU group that the task needs to be allowed to bind to to 1, that is, a task is bound to a group of processors for scheduling.
[0015] A multi-core processor task scheduling device based on group binding includes: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute a multi-core processor task scheduling method based on group binding.
[0016] Compared with the prior art, the method and device for scheduling multi-core processor tasks based on group binding of the present invention have the following outstanding beneficial effects: The present invention can effectively solve the problems of cache partitioning, shared resources and parallel computing task partitioning among multiple cores of a many-core processor. While ensuring the real-time performance of system tasks and the comprehensive management requirements of system tasks, it can allocate processing core resources to parallel computing tasks and reduce the maintenance overhead of parallel tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Attached Figure 1 The invention is a flowchart of a task scheduling method for a multi-core processor based on group binding. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] A best embodiment is given below: like Figure 1 As shown, a multi-core processor task scheduling method based on group binding in this embodiment is divided into two parts: CPU core processing and real-time task processing; First, for CPU core processing, tasks that are not bound to a CPU core belong to the global ready queue, and tasks that are bound to a specified CPU core belong to the core affinity queue of the corresponding core; The divider divides the CPU cores into several CPU groups according to the physical grouping of the chip. Each CPU group maintains a local scheduling queue. When a task starts to be processed, it is first placed in the global scheduler, and the task is assigned to each CPU group through a given scheduling algorithm. The task is then preemptively scheduled based on priority on the local scheduling queue of each CPU group. The scheduling algorithm in this embodiment adopts a hierarchical scheduling algorithm, which is a scheduling algorithm based on hierarchical task division. It divides tasks into multiple levels, and the tasks of each level are assigned to different groups for execution.
[0021] For the processing of real-time tasks, the first thing is to set the task priority. The best priority allocation method is used to calculate the task response time and schedulability of the input tasks to determine the priority order of each task.
[0022] Among them, the priority allocation for real-time tasks is as follows: The tasks are first divided into two different task sets, the assigned task set A and the unassigned task set U. Task set A consists of low-priority tasks with a given priority, while task set B consists of tasks without a given priority. Before priority assignment, all tasks are placed in task set B by default, and are assumed to have a higher priority than the tasks in task set A.
[0023] Take out tasks from task set B in turn and temporarily assign them a higher priority than the tasks in task set A, and perform schedulability calculation on the tasks in A.
[0024] If the task can be scheduled, it is placed in task set A and given a priority. If the task is not schedulable, it is still placed in task set B.
[0025] The above steps are repeated until all tasks in B have been tried and found unschedulable, or all tasks have been moved to task set A and the final priority assignment has been established.
[0026] After configuring the priority of the task, the task is assigned to different groups by the global scheduler for scheduling. In this embodiment, the local scheduling adopts the original priority preemption method based on time slice rotation in Ruihua multi-core operating system. At this time, the priority preemption behavior only occurs within each CPU group, thus effectively reducing the inter-core overhead caused by task preemption.
[0027] For CPU core processing, any task can run on any set of CPUs in the system and route interrupts to the default CPU0 processor.
[0028] When a high-priority task switches to a group of CPU cores in the system, it is scheduled in the following execution order: (1) First, select the task P with the lowest priority from the tasks to be scheduled on the CPU core; (2) Replace task P with a high-priority task.
[0029] When a low-priority task switches to a CPU core in the system, it is scheduled in the following execution order: (1) First, select the task C with the highest priority from the CPU core's core-friendly ready queue as the backup task; (2) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task C, replace task C with that task as a backup task. (3) Transfer in backup tasks for execution.
[0030] When a group of CPU cores in the system rotate or actively give up tasks of the same priority, they are scheduled in the following execution order: (1) Add the current task D to the tail of the queue with the same priority; (2) Select task Z with the highest priority as the backup task from the CPU core's core affinity ready queue (including task D if task D exists in it); (3) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task Z, replace task Z with that task as a backup task. (4) Use the backup task to replace the current task D (if the backup task is still D, do not replace it).
[0031] In a multi-core environment, we extend the task affinity binding function by extending the affinity flag to the affinity group flag. The flag is an unsigned long integer, and each bit represents the corresponding CPU core. Setting it to 1 means binding the core, and setting it to 0 means not binding. When calling the affinity group binding interface, the CPU group is bound by setting the CPU position in the CPU group that the task needs to be bound to to 1. After the interface is extended, the task binding function based on affinity groups can be realized, that is, a task can be bound to a group of processors for scheduling.
[0032] Many-core processors have relatively abundant hardware resources. In actual use, embedded applications rarely use these hardware resources completely. Therefore, many-core processors in the embedded field are usually used on comprehensive management devices with real-time requirements, that is, not all tasks processed are real-time tasks, and there are also a certain amount of non-real-time tasks to be processed by the system. A task scheduling method for many-core processors based on group binding needs to have the following characteristics: (1) The system supports concurrent processing of real-time and non-real-time tasks. Due to the need for functional diversity, the tasks running on this system have different real-time requirements, and the system needs to support concurrent processing of these tasks; (2) The system needs to ensure the real-time and security of real-time tasks. The execution of non-real-time tasks in the system cannot affect the normal operation of real-time tasks. When resource preemption occurs, the system needs to prioritize and ensure that real-time tasks can be completed before the deadline. Non-real-time tasks can be blocked or discarded when necessary. (3) Under the premise of ensuring the real-time and security of real-time tasks, make full use of system resources to process other tasks.
[0033] Based on the above method, a multi-core processor task scheduling device based on group binding in this embodiment includes: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute a multi-core processor task scheduling method based on group binding.
[0034] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementations. Any technical solutions that conform to the above-mentioned specific implementations of the present invention and any appropriate changes or substitutions made by ordinary technicians in the relevant technical field shall fall within the patent protection scope of the present invention.
[0035] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A multi-core processor task scheduling method based on group binding, characterized in that: It is divided into two parts: CPU core processing and real-time task processing; First, for CPU core processing, tasks that are not bound to a CPU core belong to the global ready queue, and tasks that are bound to a specified CPU core belong to the core affinity queue of the corresponding core; The divider divides the CPU cores into several CPU groups according to the physical grouping of the chip. Each CPU group maintains a local scheduling queue. When a task starts to be processed, it is first placed in the global scheduler, and the task is assigned to each CPU group through a hierarchical scheduling algorithm. The task is then preemptively scheduled based on priority on the local scheduling queue of each CPU group. For the processing of real-time tasks, the first thing is to set the task priority. The best priority allocation method is used to calculate the task response time and schedulability of the input tasks to determine the priority order of each task.
2. The method for scheduling tasks of a multi-core processor based on group binding according to claim 1, characterized in that: The priority distribution for real-time tasks is as follows: The tasks are first divided into two different task sets, the assigned task set A and the unassigned task set U. Task set A consists of low-priority tasks with a given priority, while task set B consists of tasks without a given priority. Before priority assignment, all tasks are placed in task set B by default, and are assumed to have a higher priority than the tasks in task set A.
3. The method for scheduling tasks of a multi-core processor based on group binding according to claim 2, characterized in that: Take out tasks from task set B in turn and temporarily assign them a higher priority than the tasks in task set A, and perform schedulability calculation on the tasks in task set A; If the task can be scheduled, it is placed in task set A and given a priority. If the task is not schedulable, it is still placed in task set B. Repeat the above steps until all tasks in task set B have been tried and found unschedulable, or all tasks have been moved to task set A and the final priority assignment has been established; After the priority of the task is configured, the task is assigned to different groups by the global scheduler for scheduling.
4. The method for scheduling tasks of a multi-core processor based on group binding according to claim 3, characterized in that: For CPU core processing, any task can run on any set of CPUs in the system, and the interrupt will be routed to the default CPU0 processor.
5. The method for scheduling tasks of a multi-core processor based on group binding according to claim 4, characterized in that: When a high-priority task switch occurs in a group of CPU cores in the system, it is scheduled in the following execution order: (1) First, select the task P with the lowest priority from the tasks to be scheduled on the CPU core; (2) Replace task P with a high-priority task.
6. The method for scheduling tasks of a multi-core processor based on group binding according to claim 5, characterized in that: When a low-priority task switches to a CPU core in the system, it is scheduled in the following execution order: (1) First, select the task C with the highest priority from the CPU core's core affinity ready queue as the backup task; (2) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task C, replace task C with that task as a backup task. (3) Transfer in backup tasks for execution.
7. The method for scheduling tasks of a multi-core processor based on group binding according to claim 6, characterized in that: When a group of CPU cores in the system rotate or actively give up tasks of the same priority, they are scheduled in the following execution order: (1) Add the current task D to the tail of the queue with the same priority; (2) Select the task Z with the highest priority from the CPU core's core-friendly ready queue as the backup task; (3) Then traverse the tasks in the global ready queue. If there is a task with a higher priority than task Z, replace task Z with that task as a backup task. (4) Replace the current task D with the backup task.
8. The method for scheduling tasks of a multi-core processor based on group binding according to claim 7, characterized in that: In task affinity binding, the affinity flag is expanded to the affinity group flag. The flag is an unsigned long integer. Each bit represents the corresponding CPU core. Setting it to 1 means binding the core, and setting it to 0 means not binding. When calling the affinity group binding interface, the CPU group is bound by setting the CPU position in the CPU group that the task needs to be allowed to bind to 1, that is, a task is bound to a group of processors for scheduling.
9. A multi-core processor task scheduling device based on group binding, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Multi-core task scheduling method and device, electronic equipment and storage medium
CN114168352A
Multi-core processor task scheduling method and device, equipment and storage medium
CN115033352A
Container adaptive division-based restrictive preemptive real-time task scheduling method
CN116107716A
Multi-core processor-oriented partition operating system deterministic scheduling method
CN117687749A