Serial intelligent scheduling method in multi-task producer environment

By adopting the serial intelligent scheduling method of state machine processing mode in a multitasking environment, the problem of how processing nodes with limited resources support parallel multitasking is solved, and efficient multitasking and collaborative work is achieved.

CN119829234AActive Publication Date: 2025-04-15BEIJING INST OF COMP TECH & APPL

Patent Information

Application Number
CN202411809912.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-15
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

In the multitasking producer environment, it is difficult for the prior art to achieve support for parallel multitasking, especially when the software and hardware resources of the processing node are limited, it is difficult to effectively schedule concurrent multitasking.

Method used

A serial intelligent scheduling method is designed using the state machine processing mode. It saves the context and state data of the task through the state machine, provides processing logical objects, and processes and converts states according to external events, thereby realizing serialized scheduling of multi-tasks.

Benefits of technology

It realizes intelligent task scheduling that supports multi-task parallel in serial mode in a multi-task producer environment, effectively utilizes the limited resources of processing nodes, and ensures the collaborative work and efficient execution of multi-tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829234A_ABST
    Figure CN119829234A_ABST
Patent Text Reader

Abstract

The invention relates to a serial intelligent scheduling method in a multi-task producer environment, and belongs to the technical field of embedded special equipment. According to the method, the design thought of a state machine processing mode is learned, and each independent task is processed through a state machine. In order to store the context of multiple tasks, a state machine which is universal in structure and logic and can be customized according to the specific interaction process of each type of tasks and data needing to be used in the middle is designed. According to the method, multi-task parallel intelligent task scheduling can be realized in a serial (single-thread) mode in a multi-task producer environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of embedded and special equipment, and in particular relates to a serial intelligent scheduling method in a multi-task producer environment. Background Art

[0002] In the field of embedded and special equipment, a device is often designed to contain multiple processing nodes. Each processing node may be a single-chip microcomputer or a chip with independent computing capabilities, independent software and hardware environments, and operating systems. It is deployed in different locations in the device to perform different functions. The actual functions that the device needs to complete are often divided into several small, relatively independent functions that need to work together, and are deployed on these processing nodes separately. In order to meet the needs of collaborative work, these processing nodes need to be connected to each other through physical or logical links between nodes so that they can communicate with each other or send commands to each other. At the same time, some processing nodes may also receive external communications or controls. In scenarios where multiple external or internal objects need to interact with each processing node concurrently for tasks, it is necessary to use the limited software and hardware resources available on these nodes to provide good support for concurrent multitasking. Summary of the invention

[0003] 1. Technical issues to be resolved

[0004] The technical problems to be solved by the present invention are: 1. To realize a serialized scheduling method capable of supporting parallel multi-tasking; 2. The serialized scheduling method can save multi-task context and provide multi-task scheduling support for multiple interactive steps.

[0005] (II) Technical solution

[0006] In order to solve the above technical problems, the present invention provides a serial intelligent scheduling method in a multi-task producer environment, which learns the design concept of the state machine processing mode and uses the state machine to process each individual task; the state machine saves the context and state data of the current processing task, and provides the object of the processing logic in each state. After receiving an external event, the state machine can perform corresponding processing according to the current state and the data contained in the event itself, and switch to the next state; the state machine can handle multi-step interactions, and there are tasks driven by external events between the steps, and can be customized according to the specific interaction process of each type of task and the data required to be used in the middle. The context of different tasks is saved in the state machine in the form of internal static data customized separately according to the task itself, so the next interaction of the same task can be realized using the data generated before; each type of task that the node needs to complete has a separately defined state machine, and each state machine passively accepts events from the outside, triggers the interaction process steps, completes the state transition, enters the next state, and waits for the event from the next step of the current task or the event of starting a new task;

[0007] In this method, each processing node also designs a main control module as the entry point for all state machine event processing. This main control module holds the processing thread when idle, waits for and receives data or signals from the outside, and makes judgments based on its source and type information. If necessary, the data is further encapsulated to generate events that the state machine can handle, and distributes them to the state machine that really needs to handle this event; if a new task arrives, the main control module also generates a corresponding new state machine for processing this task according to the task type, and initializes it appropriately; then, the main control module calls the event processing logic of the corresponding state machine, transfers the control of the processing thread to the state machine, and the state machine executes a step of task interaction according to the received event, and performs the corresponding state transition after the interaction is completed; after completing this task interaction and state transition, the state machine returns the control of the processing thread to the main control module, and the main control module continues to loop the next event reception-distribution-execution-return step after taking back the thread control; when the task ends, the main control module is responsible for the resource cleanup and destruction of the state machine.

[0008] Preferably, all state machines follow the "run to completion" principle, that is, after receiving an event, the state machine performs the corresponding operation according to the state and switches to the next state. It cannot be interrupted during the processing and does not receive other events. From the outside, the state machine is in a defined state, not an "intermediate state".

[0009] Preferably, if there is a blocking operation waiting for external IO inside the state machine, the state is split and the external IO is processed as an event.

[0010] Preferably, the processing time of a single task interaction and state transition is less than a preset threshold. The state machine cannot actively initiate interaction with the outside world. Interaction with the outside world must be after receiving an event as part of the event processing process.

[0011] Preferably, a step of a task always starts with the receipt of a signal or data, ie, an event, from other nodes or outside the system.

[0012] Preferably, the main control module is further provided with an event buffer queue for caching events, and the event buffer queue adopts a first-in-first-out form, or uses a priority queue to assign high priority to preset important events.

[0013] Preferably, in this method, the main control module caches and distributes events and handles the transfer and return of thread control rights, and the state machine processes the actual tasks to achieve parallel operation of multiple state machines, thereby providing support for parallel multi-tasking in serial form.

[0014] Preferably, several available threads are allocated to the main control module according to the hardware resource situation. The main control module maintains it as a thread pool. Whenever a new event is received, a thread is taken out from the thread pool and allocated to the state machine for event processing. After the state machine completes the processing and returns the thread, it is put back into the thread pool.

[0015] The present invention also provides a system for implementing the method.

[0016] The invention also provides an application of the method in the technical field of embedded and special equipment.

[0017] (III) Beneficial effects

[0018] The present invention provides a serial intelligent scheduling method in a multi-task producer environment, which learns the design concept of the state machine processing mode and uses the state machine to process each individual task. In order to save the context of multiple tasks, a state machine with a common structure and logic is designed, but it can be customized according to the specific interaction process of each type of task and the data required to be used in the middle. The method can realize multi-task parallel intelligent task scheduling in a serial (single-threaded) manner in a multi-task producer environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION

[0020] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0021] Unlike traditional desktop or server computers, in the field of embedded and special equipment, the hardware resources of processing nodes, especially the number of CPU cores and memory capacity, are extremely limited. Some nodes, such as nodes that use single-chip microcomputers as hardware implementations, are even naturally difficult to support multi-threading. Therefore, when a node needs to interact with multiple other nodes or external objects, that is, in a multi-tasking scenario, it is difficult to use the traditional "one thread is responsible for one task" model, and a serialized scheduling method is required to support parallel multi-tasking. At the same time, considering that some tasks may also have multiple interaction steps, after the previous step is completed, it may be necessary to wait for other objects to respond before starting the next step of interaction. Therefore, it is also necessary to save the context of the task for use, which further increases the complexity of the system. Therefore, the present invention is aimed at this scenario. A method for intelligent task scheduling that implements multi-task parallelism in a serial (single-threaded) manner in a multi-task producer environment is proposed.

[0022] The present invention provides a serial intelligent scheduling method in a multi-task producer environment, which learns the design idea of ​​the state machine processing mode and uses the state machine to process each individual task. The state machine is essentially an object that saves the context and state data of the current processing task and provides the processing logic in each state. After receiving an external event, the state machine can perform corresponding processing according to the current state and the data contained in the event itself, and switch to the next state. Therefore, these characteristics of the state machine are naturally suitable for processing multi-step interactions, and there are tasks driven by external events between the steps. In order to save the context of multiple tasks, a state machine with a common structure and logic is designed, but it can be customized according to the specific interaction process of each type of task and the data needed to be used in the middle. The context of different tasks is saved in the state machine in the form of internal static data customized individually according to the task itself, so the next interaction of the same task can use the data generated before. Each type of task that the node needs to complete has a separately defined state machine, and each state machine passively accepts events from the outside, triggers the interaction process steps, completes the state transition, enters the next state, and waits for the event of the next step from the current task or the event of starting a new task.

[0023] All state machines follow the "run to completion" principle, that is, after receiving an event, the state machine must perform the corresponding operation according to the state and switch to the next state. It cannot be interrupted during the processing and cannot receive other events. Therefore, from the outside, the state machine must be in a defined state, not a "middle state". In addition, the state machine that handles each type of event should be well designed, and there should be no blocking operations such as waiting for external IO inside the state machine. If such operations are required, the state should be divided and the external IO should be processed as an event. In addition, the processing time of a single task interaction and state transition should not be too long, so as to avoid other events not being responded to in time. At the same time, the state machine cannot actively initiate interaction with the outside. The interaction with the outside must exist as part of the event processing process after receiving an event. Because a step of a task always starts with receiving a signal or data from other nodes or outside the system, that is, an event, such a design can simplify the design ideas and avoid many problems that may arise in complex systems.

[0024] In this method, each processing node also needs a main control module as the entry point for all state machine event processing. This main control module holds the processing thread when idle, waits for and receives data or signals from the outside, and makes judgments based on information such as its source and type. If necessary, the data should be further encapsulated to generate events that the state machine can handle, and distribute them to the state machine that really needs to handle this event. If a new task arrives, the main control module also needs to generate a corresponding new state machine for processing this task according to its task type, and initialize it appropriately. Subsequently, the main control module calls the event processing logic of the corresponding state machine, transfers the control of the processing thread to the state machine, and the state machine performs a step of task interaction according to the received event, and performs the corresponding state transition after the interaction is completed. After completing this task interaction and state transition, the state machine returns the control of the processing thread to the main control module, and the main control module continues to loop the next event reception-distribution-execution-return step after taking back the thread control. When the task ends (completed or abnormally ended), the main control module is also responsible for the resource cleanup and destruction of the state machine. At the same time, the main control module also needs an event buffer queue to solve the problem that when external events arrive too fast, the node processing speed is difficult to keep up. The buffer queue can generally adopt a simple first-in-first-out form. If necessary, a priority queue can also be used to assign high priority to some important events to ensure that they can be processed first.

[0025] The main control module caches and distributes events and handles the transfer and return of thread control rights. The state machine processes the actual tasks, which can realize the parallel operation of multiple state machines on a macro level, thereby providing support for parallel multi-tasking in a serial form. The overall processing flow of this method is as follows Figure 1 shown.

[0026] The above discussion is about the fully serial scheduling method in a strict single-threaded scenario. If the thread limit is not so strict, this method can also be easily expanded: according to the actual hardware resources, several available threads are allocated to the main control module, and the main control module maintains it as a thread pool. Whenever a new event is received, a thread is taken from the thread pool and assigned to the state machine for event processing. After the state machine completes the processing and returns the thread, it is put back into the thread pool.

[0027] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A serial intelligent scheduling method in a multi-task producer environment, characterized in that: This method learns the design idea of ​​the state machine processing mode and uses the state machine to process each individual task; the state machine saves the context and state data of the current processing task, and provides the object of the processing logic in each state. After receiving an external event, the state machine can perform corresponding processing according to the current state and the data contained in the event itself, and switch to the next state; the state machine can handle multi-step interactions, and there are tasks driven by external events between the steps, and can be customized according to the specific interaction process of each type of task and the data needed in the middle. The context of different tasks is saved in the state machine in the form of internal static data customized according to the task itself, so the next interaction of the same task can be realized using the data generated before; Each type of task that a node needs to complete has a separately defined state machine. Each state machine passively accepts events from the outside, triggers interactive process steps, completes state transitions, enters the next state, and waits for events from the next step of the current task or events to start a new task. In this method, each processing node also designs a main control module as the entry point for all state machine event processing. This main control module holds the processing thread when idle, waits for and receives data or signals from the outside, and makes judgments based on their source and type information. If necessary, it further encapsulates the data, generates events that the state machine can handle, and distributes them to the state machine that really needs to handle this event; if a new task arrives, the main control module also generates a corresponding new state machine for processing this task according to the task type, and initializes it appropriately; Subsequently, the main control module calls the event processing logic of the corresponding state machine and transfers the control of the processing thread to the state machine. The state machine executes a task interaction step according to the received event and performs the corresponding state transition after the interaction is completed. After completing this task interaction and state transition, the state machine returns the control of the processing thread to the main control module. After taking back the control of the thread, the main control module continues to loop and execute the next event reception-distribution-execution-return steps. When the task is completed, the main control module is responsible for the resource cleanup and destruction of the state machine.

2. The method according to claim 1, characterized in that All state machines follow the "run to completion" principle, that is, after receiving an event, the state machine performs the corresponding operation according to the state and switches to the next state. It cannot be interrupted during the processing and does not receive other events. From the outside, the state machine is in a defined state, not an "intermediate state".

3. The method according to claim 2, characterized in that If there is a blocking operation waiting for external IO inside the state machine, the state will be split and the external IO will be processed as an event.

4. The method according to claim 3, characterized in that The processing time of a single task interaction and state transition is less than the preset threshold. The state machine cannot actively initiate interaction with the outside world. Interaction with the outside world must exist after receiving an event as part of the event processing process.

5. The method according to claim 1, characterized in that A step of a task always starts with receiving a signal or data, that is, an event, from other nodes or outside the system.

6. The method according to claim 1, characterized in that The main control module is also provided with an event buffer queue for caching events. The event buffer queue adopts a first-in-first-out form, or uses a priority queue to assign high priority to preset important events.

7. The method according to claim 6, characterized in that In this method, the main control module caches and distributes events and handles the transfer and return of thread control rights, and the state machine processes the actual tasks to achieve parallel operation of multiple state machines, thereby providing support for parallel multi-tasking in serial form.

8. The method according to claim 1, characterized in that According to the hardware resources, several available threads are allocated to the main control module, which is maintained as a thread pool. Whenever a new event is received, a thread is taken out of the thread pool and allocated to the state machine for event processing. After the state machine completes the processing and returns the thread, it is put back into the thread pool.

9. A system for implementing the method according to any one of claims 1 to 8.

10. Application of the method according to any one of claims 1 to 8 in the field of embedded and special equipment technology.

Citation Information

Patent Citations

  • Multi-service processing model and multi-service processing method in communication test system

    CN103024791A

  • Process processing method and system based on event

    CN107656777A

  • Spring-based process state machine system and processing method thereof

    CN111950990A

  • Process engine implementation method and system based on Spark and parallel memory computing

    CN112379884A

  • Debugging method and debugging system for multi-task programs

    US5799142A

Cited By

  • Efficient collaborative task scheduling method based on RSIC-v architecture embedded system

    CN120762840A