Multi-task scheduling method and system in embedded bare computer system

By decomposing business tasks into multiple subtasks and adding them to the task queue when interrupted, the code bloated and high-priority task blocking problems of embedded bare-metal systems when processing concurrent tasks are solved, and the concurrent processing and work efficiency are improved.

CN119645642APending Publication Date: 2025-03-18SHANGHAI GBCOM COMM TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411741506.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Embedded bare-metal systems have problems with bloated code structure and difficult to maintain and scale when handling concurrent tasks, and high-priority tasks may be blocked by low-priority tasks, affecting system performance and stability.

Method used

By decomposing the business tasks into multiple independent subtasks, and adding only the first subtask of the corresponding business tasks to the task queue when interrupted, the subtasks of each business task can be executed interspersedly to achieve concurrent processing.

Benefits of technology

Concurrent processing is implemented in space, improving the working efficiency of embedded bare-metal systems and avoiding the time wasted waiting for low-priority tasks to be completed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645642A_ABST
    Figure CN119645642A_ABST
Patent Text Reader

Abstract

The invention provides a multi-task scheduling method and system in an embedded bare computer system, and belongs to the technical field of task scheduling, a business task is decomposed into a plurality of independent sub-tasks in advance, and the plurality of sub-tasks form the business task in sequence; the task enqueue process comprises the steps that A1, an interrupt program responds to an external interrupt event to determine a corresponding service task as a target service task; a2, the interrupt program adds a first sub-task corresponding to the target service task into a task queue; the task processing process comprises the following steps: step B1, circularly detecting whether a to-be-executed sub-task exists in a task queue or not; and step B2, when it is detected that the to-be-executed sub-task exists in the task queue, triggering a task execution process. The method has the beneficial effects that the complete business task is decomposed into a plurality of sub-tasks, and only the first sub-task corresponding to the business task is added into the task queue during interruption, so that the sub-tasks of the business tasks can be executed alternately, and concurrent processing is realized in space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of task scheduling, and in particular to a multi-task scheduling method and system in an embedded bare metal system. Background Art

[0002] In embedded systems, a bare metal system usually refers to a single-threaded operating system that runs a large loop in the main function and implements task processing through polling. The bare metal system is mainly composed of the front and back systems. The back refers to the task polling in the main function large loop, and the foreground refers to the interrupt service program. The task polling in the background can be interrupted by the foreground, jump to the interrupt service program, and return to the polling task after the interrupt is completed.

[0003] Typical business program framework of embedded bare metal system is as follows: Figure 1 As shown in the figure, the external event is the main business event monitored by the system, such as key action, level change, sound volume, photoelectric signal, etc. When the system captures an external event, it will trigger the corresponding interrupt program. Since time-consuming operations cannot be performed in the interrupt program, the interrupt program usually sets a flag bit and exits immediately. Then, after the main business program detects the flag bit, it executes the task program of the event, such as capturing the key input value, etc.

[0004] However, the main business program needs to include all possible task processing codes, resulting in a bloated and complex code structure that is difficult to maintain and expand. As business needs increase, the amount of code in the main business program will continue to expand, which will increase the complexity and error rate of the system. Moreover, the framework has obvious deficiencies in handling concurrent tasks. Since all tasks are executed sequentially in the main business program, when a task is running, if the flag bit of another task is set, then the task can only be executed after the current task is completed. This sequential execution method not only reduces the real-time performance of the system, but may also cause high-priority tasks to be blocked by low-priority tasks, thereby affecting the performance and stability of the entire system.

[0005] In order to solve the above problems, one of the current mainstream methods is to use the transplantation of real-time operating system (RTOS) to achieve multi-task concurrent execution according to priority. However, not all embedded systems are suitable for RTOS. On the one hand, RTOS usually occupies more system resources, which may bring additional burden to embedded systems with limited resources; on the other hand, some embedded microcontroller chips do not support RTOS transplantation, so this method cannot be used to achieve multi-task concurrent execution. Summary of the invention

[0006] In order to solve the above technical problems, the present invention provides a multi-task scheduling method in an embedded bare metal system; on the other hand, it also provides a multi-task scheduling system in an embedded bare metal system.

[0007] The technical problem solved by the present invention can be achieved by adopting the following technical solutions:

[0008] The first aspect of the present invention is to provide a multi-task scheduling method in an embedded bare metal system, which decomposes a business task into multiple independent subtasks in advance, and the multiple subtasks constitute the business task in sequence;

[0009] The method includes a task enqueuing process and a task processing process;

[0010] The task enqueue process includes:

[0011] Step A1, when an external interruption event is received, the interruption program responds to the external interruption event to determine a corresponding business task, and uses the determined business task as a target business task;

[0012] Step A2, the interrupt program adds the first subtask corresponding to the target business task to the task queue;

[0013] The task processing process includes:

[0014] Step B1, cyclically detecting whether there are subtasks to be executed in the task queue;

[0015] Step B2: When it is detected that there is a subtask to be executed in the task queue, a task execution process is triggered.

[0016] Preferably, the step A2 comprises:

[0017] Step A21, determining the priority of the target business task;

[0018] Step A22: adding the first subtask corresponding to the target business task to the task queue according to the priority of the target business task.

[0019] Preferably, the step A22 includes:

[0020] Step A221, determining whether the priority of the target business task is higher than the priority of the subtask being executed:

[0021] If yes, then add the first subtask corresponding to the target business task to the head of the task queue;

[0022] If not, the first subtask corresponding to the target business task is added to the end of the task queue.

[0023] Preferably, the task enqueue process further includes:

[0024] Step A3: before the current subtask of the target business task is completed, the queue interface adds the next subtask of the target business task to the task queue.

[0025] Preferably, the task execution process includes:

[0026] Step B21, extracting the subtask at the head of the task queue, and taking the extracted subtask as the target subtask;

[0027] Step B22, executing the target subtask and outputting a return value after the execution is completed;

[0028] Step B23, performing corresponding operations according to the returned value.

[0029] Preferably, in step B23, when the return value is "task completed", the target subtask executed in step B22 is deleted from the task queue;

[0030] When the return value is "repeat execution later", the target subtask executed in step B22 is added to the end of the task queue;

[0031] When the return value is "repeat execution immediately", the target subtask executed in step B22 is added to the head of the task queue.

[0032] A second aspect of the present invention is to provide a multi-task scheduling system in an embedded bare metal system, which is used to implement the multi-task scheduling method in the embedded bare metal system as described above, and the system includes:

[0033] A task decomposition module is used to decompose a business task into multiple independent subtasks in advance, and the multiple subtasks constitute the business task in sequence;

[0034] A task queue module, wherein an interruption program is pre-installed in the task queue module, wherein the interruption program is used to determine a corresponding business task in response to an external interruption event, take the determined business task as a target business task, and add the first subtask corresponding to the target business task to a task queue;

[0035] The task processing module is used for cyclically detecting whether there are subtasks to be executed in the task queue, and triggering the task execution process when detecting that there are subtasks to be executed in the task queue.

[0036] Preferably, the task enqueue module comprises:

[0037] The first task adding unit is used to add the next subtask of the target business task to the task queue before the current subtask of the target business task is executed.

[0038] Preferably, the task processing module further includes:

[0039] A task extraction unit, used to extract the subtask at the head of the task queue and use the extracted subtask as the target subtask;

[0040] A task execution unit, connected to the task extraction unit, is used to execute the target subtask and output a return value after the execution is completed;

[0041] The task response unit is connected to the task execution unit and is used to execute corresponding operations according to the return value.

[0042] Preferably, the task response unit includes:

[0043] A task deletion subunit, used for deleting the target subtask from the task queue when the return value is "task completed";

[0044] A second task adding sub-unit is used for adding the target sub-task to the end of the task queue when the return value is "repeat execution later";

[0045] The third task adding sub-unit is used to add the target sub-task to the head of the task queue when the return value is "repeat execution immediately".

[0046] The advantages or beneficial effects of the technical solution of the present invention are:

[0047] The present invention decomposes a complete business task into multiple subtasks, and only adds the first subtask of the corresponding business task to the task queue when an interruption occurs, so that the subtasks of each business task can be executed alternately, thereby realizing concurrent processing in space and greatly improving the work efficiency of the embedded bare metal system. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a typical business program framework diagram of an embedded bare metal system in the prior art;

[0049] Figure 2 A flowchart of a task enqueue process in a preferred embodiment of the present invention;

[0050] Figure 3 A flowchart of a task processing process in a preferred embodiment of the present invention;

[0051] Figure 4A decomposition and scheduling diagram of a business task for detecting key input in a preferred embodiment of the present invention;

[0052] Figure 5 This is a flow chart of step A2 in a preferred embodiment of the present invention;

[0053] Figure 6 This is a flow chart of step A22 in a preferred embodiment of the present invention;

[0054] Figure 7 This is a flow chart of step B2 in a preferred embodiment of the present invention;

[0055] Figure 8 A typical business program framework diagram of an embedded bare metal system in a preferred embodiment of the present invention;

[0056] Fig. 9 A structural block diagram of a multi-task scheduling system in an embedded bare metal system in a preferred embodiment of the present invention;

[0057] Fig.10 This is a structural block diagram of a task response unit in a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not 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.

[0059] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0060] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.

[0061] In a preferred embodiment of the present invention, based on the above problems existing in the prior art, a multi-task scheduling method in an embedded bare metal system is provided, which decomposes a business task into multiple independent subtasks in advance, and the multiple subtasks constitute the business task in sequence;

[0062] The method includes the task enqueuing process and the task processing process;

[0063] like Figure 2 As shown, the task enqueue process includes:

[0064] Step A1, when an external interrupt event is received, the interrupt program responds to the external interrupt event to determine a corresponding business task, and uses the determined business task as a target business task;

[0065] Step A2, the interrupt program adds the first subtask corresponding to the target business task to the task queue;

[0066] like Figure 3 As shown, the task processing process includes:

[0067] Step B1, cyclically checking whether there are subtasks to be executed in the task queue;

[0068] Step B2, when it is detected that there is a subtask to be executed in the task queue, the task execution process is triggered.

[0069] Specifically, before building the system, first, decompose each business task of the system into multiple subtasks of independent processes. Each subtask is responsible for completing a specific, independent processing process. These subtasks are connected in series in sequence to form a complete business task to ensure the smooth execution of the entire business task.

[0070] Each subtask is a process that cannot be interrupted except for interruption. Before the current subtask ends, the next subtask of the business task should be added to the queue.

[0071] For example, taking the business task of detecting key input as an example, the decomposition and scheduling process is as follows: Figure 4 As shown. First, perform key interrupt detection. When the system detects that a key is pressed, an interrupt signal will be triggered. Next, subtask 1: key trigger event. Then, subtask 2: anti-misjudgment processing, in order to prevent misjudgment caused by key jitter or false touch, set a threshold Nms, N is a positive integer. After the key is confirmed to be pressed, the system will wait for at least Nms. If the key state remains unchanged within Nms (that is, continuously pressed), continue to the next step to ensure that the key trigger event is stable and true; otherwise, it is considered to be a false touch and no subsequent processing is performed. Subsequently, subtask 3: key lift detection, the system will continue to monitor the key state. Once it is detected that the key is lifted, it is considered that the key trigger event is completed and enter the next step of processing. Next, subtask 4: business processing after the key event is completed, the system will execute the corresponding business logic. Finally, return to the interrupt detection state and continue to wait for the next key input.

[0072] In each business task, the first subtask is the starting subtask of the business task. In the business task of detecting key input, the key trigger event is the first subtask of the business task.

[0073] The task queue is used to store subtasks to be executed, waiting for the subsequent business main program loop to detect and execute. In the initial state, the task queue is set to empty, and the queue does not contain any subtasks to be executed.

[0074] When the system receives an external interrupt event, the interrupt program is triggered. In the interrupt, the starting subtask of the corresponding business task is added to the queue. Specifically, it can be added to the head or tail of the queue according to the task priority.

[0075] The main business program queries the status of the task queue by polling. Once a subtask is added to the queue, it can be scheduled and executed in time. Specifically, when the main business program detects that there are subtasks to be executed in the task queue, it triggers the task execution process. This process is responsible for taking the subtasks to be executed from the queue and executing the corresponding processing logic. After the execution is completed, the next subtask may be added to the task queue for subsequent execution based on the execution results of the subtask and the needs of the system.

[0076] In this embodiment, the task polling can be interrupted and jump to the interrupt program, and then return to the polling task after the interruption is completed.

[0077] Since a complete business task is divided into multiple subtasks to be executed separately, when a high-priority business task interruption occurs, the method of the embodiment of the present invention can add the starting subtask of the high-priority business task to the queue, and the subsequent business main program loop detects and executes the starting subtask of the high-priority business task without waiting for all subtasks of the currently executing business task to be completed, thereby ensuring that the high-priority task can get the processing opportunity as soon as possible.

[0078] The main business program will continuously loop and detect the subtasks in the task queue. Once the starting subtask of a high-priority business task is found, the main program will immediately interrupt the currently executing subtask (if any) and execute the starting subtask of the high-priority task instead, so as to achieve concurrent processing in space, that is, the subtasks of different business tasks can be executed alternately, avoiding the time wasted waiting for the completion of low-priority tasks, and improving work efficiency overall.

[0079] As a preferred embodiment, wherein Figure 5 As shown, step A2 includes:

[0080] Step A21, determining the priority of the target business task;

[0081] Step A22: adding the first subtask corresponding to the target business task to the task queue according to the priority of the target business task.

[0082] As a preferred embodiment, wherein Figure 6 As shown, step A22 includes:

[0083] Step A221, determine whether the priority of the target business task is higher than the priority of the subtask being executed:

[0084] If yes, add the first subtask corresponding to the target business task to the head of the task queue;

[0085] If not, the first subtask corresponding to the target business task is added to the end of the task queue.

[0086] Specifically, in this embodiment, according to the priority of the target business task, its first subtask is inserted into the appropriate position of the task queue. For example, if the target business task has a high priority, then its first subtask will be placed at the head of the queue so as to obtain an execution opportunity as soon as possible. On the contrary, if the target business task has a low priority, then its first subtask will be placed at the end of the queue and will be processed after the higher priority task is executed.

[0087] Priority is usually determined based on the urgency and importance of the business need and can be high, medium, or low.

[0088] The priority of all subtasks under the same business task is the same as the priority of the business task.

[0089] Specifically, when a business task with a higher priority is triggered, the first subtask of the high-priority business task can be inserted into the head of the queue to achieve high-priority execution.

[0090] As a preferred implementation, the task joining process further includes:

[0091] Step A3: before the current subtask of the target business task is executed, the queue interface adds the next subtask of the target business task to the task queue.

[0092] Specifically, when the target business task is started, the first subtask is added to the task queue by the interrupt program to ensure that the business task can respond immediately and start executing its first processing link.

[0093] Before the current subtask is finished, the next subtask of the business task should be added to the queue. This step is achieved by calling the queue interface. The queue interface provides functions such as adding tasks and deleting tasks, ensuring the flexibility and scalability of the task queue.

[0094] Once the current subtask is completed and resources are released, the next subtask is immediately taken out of the queue and executed, thus achieving continuous and automatic advancement of the target business task.

[0095] As a preferred embodiment, wherein Figure 7 As shown in the figure, the task execution process includes:

[0096] Step B21, extracting the subtask at the head of the task queue, and taking the extracted subtask as the target subtask;

[0097] Step B22, execute the target subtask and output the return value after the execution is completed;

[0098] Step B23, perform corresponding operations according to the returned value.

[0099] Specifically, in this embodiment, the task scheduling is performed by the business main program, which is still a loop, and the loop detects whether there are subtasks to be executed in the task queue. However, each loop only extracts one subtask from the head of the task queue for execution, and outputs a return value after execution.

[0100] The return value is used to indicate the next action, for example, deleting the completed task from the queue, adding the subtask that needs to be repeated later to the end of the queue, and adding the subtask that needs to be repeated immediately to the head of the queue.

[0101] As a preferred implementation, in step B23, when the return value is "task completed", the target subtask executed in step B22 is deleted from the task queue;

[0102] When the return value is "repeat execution later", the target subtask executed in step B22 is added to the end of the task queue;

[0103] When the return value is "repeat execution immediately", the target subtask executed in step B22 is added to the head of the task queue.

[0104] Specifically, in this embodiment, different actions are taken according to different situations of the return value.

[0105] If the return value is "task completed", the queue interface is called to delete the target subtask from the queue to ensure that the completed tasks will not continue to occupy queue resources.

[0106] If the return value is "repeat execution later", the queue interface is called to add the target subtask to the end of the task queue so that the subtask can be continuously scheduled for execution in subsequent cycles.

[0107] If the return value is "repeat execution immediately", the queue interface will be called to add the target subtask to the head of the task queue to ensure that the subtask can be scheduled for execution again in the next cycle of the main program.

[0108] In addition to being able to add the head, add the tail, and delete specified tasks, the queue interface can also implement functions such as counting queue length.

[0109] like Figure 8 The typical business program framework of the embedded bare metal system of the present invention is shown. The core idea of ​​the architecture of the present invention is to "break the whole into parts" and "simplify the complex".

[0110] The framework is divided into five parts: external events, interrupt programs, task queues, business main programs and task decomposition. Among them:

[0111] The task decomposition part is used to decompose each business task of the system into multiple subtasks of independent processes before building the system. Each subtask completes an independent process, and when connected in series, a complete business task is completed.

[0112] Task queue: It is empty in the initial state. When an external event occurs, an interrupt is triggered. During the interrupt, the interrupt program adds the "starting subtask" of the corresponding business task to the queue. It can be added to the head or tail of the queue according to the task priority.

[0113] The main business program is used for task scheduling. The main business program is a loop that can detect whether there are subtasks to be executed in the task queue. However, each loop only extracts one subtask from the head of the queue for execution. After the execution is completed, the next possible action is determined based on the return value of the task:

[0114] Task completed: delete this task from the queue;

[0115] Then repeat the execution: add the current subtask to the end of the queue, and it will be scheduled later;

[0116] Repeat execution immediately: Add the current subtask to the head of the queue, and the main program will immediately schedule the subtask again in the next loop.

[0117] The execution process of each subtask is a process that cannot be interrupted except for interruption. Before the subtask ends, the next subtask of the task should be added to the queue until all subtasks of the business task are executed.

[0118] The present invention also provides a multi-task scheduling system in an embedded bare metal system, which is used to implement the multi-task scheduling method in the embedded bare metal system as described above. Fig. 9 As shown, the system includes:

[0119] Task decomposition module 2, used to decompose the business task into multiple independent subtasks in advance, and the multiple subtasks constitute the business task in sequence;

[0120] A task queue module 3, in which an interruption program 31 is pre-installed, and the interruption program 31 is used to respond to an external interruption event to determine a corresponding business task, take the determined business task as a target business task, and add the first subtask corresponding to the target business task to the task queue;

[0121] The task processing module 4 is used for cyclically detecting whether there are subtasks to be executed in the task queue, and triggering the task execution process when detecting that there are subtasks to be executed in the task queue.

[0122] Specifically, in this embodiment, a complete business task is decomposed into multiple subtasks, and the business main program polls the task queue to detect that a subtask is extracted from the head of the queue for execution.

[0123] When an interrupt occurs, only the first subtask of the corresponding business task is added to the task queue, so that the subtasks of each business task can be executed alternately, thereby realizing concurrent processing in space and greatly improving the work efficiency of the embedded bare metal system.

[0124] As a preferred implementation, the task enqueue module 3 includes:

[0125] The first task adding unit 32 is used to add the next subtask of the target business task to the task queue before the current subtask of the target business task is executed.

[0126] As a preferred implementation, the task processing module 4 further includes:

[0127] The task extraction unit 41 is used to extract the subtask at the head of the task queue and use the extracted subtask as the target subtask;

[0128] The task execution unit 42 is connected to the task extraction unit 41 and is used to execute the target subtask and output a return value after the execution is completed;

[0129] The task response unit 43 is connected to the task execution unit 42 and is used to execute corresponding operations according to the return value.

[0130] As a preferred embodiment, wherein Fig.10 As shown, the task response unit 43 includes:

[0131] The task deletion subunit 431 is used to delete the target subtask from the task queue when the return value is "task completed";

[0132] The second task adding sub-unit 432 is used to add the target sub-task to the end of the task queue when the return value is "repeat execution later";

[0133] The third task adding sub-unit 433 is used to add the target sub-task to the head of the task queue when the return value is "repeat execution immediately".

[0134] In this embodiment, the first subtask is queued by the interruption program 31. Subsequent subtasks are queued by the queue interface, for example, the first task adding unit 32 in the task queue module 3, the task deleting subunit 431 in the task response unit 43, the second task adding subunit 432 and the third task adding subunit 433 can all be completed by the queue interface.

[0135] In the embodiment of the present invention, when an interruption occurs, each business task only adds its "starting subtask" to the task queue, avoiding loading and executing subsequent subtasks in advance when it is uncertain whether the task will be interrupted, thereby wasting resources.

[0136] For example, in the business task processing flow of the access control system, taking the password door opening task as an example, it is assumed that the task consists of three parts: a password input subtask, a password verification subtask, and a door opening subtask, which are executed sequentially.

[0137] When the user starts to execute the password door opening task, the password input subtask phase is entered first. If the system receives an interrupt request from the card door opening task during the password input (not completed), since the card door opening task has a higher priority than the password door opening task, the system will immediately interrupt the current execution state of the password door opening task, that is, suspend the password input subtask. Subsequently, the system adds the starting subtask of the card door opening task (assuming it is the card swipe detection subtask) to the task queue and immediately schedules the execution of the starting subtask.

[0138] The unfinished password input subtask will return a value to be deleted from the queue, and all remaining subtasks of the password door opening task (password verification subtask, door opening subtask) will no longer need to be added to the queue for execution.

[0139] The advantages or beneficial effects of adopting the above technical solution are: the present invention decomposes a complete business task into multiple sub-tasks, and only adds the first sub-task of the corresponding business task to the task queue when an interruption occurs, so that the sub-tasks of each business task can be executed alternately, thereby realizing concurrent processing in space and greatly improving the work efficiency of the embedded bare metal system.

[0140] In the description of the present invention, it should be understood that the numerical labels before the steps do not identify the order of executing the steps, but are only used to facilitate the description of the present invention and distinguish each step, and therefore cannot be understood as a limitation of the present invention.

[0141] The above are only preferred embodiments of the present invention, and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the contents of this specification and illustrations should be included in the protection scope of the present invention.

Claims

1. A multi-task scheduling method in an embedded bare metal system, characterized in that: Decomposing the business task into multiple independent subtasks in advance, wherein the multiple subtasks constitute the business task in sequence; The method includes a task enqueuing process and a task processing process; The task enqueue process includes: Step A1, when an external interruption event is received, the interruption program responds to the external interruption event to determine a corresponding business task, and uses the determined business task as a target business task; Step A2, the interrupt program adds the first subtask corresponding to the target business task to the task queue; The task processing process includes: Step B1, cyclically detecting whether there are subtasks to be executed in the task queue; Step B2: When it is detected that there is a subtask to be executed in the task queue, a task execution process is triggered.

2. The multi-task scheduling method in an embedded bare metal system according to claim 1, characterized in that: The step A2 comprises: Step A21, determining the priority of the target business task; Step A22: adding the first subtask corresponding to the target business task to the task queue according to the priority of the target business task.

3. The multi-task scheduling method in an embedded bare metal system according to claim 2, characterized in that: The step A22 comprises: Step A221, determining whether the priority of the target business task is higher than the priority of the subtask being executed: If yes, then add the first subtask corresponding to the target business task to the head of the task queue; If not, the first subtask corresponding to the target business task is added to the end of the task queue.

4. The multi-task scheduling method in an embedded bare metal system according to claim 1, characterized in that: The task enlistment process also includes: Step A3: before the current subtask of the target business task is completed, the queue interface adds the next subtask of the target business task to the task queue.

5. The multi-task scheduling method in an embedded bare metal system according to claim 1, characterized in that: The task execution process includes: Step B21, extracting the subtask at the head of the task queue, and taking the extracted subtask as the target subtask; Step B22, executing the target subtask and outputting a return value after the execution is completed; Step B23, performing corresponding operations according to the returned value.

6. The multi-task scheduling method in an embedded bare metal system according to claim 5, characterized in that: In step B23, when the return value is "task completed", the target subtask executed in step B22 is deleted from the task queue; When the return value is "repeat execution later", the target subtask executed in step B22 is added to the end of the task queue; When the return value is "repeat execution immediately", the target subtask executed in step B22 is added to the head of the task queue.

7. A multi-task scheduling system in an embedded bare metal system, characterized in that: For implementing the multi-task scheduling method in an embedded bare metal system as claimed in any one of claims 1 to 6, the system comprises: A task decomposition module is used to decompose a business task into multiple independent subtasks in advance, and the multiple subtasks constitute the business task in sequence; A task queue module, wherein an interruption program is pre-installed in the task queue module, wherein the interruption program is used to determine a corresponding business task in response to an external interruption event, take the determined business task as a target business task, and add the first subtask corresponding to the target business task to a task queue; The task processing module is used for cyclically detecting whether there are subtasks to be executed in the task queue, and triggering the task execution process when detecting that there are subtasks to be executed in the task queue.

8. The multi-task scheduling system in an embedded bare metal system according to claim 7, characterized in that: The task enqueue module includes: The first task adding unit is used to add the next subtask of the target business task to the task queue before the current subtask of the target business task is executed.

9. The multi-task scheduling system in an embedded bare metal system according to claim 7, characterized in that: The task processing module also includes: A task extraction unit, used to extract the subtask at the head of the task queue and use the extracted subtask as the target subtask; A task execution unit, connected to the task extraction unit, is used to execute the target subtask and output a return value after the execution is completed; The task response unit is connected to the task execution unit and is used to execute corresponding operations according to the return value.

10. The multi-task scheduling system in an embedded bare metal system according to claim 9, characterized in that: The task response unit comprises: A task deletion subunit, used for deleting the target subtask from the task queue when the return value is "task completed"; A second task adding subunit is used to add the target subtask to the end of the task queue when the return value is "repeat execution later"; The third task adding subunit is used to add the target subtask to the head of the task queue when the return value is "repeat execution immediately".

Citation Information

Cited By

  • Multi-task scheduling method and system of safety controller

    CN121578714A