[go: up one dir, main page]

CN119829234B - A serial intelligent scheduling method in a multi-task producer environment - Google Patents

A serial intelligent scheduling method in a multi-task producer environment

Info

Publication number
CN119829234B
CN119829234B CN202411809912.3A CN202411809912A CN119829234B CN 119829234 B CN119829234 B CN 119829234B CN 202411809912 A CN202411809912 A CN 202411809912A CN 119829234 B CN119829234 B CN 119829234B
Authority
CN
China
Prior art keywords
task
state
event
processing
state machine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202411809912.3A
Other languages
Chinese (zh)
Other versions
CN119829234A (en
Inventor
马煜杰
王震
王慧咏
龚志力
王艳
范京凯
赵明亮
祁春慧
沈月峰
王吕大
陕振
孙大东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Institute of Computer Technology and Applications
Original Assignee
Beijing Institute of Computer Technology and Applications
Filing date
Publication date
Application filed by Beijing Institute of Computer Technology and Applications filed Critical Beijing Institute of Computer Technology and Applications
Priority to CN202411809912.3A priority Critical patent/CN119829234B/en
Publication of CN119829234A publication Critical patent/CN119829234A/en
Application granted granted Critical
Publication of CN119829234B publication Critical patent/CN119829234B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention relates to a serial intelligent scheduling method in a multitasking producer environment, belonging to the technical field of embedded special equipment. The method learns the design concept of the state machine processing mode and utilizes the state machine to process each individual task. Wherein, in order to save the multi-tasking context, the structure and logic are designed to be universal, but can be customized according to the specific interaction flow of each type of task and the data needed to be used in the middle. The method can realize the intelligent task scheduling of multi-task parallelism in a serial (single-thread) mode under the environment of a multi-task producer.

Description

Serial intelligent scheduling method under environment of multitasking producer
Technical Field
The invention belongs to the technical field of embedded special equipment, and particularly relates to a serial intelligent scheduling method under a multi-task producer environment.
Background
In the field of embedded and special equipment, one equipment is often designed to comprise a plurality of processing nodes, each processing node may be a single chip microcomputer or a certain chip, has independent computing capability, has independent software and hardware environments and operating systems, and is deployed at different positions in the equipment to complete different functions. The actual functions that a device needs to perform are often split into several small, relatively independent, but interoperable functions that are deployed separately on top of these processing nodes. To meet the demands of co-operation, the processing nodes need to be interconnected by physical or logical links between the nodes, so as to be able to communicate with each other or send commands to each other. At the same time, some of the processing nodes may also receive communications or control from outside. In the scenario where multiple external or internal objects need to interact with tasks concurrently with respective processing nodes, support for concurrent multitasking needs to be well provided by utilizing the limited software and hardware resources available to these nodes.
Disclosure of Invention
First, the technical problem to be solved
The invention aims to solve the technical problems that 1, a serialization scheduling method capable of supporting parallel multi-tasks is realized, and 2, the serialization scheduling method can save multi-task contexts and provide multi-task scheduling support for multi-interaction steps.
(II) technical scheme
In order to solve the technical problems, the invention provides a serial intelligent scheduling method in a multitasking producer environment, which learns the design idea of a state machine processing mode and processes each individual task by using a state machine; the state machine can process multi-step interaction, has external event-driven tasks among steps, can customize according to specific interaction flow of each type of task and data needed to be used in the middle, and the context of different tasks is stored in the state machine in a mode of independently customizing internal static data according to the task itself, so that next interaction of the same task can be realized by utilizing the data generated before, each type of task which is needed to be completed by a node is provided with an independently defined state machine, each state machine passively receives events from outside, triggers the interaction flow step, completes the state transition, enters the next state, waits for the event from the next step of the current task or starts the event of a new task;
In the method, each processing node is further provided with a main control module serving as an entry point for event processing of all state machines, the main control module holds processing threads when idle, waits and receives data or signals from the outside, judges according to source and type information of the processing threads, packages the data further if needed, generates events which can be processed by the state machines, distributes the events to the state machines which really need to process the events, generates corresponding new state machines for processing the tasks according to task types if a brand new task arrives, and appropriately initializes the new state machines, then the main control module calls event processing logic of the corresponding state machines, transfers control rights of the processing threads to the state machines, the state machines execute one-step task interaction according to the received events, performs corresponding state conversion after the interaction is completed, returns the control rights of the processing threads to the main control module after the task interaction and the state conversion are completed, and continues to circularly execute steps of receiving, distributing, executing and returning the next events, and destroying the work resources of the main control module and the state machines when the task is finished.
Preferably, all state machines follow the principle of "run to complete", i.e. after receiving an event, the state machine performs the corresponding operation according to the state and switches to the next state, cannot be interrupted during processing, and does not receive other events, and is in a certain defined state from the outside, not a certain "intermediate state".
Preferably, if there is a blocking operation waiting for an external IO inside the state machine, the state is divided, and the external IO is treated as an event.
Preferably, the processing of a single task interaction and state transition takes less time than a preset threshold, and the state machine cannot actively initiate an interaction to the outside, which must exist as part of the event processing flow after receiving a certain event.
Preferably, one step of the task always starts from the receipt of signals or data from other nodes or outside the system, i.e. events.
Preferably, the main control module is further provided with an event buffer queue for buffering the events, the event buffer queue adopts a first-in first-out mode, or a priority queue is used for distributing high priority to preset important events.
Preferably, in the method, the main control module caches and distributes the events and processes the handover-return of the thread control rights, and the state machine processes the actual tasks to realize the parallel operation of a plurality of state machines, so that the support of parallel multitasking is provided in a serial form.
Preferably, a plurality of available threads are distributed to the main control module according to the condition of hardware resources, the main control module maintains the threads as a thread pool, one thread is taken out from the thread pool to be distributed to the state machine for event processing each time a new event is received, and the thread is put into the thread pool again after the state machine finishes processing and returns the thread.
The invention also provides a system for implementing the method.
The invention also provides application of the method in the technical field of embedded special equipment.
(III) beneficial effects
The invention provides a serial intelligent scheduling method under the environment of a multitasking producer, which learns the design idea of a state machine processing mode and utilizes the state machine to process each individual task. Wherein, in order to save the multi-tasking context, the structure and logic are designed to be universal, but can be customized according to the specific interaction flow of each type of task and the data needed to be used in the middle. The method can realize the intelligent task scheduling of multi-task parallelism in a serial (single-thread) mode under the environment of a multi-task producer.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
To make the objects, contents and advantages of the present invention more apparent, the following detailed description of the present invention will be given with reference to the accompanying drawings and examples.
Unlike traditional desktop or server computers, in the field of embedded and special equipment, hardware resources of processing nodes, particularly the number of CPU cores and memory capacity are extremely limited, and some nodes such as nodes realized by taking a single chip microcomputer as hardware are difficult to support multithreading even naturally, so that when the nodes need to interact with other multiple nodes or external objects, namely under a multitasking scene, the mode that a traditional thread is responsible for one task is difficult to use, and support of parallel multitasking needs to be realized by a serialized scheduling method. Also, considering that there may be multiple interaction steps for some tasks, the previous step may need to wait for the response of other objects before starting the next interaction, and thus the context of the task needs to be saved for use, which further increases the complexity of the system. The present invention is therefore directed to this scenario. An intelligent task scheduling method for realizing multi-task parallelism in a serial (single-thread) mode under the environment of a multi-task producer is provided.
The serial intelligent scheduling method provided by the invention learns the design idea of a state machine processing mode and utilizes the state machine to process each independent task. A state machine is essentially an object that holds the context and state data of the current processing task while providing the processing logic in each state. After receiving the 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. Thus, these features of the state machine are inherently suited to handle multi-step interactions, with external event-driven tasks between steps. In order to save the multi-task context, a state machine with general structure and logic is designed, but can be customized according to the specific interaction flow of each type of task and the data needed to be used in the middle. The context of the different tasks is saved in the state machine in the form of internal static data that is individually tailored to the task itself so that the next interaction of the same task can take advantage of the previously generated data. Each type of task that the node needs to complete has a separately defined state machine, each state machine passively accepts events from outside, triggers the interactive flow step, completes the state transition, enters the next state, waits for events from the next step of the current task or opens events of a new task.
All state machines follow the "run to complete" principle, i.e. after receiving an event, the state machine must perform a corresponding operation according to the state and switch to the next state, which cannot be interrupted during processing, nor receive other events. The state machine must therefore be in a certain defined state from the outside, not a certain "intermediate state". In addition, the state machine handling each class of events should be well designed, and there should be no blocking operations inside the state machine, such as waiting for external IOs. If such an operation is required, the state should be partitioned and the external IO handled as an event. And the processing process of single task interaction and state conversion is not excessively long, so that other events cannot be responded in time. While the state machine cannot actively initiate an interaction to the outside, the interaction to the outside must exist as part of the event handling process after receiving a certain event. Because one step of the task always starts from receiving signals or data from other nodes or outside the system, i.e., events, such a design can simplify the design concept and avoid many problems that may occur with complex systems.
In this method, each processing node also needs a master control module as an entry point for all state machine event processing. The main control module holds processing threads when in idle, waits for and receives data or signals from the outside, judges according to information such as sources, types and the like, further packages the data if needed, generates events which can be processed by the state machine, and distributes the events to the state machine which really needs to process the events. If a new task arrives, the main control module also needs to generate a corresponding new state machine for processing the task according to the task type, and perform proper initialization on the new state machine. And then, the main control module calls event processing logic of a corresponding state machine, the control right of the processing thread is transferred to the state machine, the state machine executes one-step task interaction according to the received event, and corresponding state conversion is carried out after the interaction is completed. After the task interaction and the state conversion are completed, the state machine returns the processing thread control right to the main control module, and the main control module continues to circularly execute the next event receiving-distributing-executing-returning steps after the thread control right is taken back. When the task is finished (completed or abnormally finished), the main control module also needs to be responsible for resource cleaning and destroying work of the state machine. Meanwhile, the main control module also needs an event buffer queue to solve the problem that the processing speed of the node is difficult to keep up when the external event arrives too fast. The buffer queues may typically take the form of simple first-in-first-out queues, or priority queues may be used if desired to assign high priority to important events to ensure that they are prioritized.
The main control module is used for caching and distributing the events and handing over and returning the control rights of the processing threads, and the state machine is used for processing the actual tasks, so that a plurality of state machines can run in macroscopic parallel, and support for parallel multitasking is provided in a serial form. The overall process flow of the method is shown in figure 1.
The above is discussed in terms of a fully serial scheduling method in a strictly single threaded scenario. If the thread restriction is not strict, the method can be conveniently expanded by distributing a plurality of available threads to the main control module according to the actual hardware resource condition, the main control module maintains the threads as a thread pool, taking out one thread from the thread pool to be distributed to the state machine for event processing when receiving a new event, and putting the thread into the thread pool again after the state machine finishes processing and returns the thread.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.

Claims (10)

1. A serial intelligent scheduling method in a multitasking producer environment is characterized in that the method learns the design idea of a state machine processing mode and utilizes a state machine to process each individual task; the state machine can process multi-step interaction, has external event-driven tasks among steps, can customize according to specific interaction flow of each type of task and data needed to be used in the middle, and the context of different tasks is stored in the state machine in a mode of independently customizing internal static data according to the task itself, so that next interaction of the same task can be realized by utilizing the data generated before, each type of task which is needed to be completed by a node is provided with an independently defined state machine, each state machine passively receives events from outside, triggers the interaction flow step, completes the state transition, enters the next state, waits for the event from the next step of the current task or starts the event of a new task;
In the method, each processing node is further provided with a main control module serving as an entry point for event processing of all state machines, the main control module holds processing threads when idle, waits and receives data or signals from the outside, judges according to source and type information of the processing threads, packages the data further if needed, generates events which can be processed by the state machines, distributes the events to the state machines which really need to process the events, generates corresponding new state machines for processing the tasks according to task types if a brand new task arrives, and appropriately initializes the new state machines, then the main control module calls event processing logic of the corresponding state machines, transfers control rights of the processing threads to the state machines, the state machines execute one-step task interaction according to the received events, performs corresponding state conversion after the interaction is completed, returns the control rights of the processing threads to the main control module after the task interaction and the state conversion are completed, and continues to circularly execute steps of receiving, distributing, executing and returning the next events, and destroying the work resources of the main control module and the state machines when the task is finished.
2. The method of claim 1, wherein all state machines follow the "run to complete" principle, i.e. after receiving an event, the state machine performs the corresponding operation according to the state and transitions to the next state, cannot be interrupted during processing, and does not receive other events, and from the outside, the state machine is in a certain defined state, not a certain "intermediate state".
3. The method of claim 2, wherein the state machine segments the state if there is a blocking operation waiting for an external IO, and wherein the external IO is handled as an event.
4. A method as claimed in claim 3, wherein the processing of a single task interaction and state transition takes less than a preset threshold, the state machine being unable to actively initiate an interaction to the outside, which interaction must be present as part of the event processing flow after receiving a certain event.
5. A method according to claim 1, characterized in that one step of the task always starts from the reception of signals or data from other nodes or outside the system, i.e. events.
6. The method of claim 1, wherein the master control module is further provided with an event buffer queue for buffering events, the event buffer queue being in a first-in-first-out format, or using a priority queue, to assign a high priority to a preset important event.
7. The method of claim 6, wherein the buffering and distribution of events and the handing over-returning of thread control are performed by a master control module, and the actual tasks are processed by state machines to implement parallel operation of a plurality of state machines, thereby providing support for parallel multitasking in a serial form.
8. The method of claim 1 wherein a plurality of available threads are allocated to the master control module according to hardware resource conditions, the master control module maintains the threads as a thread pool, and each time a new event is received, a thread is fetched from the thread pool and allocated to the state machine for event processing, and after the state machine completes processing and returns the thread, the thread is placed in the thread pool again.
9. A system for implementing the method of any one of claims 1 to 8.
10. Use of a method according to any one of claims 1 to 8 in the technical field of embedded, specialty devices.
CN202411809912.3A 2024-12-10 A serial intelligent scheduling method in a multi-task producer environment Active CN119829234B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411809912.3A CN119829234B (en) 2024-12-10 A serial intelligent scheduling method in a multi-task producer environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411809912.3A CN119829234B (en) 2024-12-10 A serial intelligent scheduling method in a multi-task producer environment

Publications (2)

Publication Number Publication Date
CN119829234A CN119829234A (en) 2025-04-15
CN119829234B true CN119829234B (en) 2025-10-14

Family

ID=

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103024791A (en) * 2012-12-28 2013-04-03 广州联正达通信科技股份有限公司 Multi-service processing model and multi-service processing method in communication test system
CN107656777A (en) * 2016-07-25 2018-02-02 武汉票据交易中心有限公司 A kind of flow path processing method and system based on event

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103024791A (en) * 2012-12-28 2013-04-03 广州联正达通信科技股份有限公司 Multi-service processing model and multi-service processing method in communication test system
CN107656777A (en) * 2016-07-25 2018-02-02 武汉票据交易中心有限公司 A kind of flow path processing method and system based on event

Similar Documents

Publication Publication Date Title
EP3786793B1 (en) Task processing method and device, and computer system
US5390329A (en) Responding to service requests using minimal system-side context in a multiprocessor environment
US5721922A (en) Embedding a real-time multi-tasking kernel in a non-real-time operating system
US9870252B2 (en) Multi-threaded processing with reduced context switching
JP5789072B2 (en) Resource management in multi-core architecture
US8963933B2 (en) Method for urgency-based preemption of a process
CN101414270A (en) Method for implementing assist nuclear task dynamic PRI scheduling with hardware assistant
US9529625B2 (en) Method and system for providing stack memory management in real-time operating systems
CN106062716B (en) The method, apparatus and single task system of multitask are realized in single task system
CN110795254A (en) Method for processing high-concurrency IO based on PHP
WO2023246044A1 (en) Scheduling method and apparatus, chip, electronic device, and storage medium
US20240184624A1 (en) Method and system for sequencing artificial intelligence (ai) jobs for execution at ai accelerators
CN108710535A (en) A kind of task scheduling system based on intelligent processor
CN111897637A (en) Job scheduling method, device, host and storage medium
CN110955503A (en) Task scheduling method and device
US11461134B2 (en) Apparatus and method for deferral scheduling of tasks for operating system on multi-core processor
CN115408117A (en) Coroutine operation method and device, computer equipment and storage medium
KR101791182B1 (en) Computer system interrupt handling
CN119829234B (en) A serial intelligent scheduling method in a multi-task producer environment
CN102622271A (en) Method and apparatus for multi-threaded processing and using semaphore
US10949367B2 (en) Method for handling kernel service request for interrupt routines in multi-core environment and electronic device thereof
US11301304B2 (en) Method and apparatus for managing kernel services in multi-core system
CN119829234A (en) Serial intelligent scheduling method under environment of multitasking producer
CN101349975B (en) Method for implementing interrupt bottom semi-section mechanism in embedded operation system
US20250231795A1 (en) Method for executing task scheduling and related products thereof

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant