A multi-task parallel processing method based on a multi-core embedded processor
Patent Information
- Application Number
- CN202311145846.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2043-09-07
AI Technical Summary
[0003]本发明提供了一种基于多核嵌入式处理器的多任务并行处理方法,解决了目前公知技术中的嵌入式平台多任务处理方法无法适用多核处理器的问题
1.本申请提供的方法操作简单、代码数量少。对于具有N个核心的CPU,仅通过3个主要函数、N+1个任务队列及1组数据管理模块即可实现多任务并行处理功能。
Smart Images

Figure CN117472561B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of processor technology, and more specifically to a multi-task parallel processing method based on a multi-core embedded processor. Background Technology
[0002] Currently, known multitasking methods for embedded platforms, such as the invention patent applied for by the applicant in China, patent number CN111538579B, disclose a method for multitasking on an embedded platform. This method involves setting up the task environment and scheduling tasks through sub-function calls after entering the C language main function. This method does not require any modification to the CPU startup code before entering the main function. However, the above method is not applicable to multi-core embedded processors and needs to be redesigned to ensure its future-proofing. Summary of the Invention
[0003] This invention provides a multi-task parallel processing method based on a multi-core embedded processor, which solves the problem that current known embedded platform multi-task processing methods cannot be applied to multi-core processors.
[0004] The technical solution of the present invention is as follows: A multi-task parallel method based on a multi-core embedded processor is proposed. This method is implemented by calling sub-functions in the main function of C language. Each task to be executed is allocated an independent stack space in memory, so that each task does not interfere with each other during execution, and each CPU core can access any stack space. To achieve task management, this method includes a task data recording module, which stores basic information about tasks to be executed. Each task data recording module corresponds to a stack space. The basic information includes the entry address of the task function, the start address of the stack corresponding to the task, the end address of the stack corresponding to the task, and the CPU core number that can run the task. The basic information is register information used to initialize CPU registers. To manage the task data recording module, this method provides a task queue, which includes a work queue corresponding one-to-one with the CPU core number and at least one idle queue; the task data recording module containing basic information is located in the work queue, and the task data recording module without basic information is located in the idle queue. To achieve mutual coordination among the cores, this method includes a scheduling interaction area, which is a data storage space in memory that can be accessed by any CPU core. Each core has its own dedicated space within the scheduling interaction area. The dedicated space is used to update the interaction state of the core and update the address of the task data recording module. The interaction state includes the task waiting to switch, the task selection completed, and the task running. To achieve multi-task parallelism in multi-core embedded processors, this method designs three execution functions, including a task data recording module initialization function, a task registration function, and a task scheduling function. The task data recording module initialization function is used to clear the valid information of the task data recording module, place the task data recording module into the idle queue, and clear the scheduling interaction area. The task registration function can write basic task information to the task data recording module and update the corresponding stack space based on the task's requirements; The task scheduling function can use the scheduling interaction area to terminate the task being executed in the CPU core and execute other tasks. The task scheduling function includes task access subfunctions and task selection subfunctions, which communicate and cooperate through the scheduling interaction area. The specific steps for implementing multi-task parallel processing on a multi-core processor based on a task data recording module, task queue, scheduling interaction area, and execution function are as follows: S01) Select the CPU core responsible for task scheduling as the master core, and the remaining CPU cores are slave cores of the master core; when running the task scheduling function, the master core can run the task access sub-function and the task selection sub-function, while the slave cores can only run the task access sub-function. S02) In the main function of the main control core, the task data recording module initialization function is called to clear the valid information of the task data recording module and put all the task data recording modules in the work queue into the idle queue. At the same time, the scheduling interaction area is cleared to set the interaction state of the dedicated space of each CPU core in the scheduling interaction area to the task waiting to switch state. S03) In the main function of the program of the slave kernel, the task access sub-function is called. The task access sub-function communicates repeatedly with the scheduling region until the interaction state of the slave kernel in the special space of the scheduling interaction region is set to the task selection completed state. S04) In the main function of the main control core, the task registration function is called, and the entry address of the task function and the CPU core number that can run the task are passed to the task registration function as parameters. The task registration function takes a task data record module from the idle queue and fills in the basic information of the task. The registration function places the task data record module at the head of the work queue of the CPU core corresponding to the task data record module, and writes the basic information in the stack space corresponding to the task data record module according to the CPU register popping requirements. S05) If multiple tasks need to run synchronously, repeat step S04) until all tasks are registered; S06) In the main function of the main control core, the task selection sub-function is called to query the interaction status of the dedicated space of each CPU core in the scheduling interaction area in turn. Starting from the beginning of the work queue of the CPU core in the task waiting to switch state, the task data recording module is obtained, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction status is set to the task selection completed state. After the task selection sub-function queries and updates the interaction status of the dedicated space of each CPU core in turn, the task access sub-function is called to execute the next step. S07) The task access sub-functions running on each CPU core communicate with the scheduling interaction area to obtain the interaction status information of the CPU core in its respective dedicated space. When the interaction status changes to the task selection completed state, the basic information of the task is obtained according to the address of the task data recording module in the dedicated space, and the interaction status is updated to the task in progress state in the dedicated space. Then, the register information stored in the stack space corresponding to the task data recording module is loaded into the CPU core to start the task. Furthermore, if no task data record module is found in the work queue of the CPU core in step S06), then the task data record module is retrieved from the work queue of other CPU cores and loaded into the work queue of this CPU core, and step S06 is repeated.
[0005] Furthermore, when the task executed by the slave core needs to be paused, the task access subfunction is called; the task access subfunction saves the register information in the CPU core to the stack space corresponding to the task; the task access subfunction sets the interaction state of the dedicated space of the CPU core in the scheduling interaction area to the task waiting to switch state, monitors the interaction state and stops other work until the monitored interaction state is set to the task selection completed state, and then executes step S07).
[0006] Furthermore, when the task executed by the main control core needs to be paused, the task access subfunction is first called to save the register information of this CPU core to the stack space corresponding to the task, and the interaction state of the dedicated space corresponding to this CPU core in the scheduling interaction area is set to the task waiting to be switched. Then, the task selection subfunction is called to scan the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn. When the interaction state of the dedicated space is found to be the task waiting to be switched, the next task data recording module of the current task is selected from the work queue of the CPU core corresponding to this dedicated space, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state. Then, the task access subfunction is called again to execute step S07.
[0007] Furthermore, when selecting the next task data recording module from the work queue of the CPU core corresponding to the dedicated space, if the current task is located at the tail of the work queue, then return to the head of the work queue to select the first task.
[0008] Furthermore, if the task data record module is not found in the work queue of the CPU core corresponding to the dedicated space, the task data record module can be retrieved from the work queue of other CPU cores and added to the work queue of this CPU core. When retrieving, it is necessary to confirm whether the CPU core number in the task data record module belongs to the CPU core number that can run the task.
[0009] Furthermore, if no matching task data record module is found in the work queue of the CPU core corresponding to the dedicated space, the task selection sub-function does not operate on the dedicated space corresponding to this CPU core.
[0010] Furthermore, after the task in the CPU core finishes execution, the task data recording module corresponding to the completed task is moved from the work queue to the idle queue, and the data in the data recording module is cleared. For slave cores, the task access subfunction sets the interaction state in the dedicated space of the slave core to the task waiting-to-switch state, monitors the interaction state and stops other work until the interaction state is set to the task selection completed state, and then executes step S07). For the master core, after calling the task access subfunction to set the interaction state in the dedicated space corresponding to the master core to the task waiting-to-switch state, the task selection subfunction is called to query the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn. The next task data recording module is obtained from the work queue of the CPU core in the task waiting-to-switch state, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state. After the task selection subfunction queries and updates the interaction state of the dedicated space of each CPU core in turn, the task access subfunction is called to execute step S07). Furthermore, in step S04, the main control core needs to establish a default task. The default task directly calls the task access sub-function to perform the next round of tasks, and the next round of tasks can be the default task itself.
[0011] Furthermore, in this method, the CPU register push and pop stack functions of the task access sub-function are built using CPU platform-related assembly code; the task data recording module initialization function, task registration function, task scheduling function, task data recording module, "idle queue" and "work queue" are all built using C language.
[0012] Due to the adoption of the above technical solution, the beneficial effects of the present invention are: 1. The method provided in this application is simple to operate and requires little code. For a CPU with N cores, multi-task parallel processing can be achieved using only 3 main functions, N+1 task queues, and a set of data management modules.
[0013] 2. The method provided in this application is simple and easy to develop. Since the task scheduling environment is built by calling sub-functions in the C language main function, it can be used in common embedded environments such as ADS and Keil in the most intuitive and efficient way. Any technician with experience in embedded processor development can apply it.
[0014] 3. This application also optimizes the relatively closed operating environment of embedded systems by removing functions such as memory address access protection and program privilege level protection. It achieves high efficiency in task switching with minimal overhead and can be ported between platforms by simply changing the assembly code for register push and pop operations related to the CPU platform. Attached Figure Description
[0015] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a diagram of the work queue operation architecture described in this application; Figure 2 A flowchart of a multi-task parallel method based on a multi-core embedded processor is provided for this application. Detailed Implementation
[0016] As attached Figure 1 and attached Figure 2 As shown, a multi-task parallel method based on a multi-core embedded processor is proposed. This method is implemented by calling sub-functions in the C language main function.
[0017] Each task to be executed is allocated an independent stack space in memory, so that the tasks do not interfere with each other during execution, and each CPU core can access any stack space.
[0018] To achieve task management, this method includes a task data recording module, which stores basic information about tasks to be executed. Each task data recording module corresponds to a stack space. The basic information includes the entry address of the task function, the start address of the stack corresponding to the task, the end address of the stack corresponding to the task, and the CPU core number that can run the task. The basic information is register information used to initialize CPU registers.
[0019] To manage the task data recording module, this method provides a task queue, which includes a work queue corresponding one-to-one with the CPU core number and at least one idle queue; the task data recording module containing basic information is located in the work queue, and the task data recording module without basic information is located in the idle queue.
[0020] To achieve coordination among the cores, this method includes a scheduling interaction area, which is a data storage space in memory that can be accessed by any CPU core. Each core has its own dedicated space within the scheduling interaction area. This dedicated space is used to update the interaction state of the core and the address of the task data recording module. The interaction state includes the task waiting to be switched, the task selection completed, and the task running.
[0021] In practice, each CPU core has an independent work queue for task switching and management. For a processor with N cores, N work queues need to be established. The register information in the task data recording module can select the work queue corresponding to the appropriate CPU core. When a task executing on one CPU core needs to switch to another CPU core, the task data recording modules of both cores should also switch accordingly to facilitate task switching and management by the latter.
[0022] To achieve multi-task parallelism in multi-core embedded processors, this method designs three running functions, including a task data recording module initialization function, a task registration function, and a task scheduling function.
[0023] The task data recording module initialization function is used to clear the valid information of the task data recording module, place the task data recording module into the idle queue, and clear the scheduling interaction area.
[0024] The task registration function can write basic task information to the task data recording module and update the corresponding stack space based on the task's requirements.
[0025] The task scheduling function can use the scheduling interaction area to terminate the task being executed in the CPU core and execute other tasks. The task scheduling function includes task access subfunctions and task selection subfunctions, which communicate and cooperate through the scheduling interaction area.
[0026] In this method, the CPU register push / pop functionality of the task access sub-function is built using CPU platform-specific assembly code; the task data recording module initialization function, task registration function, task scheduling function, task data recording module, "idle queue," and "work queue" are all built using C language. Since the task scheduling environment is implemented through sub-function calls in the C language main function, this method can be used in commonly used embedded environments such as ADS or Keil.
[0027] This method can be divided into three parts: initialization and execution, task execution, and task switching.
[0028] The specific steps for initializing the runtime section are as follows: S01) Select the CPU core responsible for task scheduling as the master core, and the remaining CPU cores are slave cores of the master core; when running the task scheduling function, the master core can run the task access sub-function and the task selection sub-function, while the slave cores can only run the task access sub-function.
[0029] S02) In the main function of the main control core, the task data recording module initialization function is called to clear the valid information of the task data recording module and put all the task data recording modules in the work queue into the idle queue. At the same time, the scheduling interaction area is cleared to set the interaction state of the dedicated space of each CPU core in the scheduling interaction area to the task waiting to switch state.
[0030] S03) In the main function of the slave kernel's program, the task access sub-function is called. The task access sub-function communicates repeatedly with the scheduling region until the interaction state of the slave kernel in the dedicated space of the scheduling interaction region is set to the task selection completed state.
[0031] S04) In the main function of the main control core, the task registration function is called, and the entry address of the task function and the CPU core number that can run the task are passed to the task registration function as parameters. The task registration function takes a task data record module from the idle queue and fills in the basic information of the task. The registration function places the task data record module at the head of the work queue of the CPU core corresponding to the task data record module, and writes the basic information in the stack space corresponding to the task data record module according to the CPU register popping requirements.
[0032] In practice, this step requires establishing a default task. The default task directly calls the task access subroutine to proceed to the next round of tasks, and the next round of tasks can be the default task itself. The default task is established in the same way as other tasks. The default task is used to prevent the main control core from running out of available tasks. If the main control core starts the task scheduling process without available tasks, the task access subroutine may enter an infinite loop, waiting indefinitely for the task selection to complete. Once the main control core enters an infinite loop, other cores will be unable to switch tasks.
[0033] S05) If multiple tasks need to run synchronously, repeat step S04) until all tasks are registered; The specific steps for the task execution and task switching sections are as follows: S06) In the main function of the main control core, the task selection sub-function is called to query the interaction status of the dedicated space of each CPU core in the scheduling interaction area in turn. Starting from the beginning of the work queue of the CPU core in the task waiting to switch state, the task data recording module is obtained, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction status is set to the task selection completed state. After the task selection sub-function queries and updates the interaction status of the dedicated space of each CPU core in turn, the task access sub-function is called to execute the next step. In practice, if no task data record module is found in the work queue of the CPU core in step S06), the task data record module is retrieved from the work queue of other CPU cores and loaded into the work queue of this CPU core, and then step S06 is repeated.
[0034] In specific implementation, when the task executed by the slave core needs to be paused, the task access subfunction is called; the task access subfunction saves the register information in the CPU core to the stack space corresponding to the task; the task access subfunction sets the interaction state of the dedicated space of the CPU core in the scheduling interaction area to the task waiting to switch state, monitors the interaction state and stops other work until the monitored interaction state is set to the task selection completed state, and then executes step S07).
[0035] In specific implementation, when the task executed by the main control core needs to be paused, the task access subfunction is first called to save the register information of this CPU core to the stack space corresponding to the task, and the interaction state of the dedicated space corresponding to this CPU core in the scheduling interaction area is set to the task waiting to switch state; then the task selection subfunction is called to scan the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn; when the interaction state of the dedicated space is found to be the task waiting to switch state, the next task data recording module of the current task is selected from the work queue of the CPU core corresponding to this dedicated space, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state, and then the task access subfunction is called again to execute step S07).
[0036] More specifically, when selecting the next task data recording module from the work queue of the CPU core corresponding to the dedicated space, if the current task is at the tail of the work queue, then return to the head of the work queue to select the first task.
[0037] More specifically, if the task data record module is not found in the work queue of the CPU core corresponding to the dedicated space, the task data record module can be retrieved from the work queue of other CPU cores and added to the work queue of this CPU core. When retrieving, it is necessary to confirm whether the CPU core number in the task data record module belongs to the CPU core number that can run the task.
[0038] More specifically, if no matching task data record module is found in the work queue of the CPU core corresponding to the dedicated space, the task selection sub-function does not operate on the dedicated space corresponding to this CPU core.
[0039] S07) The task access sub-functions running on each CPU core communicate with the scheduling interaction area to obtain the interaction status information of the CPU core in its respective dedicated space. When the interaction status changes to the task selection completed state, the basic information of the task is obtained according to the address of the task data recording module in the dedicated space, and the interaction status is updated to the task in progress state in the dedicated space. Then, the register information stored in the stack space corresponding to the task data recording module is loaded into the CPU core to start the task. In specific implementation, after the task in the CPU core finishes execution, the task data recording module corresponding to the completed task is moved from the work queue to the idle queue, and the data in the data recording module is cleared. For slave cores, the task access subfunction sets the interaction state in the dedicated space of the slave core to the task waiting to switch state, monitors the interaction state and stops other work until the interaction state is set to the task selection completed state, and then executes step S07. For the master core, after calling the task access subfunction to set the interaction state in the dedicated space corresponding to the master core to the task waiting to switch state, the task selection subfunction is called to query the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn. The next task data recording module is obtained from the work queue of the CPU core in the task waiting to switch state, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state. After the task selection subfunction queries and updates the interaction state of the dedicated space of each CPU core in turn, the task access subfunction is called to execute step S07.
[0040] The above description is merely the basic principle and preferred embodiment of the present invention. Improvements and substitutions made by those skilled in the art based on the present invention are within the scope of protection of the present invention.
Claims
1. A multi-task parallel method based on a multi-core embedded processor, characterized in that, This method is implemented by calling a sub-function within the C language's main function; Each task to be executed is allocated an independent stack space in memory, so that each task does not interfere with each other during execution, and each CPU core can access any stack space. To achieve task management, this method includes a task data recording module, which stores basic information about tasks to be executed. Each task data recording module corresponds to a stack space. The basic information includes the entry address of the task function, the start address of the stack corresponding to the task, the end address of the stack corresponding to the task, and the CPU core number that can run the task. The basic information is register information used to initialize CPU registers. To manage the task data recording module, this method provides a task queue, which includes a work queue corresponding one-to-one with the CPU core number and at least one idle queue; the task data recording module containing basic information is located in the work queue, and the task data recording module without basic information is located in the idle queue. To achieve mutual coordination among the cores, this method has a scheduling interaction area, which is a data storage space in memory that can be accessed by any CPU core, and each core has its own dedicated space in the scheduling interaction area. The dedicated space is used to update the interaction status of this core and update the address of the task data recording module; the interaction status includes the task waiting to switch status, the task selection completed status, and the task running status; To achieve multi-task parallelism in multi-core embedded processors, this method designs three execution functions, including a task data recording module initialization function, a task registration function, and a task scheduling function. The task data recording module initialization function is used to clear the valid information of the task data recording module, place the task data recording module into the idle queue, and clear the scheduling interaction area. The task registration function can write basic task information to the task data recording module and update the corresponding stack space based on the task's requirements; Task scheduling functions can use scheduling interaction regions to terminate tasks currently being executed in the CPU core and execute other tasks; The task scheduling function includes task access subfunctions and task selection subfunctions. The task access subfunctions and task selection subfunctions communicate and cooperate through the scheduling interaction area. The specific steps for implementing multi-task parallel processing on a multi-core processor based on a task data recording module, task queue, scheduling interaction area, and execution function are as follows: S01) Select the CPU core responsible for task scheduling as the master core, and the remaining CPU cores are slave cores of the master core; when running the task scheduling function, the master core can run the task access sub-function and the task selection sub-function, while the slave cores can only run the task access sub-function. S02) In the main function of the main control core, the task data recording module initialization function is called to clear the valid information of the task data recording module and put all the task data recording modules in the work queue into the idle queue. At the same time, the scheduling interaction area is cleared to set the interaction state of the dedicated space of each CPU core in the scheduling interaction area to the task waiting to switch state. S03) In the main function of the program of the slave kernel, the task access sub-function is called. The task access sub-function communicates repeatedly with the scheduling region until the interaction state of the slave kernel in the special space of the scheduling interaction region is set to the task selection completed state. S04) In the main function of the main control core, the task registration function is called, and the entry address of the task function and the CPU core number that can run the task are passed to the task registration function as parameters. The task registration function takes a task data record module from the idle queue and fills in the basic information of the task. The registration function places the task data record module at the head of the work queue of the CPU core corresponding to the task data record module, and writes the basic information in the stack space corresponding to the task data record module according to the CPU register popping requirements. S05) If multiple tasks need to run synchronously, repeat step S04) until all tasks are registered; S06) In the main function of the main control core, the task selection sub-function is called to query the interaction status of the dedicated space of each CPU core in the scheduling interaction area in turn. Starting from the beginning of the work queue of the CPU core in the task waiting to switch state, the task data recording module is obtained, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction status is set to the task selection completed state. After the task selection sub-function queries and updates the interaction status of the dedicated space of each CPU core in turn, the task access sub-function is called to execute the next step. S07) The task access sub-functions running on each CPU core communicate with the scheduling interaction area to obtain the interaction status information of the CPU core in its respective dedicated space. When the interaction status changes to the task selection completed state, the basic information of the task is obtained according to the address of the task data recording module in the dedicated space, and the interaction status is updated to the task in progress state in the dedicated space. Then, the register information stored in the stack space corresponding to the task data recording module is loaded into the CPU core to start the task.
2. The multi-task parallel method based on a multi-core embedded processor according to claim 1, characterized in that, If no task data record module is found in the work queue of this CPU core in step S06), then the task data record module is retrieved from the work queue of other CPU cores and loaded into the work queue of this CPU core, and step S06 is repeated.
3. The multi-task parallel method based on a multi-core embedded processor according to claim 1, characterized in that, When a task executed by a slave core needs to be paused, the task access subfunction is called; the task access subfunction saves the register information in the CPU core to the stack space corresponding to the task; the task access subfunction sets the interaction state of the dedicated space of the CPU core in the scheduling interaction area to the task waiting to be switched state, monitors the interaction state and stops other work until the monitored interaction state is set to the task selection completed state, and then executes step S07).
4. The multi-task parallel method based on a multi-core embedded processor according to claim 1, characterized in that, When the task executed by the main control core needs to be paused, the task access subfunction is first called to save the register information of this CPU core to the stack space corresponding to the task, and the interaction state of the dedicated space corresponding to this CPU core in the scheduling interaction area is set to the task waiting to be switched. Then, the task selection subfunction is called to scan the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn. When the interaction state of the dedicated space is found to be the task waiting to be switched, the next task data recording module of the current task is selected from the work queue of the CPU core corresponding to this dedicated space, the address of this task data recording module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state. Then, the task access subfunction is called again to execute step S07.
5. A multi-task parallel method based on a multi-core embedded processor according to claim 4, characterized in that, When selecting the next task data recording module from the work queue of the CPU core corresponding to the dedicated space, if the current task is at the tail of the work queue, then return to the head of the work queue to select the first task.
6. The multi-task parallel method based on a multi-core embedded processor according to claim 5, characterized in that, If the task data record module is not found in the work queue of the CPU core corresponding to the dedicated space, the task data record module can be retrieved from the work queue of other CPU cores and added to the work queue of this CPU core. When retrieving, it is necessary to confirm whether the CPU core number in the task data record module belongs to the CPU core number that can run the task.
7. A multi-task parallel method based on a multi-core embedded processor according to claim 6, characterized in that, If no matching task data record module is found in the work queue of the CPU core corresponding to the dedicated space, the task selection sub-function does not operate on the dedicated space corresponding to this CPU core.
8. A multi-task parallel method based on a multi-core embedded processor according to claim 7, characterized in that, Once the task in the CPU core finishes execution, the task data recording module corresponding to the completed task is moved from the work queue to the idle queue, and the data in the data recording module is cleared. For slave cores, the task access subfunction sets the interaction state in the slave core's dedicated space to the task waiting-to-switch state, monitors the interaction state, and stops other work until the interaction state is set to the task selection completed state, then executes step S07). For master cores, after calling the task access subfunction to set the interaction state in the master core's dedicated space to the task waiting-to-switch state, the task selection subfunction is called to query the interaction state of the dedicated space of each CPU core in the scheduling interaction area in turn. The next task data record module is retrieved from the work queue of the CPU core in the task waiting-to-switch state, the address of this task data record module is updated to the dedicated space of the scheduling interaction area, and the interaction state is set to the task selection completed state. After the task selection subfunction queries and updates the interaction state of the dedicated space of each CPU core in turn, the task access subfunction is called to execute step S07).
9. A multi-task parallel method based on a multi-core embedded processor according to claim 1, characterized in that, In step S04, the main control core needs to create a default task. The default task directly calls the task access sub-function to perform the next round of tasks, and the next round of tasks can be the default task itself.
10. A multi-task parallel method based on a multi-core embedded processor according to claim 1, characterized in that, In this method, the CPU register push and pop stack functionality of the task access sub-function is built using CPU platform-specific assembly code. The task data recording module initialization function, task registration function, task scheduling function, task data recording module, "idle queue" and "work queue" are all built in C language.
Citation Information
Patent Citations
A multi-tasking method for embedded platforms
CN111538579B
FreeRTOS task running method and device based on multi-core CPU
CN113918336A
Task scheduling method and related non-transitory computer readable medium for dispatching task in multi-core processor system based at least partly on distribution of tasks sharing same data and / or accessing same memory address(ES)
US20150324234A1