Task parallel processing method and system based on single-thread asynchronous multi-task framework
By using a single-threaded asynchronous multi-task framework to encapsulate communication interactions and generate chain tasks in the intelligent driving system, the communication blocking and business coupling problems caused by the complexity of intelligent driving functions are solved, and efficient task parallel processing and process automation are achieved.
Patent Information
- Application Number
- PCT/CN2023/140230
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-26
- Filing Date
- 2023-12-20
- Publication Date
- 2024-10-31
AI Technical Summary
The complexity of intelligent driving functions leads to multiple interaction targets, long process chains, easy communication obstruction, and solidified coupling of business functions, which affects processing efficiency and user experience.
It adopts a single-threaded asynchronous multi-task framework, encapsulates communication interactions into command tasks, registers them in different task channels, generates chain tasks of business function requests, determines task relationships through task working status, realizes asynchronous parallel processing, and deeply decouples business functions. .
It improves the reusability and adaptability of business functions, automates operations, optimizes business process configuration, reduces communication blocking and coupling problems, and improves processing efficiency.
Smart Images

Figure CN2023140230_31102024_PF_FP_ABST
Abstract
Description
Task parallel processing method and system based on single-thread asynchronous multi-tasking framework
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on April 26, 2023, with application number 202310475844.0 and public name “Task parallel processing method and system based on single-threaded asynchronous multi-tasking framework”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present invention belongs to the technical field of task parallel processing, and in particular relates to a task parallel processing method, system, device and medium based on a single-threaded asynchronous multi-tasking framework. Background Art
[0004] The current widespread adaptation of intelligent driving sensor characteristics has made intelligent driving functions more extensive and complex, as shown below:
[0005] (1) Intelligent driving functions often have too many interactive target modules, and the processing direction of each node has derived a large number of processing branches. With the subsequent changes in requirements and functions, for example, the processing under a specific message may not necessarily be adapted to other types of the same sensor, resulting in communication timeouts or anomalies; at the same time, adapting to sensors with new characteristics can easily lead to mismatches between previous interfaces and channel communication methods.
[0006] (2) The process chain is too long. The status result information of the previous information processing needs to be saved and passed to the subsequent process for further processing. Because of the multi-threaded asynchronous processing, it needs to be saved and processed in a global manner or saved step by step and then passed down. Intermediate state information is often required, which can easily lead to a longer process, redundant storage management information, and more bloated logical processing. Asynchronous and multi-threaded processes can easily lead to delays and loss of intermediate state information, affecting the logic of subsequent processing. For example, the cloud-based flash (OTA) upgrade of sensors includes process strategies such as pre-upgrade processing, upgrade process, post-upgrade processing, and abnormal rollback. Among them, the transmission of sensor characteristic information, the connection of security verification authentication keys, the negotiation of file transfer blocks, the flow control and confirmation during data packet transmission, time-consuming business waiting, read and write area address data verification, and failure point rollback processing all require associated context information and multiple rounds of interaction.
[0007] (3) Channel blocking processing. Synchronous blocking communication is used between or within modules. Channels are occupied, blocking and affecting other communications using the channel. For communications that are sensitive to communication time, it often causes anomalies or failures. Simply opening multiple threads cannot solve the problem. For example, the network layer timing (N_Br and N_Cr) time parameters in the UDS diagnostic (DOCAN) protocol stack based on the controller area network bus are 30 milliseconds, 50 milliseconds, etc., and even the time parameter for sending continuous data frames is 1 millisecond. Time-sensitive communication can easily lead to communication timeout failure. UDS diagnostics based on the controller area network bus can easily lead to communication timeout failure. Sensors based on the UDS diagnostics of the controller area network bus will return to the default session if there is no communication processing for 5 seconds, and the communication under the current non-default session will fail. Sensors based on Ethernet network diagnostics (DOIP) will even actively disconnect the socket (socket) that provides a mechanism for transmitting data packets to the application layer process by combining IP address and port if there is no communication within 5 seconds. Using blocking communication under a series of time parameter restrictions can easily lead to frequent communication failures.
[0008] (4) When multi-task and multi-function processing is performed in parallel, the adhesion coupling between business functions forces functions that do not affect each other to be serialized, which increases processing time, reduces business function efficiency, and affects user experience. For example, when diagnosing DOIP and DOCAN sensors simultaneously, the two diagnostic pathways are originally independent of each other. However, due to the adhesion coupling between business functions, it is currently necessary to wait for more than 5 seconds when switching between DOIP and DOCAN diagnosis. Even when faced with collaborative processing between DOIP and DOCAN, such as sensor calibration, business logic changes often require modification.
[0009] (5) Process business is rigid and driven by business function requests, which is not easy to configure. Processes often require automated processing and dynamic adjustment. For example, when DOIP's Lidar sensor (Lidar) switches to a programming session for the first time, it needs to switch the system to restart and re-establish the connection; after DOCAN's millimeter wave sensor (SRR) performs a hard reset, it often takes 500ms to wait before continuing diagnostic communication; DOCAN's ultrasonic radar sensor (USSC) flashing requires not only flashing the firmware application (app firmware), but also flashing the firmware boot program (boot firmware) and firmware calibration program (cal firmware). The different flashing processes of each file require the business function process to be deeply bound to the sensor characteristics, which often leads to limited optimization of the business function process.
[0010] In view of this, the present invention proposes a task parallel processing method, system, device and medium based on a single-threaded asynchronous multi-tasking framework to solve the problems of multiple interactive targets, long process chains, easy blockage of business processing methods, and solidified business coupling when the current intelligent driving function is used.
[0011] Summary of the Invention
[0012] The present invention provides a task parallel processing method, system, device and medium based on a single-threaded asynchronous multi-tasking framework. By providing an automated asynchronous parallel multi-tasking framework, deep decoupling is achieved between various business functions, the reusability and adaptability of business functions are improved, and business processes are automatically run and can be optimized.
[0013] The purpose of the present invention and the solution to the technical problem are achieved by adopting the following technical solutions.
[0014] The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking framework, which includes: under the multi-tasking framework, encapsulating communication interactions with the outside as instruction tasks, and encapsulating synchronous blocking requests in communication interactions using a newly added asynchronous adaptation feature task method; based on the interaction request of the instruction task, registering the instruction task to the path corresponding to different tasks; generating general tasks and chain tasks for business function requests based on the relevant instruction tasks; aggregating unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and writing general tasks; performing pre-processing, security verification, file writing, progress checking, consistency verification and abnormal retry and rollback business functions of the upgrade process based on the chain task process; multiplexing common business functions in different sensors; judging the relationship between tasks based on the task working status; sequentially executing tasks in the task queue; entering the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task; wherein, general tasks include upper-level general tasks and top-level general tasks.
[0015] Optionally, the general task of generating a business function request based on the relevant instruction task includes: aggregating related communication instruction tasks to generate a general task corresponding to the business function; aggregating the general task of business logic and the instruction task to generate a top-level general task that responds to the business request; and generating a chain task of business function request.
[0016] Optionally, the aggregation-related communication instruction tasks generate general tasks corresponding to business functions including: general tasks for generating unified diagnostic service diagnostic communication based on at least two of the diagnosis of unified diagnostic service and controller LAN bus, diagnostic sensor communication instruction tasks of Ethernet network and timer tasks for post-communication delay control.
[0017] Optionally, the general tasks for generating corresponding business functions by aggregating related communication instruction tasks also include: aggregating and generating a general task for unified diagnostic service diagnostic communication; and generating a general task for a security verification process based on the authentication mask of the sensor and the authentication algorithm of the sensor application layer and driver layer.
[0018] Optionally, the aggregation-related communication instruction tasks may generate general tasks corresponding to business functions, including:
[0019] Aggregate and generate diagnostic communication files for unified diagnostic service diagnostic communication; clear storage area information before upgrade based on binary file format, file size and starting address information in diagnostic communication file transmission; negotiate the transmission of upgraded sensor files, control the transmission of upgraded sensor files, and verify the consistency of the transmitted upgraded sensor files.
[0020] Optionally, general tasks for generating corresponding business functions also include:
[0021] Nest multiple layers of related communication instruction tasks; decouple tasks at the same level; combine and serialize decoupled tasks at the same level and communication instruction tasks based on business logic to generate chained general tasks corresponding to business functions.
[0022] Optionally, general tasks for generating corresponding business functions also include:
[0023] Obtain task execution and result callback notifications, check the task execution results and related task feedback information based on the result callback notifications, and publish the next task to generate a chain process; chain the tasks in series, combine complex business function-decoupled tasks and communication instruction tasks at the same level; reuse the task instructions that are repeatedly executed in the chain process; feedback the result callback of each task execution; based on the task flow generated by each task, cover each task branch in the business process and locate abnormal task branches.
[0024] Optionally, judging the relationship between tasks based on the task working status includes: processing task scheduling, starting a task working cycle, checking task status results in sequence, and judging the relationship between tasks.
[0025] Optionally, sequentially executing tasks in the task queue includes: sequentially executing tasks in the instruction task queue; sequentially executing tasks in the general task queue; and sequentially executing tasks in the top-level general task queue.
[0026] Optionally, encapsulating communication interactions with the outside into instruction tasks includes: encapsulating communication interactions established externally into a single independent instruction task; establishing the instruction task corresponding to the communication; aggregating the instruction tasks in the upper-level general tasks; adding features to the aggregated instruction tasks; and adapting the newly added features based on the instruction tasks.
[0027] Optionally, the method of using the newly added asynchronous adaptation feature task to synchronously block requests in communication interactions includes:
[0028] The command task of the CAN bus sensor with the newly added adaptation feature is newly created based on the diagnostic protocol stack of the CAN bus and the CAN bus sensor with the newly added adaptation feature, and the command task is adapted based on the newly added feature to generate a general task of the unified diagnostic service.
[0029] Optionally, encapsulating the synchronous blocking request in the communication interaction using the newly added asynchronous adaptation feature task method also includes: converting the synchronous communication interaction method into an asynchronous multi-task request response feedback method. Optionally, the task parallel processing method also includes: registering and configuring state information combined with the task context, and controlling only one of the instruction tasks in a single path to be executed based on the state information.
[0030] Optionally, the task parallel processing method further includes:
[0031] Schedule and execute tasks in the same queue in real time. Implement multi-task concurrent execution for top-level general tasks in different queues. Implement simultaneous concurrent execution for multiple identical general tasks in different queues.
[0032] Optionally, entering the loop processing of waiting for chain tasks and top-level tasks based on the preset conditions of the instruction task includes: waiting for the sleep processing of chain tasks and top-level tasks based on the minimum time slice conditions preset by the instruction task; waiting for new task requests; or starting task work and replying to feedback; or in the event of a timer timeout, the task work is reactivated and executed.
[0033] Optionally, the step of entering into a loop of waiting chain tasks and top-level tasks based on a preset condition of the instruction task further includes:
[0034] After periodically checking and executing the tasks in the queue in sequence, they are processed based on the minimum timer in the instruction task, waiting for new requests and reply feedback; or in the event of a timer timeout, the task work is reactivated and executed.
[0035] Optionally, the task parallel processing method also includes: in the general task of the unified diagnostic service communication of the encapsulated diagnosis, obtaining the file information of the newly added asynchronous adaptation feature configuration of the communication unified diagnostic service, constructing the corresponding general task based on the configured file information; and automatically executing the general task.
[0036] Optionally, the task parallel processing method also includes: modifying the file information corresponding to the newly added asynchronous adaptation feature configuration based on the communication unified diagnostic service; dynamically adjusting and optimizing the general tasks corresponding to the communication unified diagnostic service business process based on the configured file information; and automatically executing the general tasks.
[0037] The present invention also provides a task parallel processing system based on a single-threaded asynchronous multi-tasking framework, which includes: an instruction task module, which is used to encapsulate communication interactions with the outside into instruction tasks under the multi-tasking framework, and encapsulate synchronous blocking requests in communication interactions using a newly added asynchronous adaptation feature task method; based on the interaction request of the instruction task, the instruction task is registered in the path corresponding to different tasks; an aggregation task module, which is used to generate general tasks and chain tasks for business function requests based on the relevant instruction tasks; aggregate unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and writing general tasks; perform pre-processing, security verification, file writing, progress checking, consistency verification and abnormal retry and rollback business functions of the upgrade process based on the chain task process; reuse common business functions in different sensors; a task scheduling module, which is used to judge the relationship between tasks based on the task working status; execute tasks in the task queue sequentially; enter the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task; wherein, general tasks include upper-level general tasks and top-level general tasks.
[0038] Optionally, the task parallel processing system further includes: a task configuration module, configured to register and configure status information combined with task context, and control only one instruction task in a single path to be executed based on the status information.
[0039] Optionally, the task parallel processing system also includes: a task thread module, which is used to schedule and execute tasks in the same queue in real time; implement simultaneous multi-task concurrent execution for top-level general tasks in different queues; and implement simultaneous concurrent execution for multiple identical general tasks in different queues.
[0040] The present invention also provides an electronic device, which includes: a memory for storing non-temporary computer-readable instructions; and a processor for running the computer-readable instructions, so that when the computer-readable instructions are executed by the processor, the task parallel processing method based on the single-threaded asynchronous multi-tasking framework described above is implemented.
[0041] The present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the above-mentioned task parallel processing method based on the single-threaded asynchronous multi-tasking framework.
[0042] Compared with the prior art, the present invention has obvious advantages and beneficial effects. By means of the above technical solution, the present invention has at least one of the following advantages and beneficial effects:
[0043] 1. The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking framework, which includes: in the multi-tasking framework, encapsulating communication interactions with the outside as instruction tasks, and encapsulating synchronous blocking requests in communication interactions using a newly added asynchronous adaptation feature task method; based on the interaction request of the instruction task, registering the instruction task to the path corresponding to different tasks; generating general tasks and chain tasks for business function requests based on the relevant instruction tasks; aggregating unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and writing general tasks; performing pre-processing, security verification, file writing, progress checking, consistency verification and abnormal retry and rollback business functions of the upgrade process based on the chain task process; reusing common business functions in different sensors; judging the relationship between tasks based on the task working status; sequentially executing tasks in the task queue; entering the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task; wherein, general tasks include upper-level general tasks and top-level general tasks. The present invention encapsulates communication interactions with the outside into instruction tasks, registers instruction tasks into pathways corresponding to different tasks based on interaction requests of instruction tasks; generates general tasks for business function requests based on related instruction tasks; aggregates related communication instruction tasks to generate general tasks corresponding to business functions; aggregates general tasks and instruction tasks to generate top-level general tasks; generates chain tasks for business function requests; processes task scheduling, starts task work cycles, checks task status in turn, and determines the relationship between tasks; sequentially executes tasks in task queues; and enters a cyclic processing flow of waiting tasks based on the conditions of instruction tasks. The present invention provides an automated asynchronous and parallel multi-task framework, which enables deep decoupling between various business functions, improves the reusability and adaptability of business functions, and enables business processes to run automatically and be optimized. The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-task framework, an automated asynchronous and parallel multi-task framework, which enables deep decoupling between various business functions, improves the reusability and adaptability of business functions, and enables business processes to run automatically and be optimized.
[0044] 2. The present invention also provides a task parallel processing system based on a single-threaded asynchronous multi-tasking framework, which includes: an instruction task module, which is used to encapsulate communication interactions with the outside into instruction tasks under the multi-tasking task framework, and encapsulate synchronous blocking requests in communication interactions using a newly added asynchronous adaptation feature task method; based on the interaction request of the instruction task, the instruction task is registered in the path corresponding to different tasks; an aggregation task module, which is used to generate general tasks and chain tasks for business function requests based on the relevant instruction tasks; aggregate unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and writing general tasks; perform pre-processing, security verification, file writing, progress check, consistency verification and abnormal retry and rollback business functions of the upgrade process based on the chain task process; reuse common business functions in different sensors; a task scheduling module, which is used to judge the relationship between tasks based on the task working status; execute tasks in the task queue sequentially; enter the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task; wherein, general tasks include upper-level general tasks and top-level general tasks. The present invention inherits the general base class for task creation through a task base class module, and the task base class module includes: single-step tasks, timer tasks, instruction tasks, general tasks and task events, which are used to integrate the general processing of the above-mentioned multiple tasks; the communication interaction with the outside is encapsulated as an instruction task through the instruction task module; the instruction task is registered in the path corresponding to different tasks based on the interaction request of the instruction task through the task configuration module; the general task of the business function request is generated based on the relevant instruction task through the aggregation task module; the general task of the corresponding business function is generated by aggregating related communication instruction tasks; the general task of the corresponding business function is generated by aggregating general tasks and instruction tasks; the chain task of the business function request is generated; the task scheduling module processes the task scheduling, starts the task work cycle, checks the task status in sequence, and judges the relationship between each task; the task thread module executes the tasks in the task queue in sequence; and the loop processing flow of the waiting task is entered based on the condition of the instruction task. The present invention provides an automated asynchronous and parallel multi-task framework, so that each business function is deeply decoupled, the reusability and adaptability of the business function are improved, and the business process is automatically operated and can be optimized and configured. The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking framework, which is applied to a task parallel processing system based on a single-threaded asynchronous multi-tasking framework. The automated asynchronous parallel multi-tasking framework enables deep decoupling between business functions, improves the reusability and adaptability of business functions, and enables automatic operation of business processes and optimized configuration.
[0045] 3. The present invention also provides an electronic device, which includes: a memory for storing non-temporary computer-readable instructions; and a processor for running the computer-readable instructions, so that when the computer-readable instructions are executed by the processor, the task parallel processing method based on the single-threaded asynchronous multi-tasking framework described above is implemented. The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking framework, which is applied to electronic devices, automates the asynchronous parallel multi-tasking framework, and achieves deep decoupling between various business functions, thereby improving the reusability and adaptability of business functions, and automating the operation of business processes and optimizing configuration.
[0046] Fourth, the present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the task parallel processing method based on the single-threaded asynchronous multi-tasking framework described above. The present invention provides a task parallel processing method based on the single-threaded asynchronous multi-tasking framework, which is applied to a computer-readable storage medium to automate the asynchronous parallel multi-tasking framework, thereby achieving deep decoupling between various business functions, improving the reusability and adaptability of business functions, and automating the operation of business processes and optimizing their configuration.
[0047] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] 1 is a schematic flow chart of a method for parallel processing of tasks based on a single-threaded asynchronous multi-tasking framework according to an embodiment of the present invention;
[0049] 2 is a schematic flow diagram of the operation of instruction tasks and instruction task paths in a task parallel processing method according to an embodiment of the present invention;
[0050] 3 is a schematic diagram of a flow chart of task thread work cycle scheduling in a task parallel processing method according to an embodiment of the present invention;
[0051] 4 is a schematic diagram of a flow chart of executing aggregated tasks in a chain manner in a method for parallel processing of tasks according to an embodiment of the present invention;
[0052] 5 is a schematic diagram of the process flow of task aggregation chain operation in the task process chain of the task parallel processing method according to an embodiment of the present invention;
[0053] 6 is a schematic diagram of a process of adding a feature task to a task framework of a task parallel processing method according to an embodiment of the present invention;
[0054] 7 is a schematic diagram of a process of changing a task blocking synchronization into an asynchronous event in a task parallel processing method according to an embodiment of the present invention;
[0055] FIG8 is a schematic diagram of a flowchart of asynchronous concurrency of tasks in a method for parallel processing of tasks according to an embodiment of the present invention;
[0056] 9 is a schematic diagram of a task configuration automation process of a task parallel processing method according to an embodiment of the present invention;
[0057] 10 is a schematic structural diagram of a task parallel processing system based on a single-threaded asynchronous multi-tasking framework according to an embodiment of the present invention;
[0058] FIG11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
[0059] FIG12 is a schematic structural diagram of a single-threaded asynchronous multi-tasking framework according to another embodiment of the present invention. DETAILED DESCRIPTION
[0060] In order to further illustrate the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the specific implementation methods, structures, features and effects proposed according to the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.
[0061] The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking task framework under a multi-tasking task framework. The task parallel processing method encapsulates communication interactions with the outside into instruction tasks, registers instruction tasks into paths corresponding to different tasks based on interaction requests of instruction tasks; generates general tasks for business function requests based on related instruction tasks; aggregates related communication instruction tasks to generate general tasks corresponding to business functions; aggregates general tasks and instruction tasks to generate top-level general tasks; generates chain tasks for business function requests; processes task scheduling, starts task work cycles, checks task statuses in sequence, and determines the relationships between tasks; sequentially executes tasks in the task queue; and enters a cyclic processing flow of waiting tasks based on the conditions of instruction tasks. By providing an automated asynchronous parallel multi-tasking framework, the present invention achieves deep decoupling between business functions, improves the reusability and adaptability of business functions, and enables automated operation of business processes and optimized configuration.
[0062] The purpose of the present invention and the solution to the technical problem are achieved by adopting the following technical solutions.
[0063] The present invention provides a task parallel processing method based on a single-threaded asynchronous multi-tasking framework. As shown in FIG1 , the task parallel processing method includes the following steps.
[0064] S1: Under the multi-tasking framework, the communication interaction with the outside is encapsulated as a command task, and the synchronous blocking request in the communication interaction is encapsulated using the newly added asynchronous adaptation feature task method; based on the interaction request of the command task, the command task is registered to the path corresponding to different tasks.
[0065] It should be noted that after the task framework based on single-threaded asynchronous multitasking creates a task, it encapsulates the communication interaction requests between the task framework and the external environment into individual instruction tasks, and encapsulates the time-consuming synchronous blocking requests in the communication interaction into non-blocking asynchronous events. When the communication interaction requests in the instruction task are independently and exclusively communicated with the external environment in a serial manner, the instruction tasks are registered with the corresponding different task paths to avoid mutual interference between interaction requests in the same path. As shown in Figure 2, under the multi-tasking task framework, multiple interaction requests are established between the task framework service itself and the external module, such as interaction request A, interaction request B, interaction request C, interaction request D, and interaction request E. These interaction requests are converted one by one into instruction tasks, such as instruction task A, instruction task B, instruction task C, instruction task D, and instruction task E, and these instruction tasks are registered in the registered instruction task set. Among them, the registered instruction task set includes multiple instruction paths, such as instruction path X and instruction path Y. For example, the above registration can register and configure the above multiple instruction tasks such as instruction task A and instruction task D in instruction path X, and register and configure instruction task B, instruction task C and instruction task E in instruction path Y. The registered configured instruction task A and instruction task D cannot interfere with the registered configured instruction task B, instruction task C and instruction task E.
[0066] S2: Generate general tasks and chain tasks for business function requests based on the relevant instruction tasks; aggregate unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and flashing general tasks; perform pre-processing, security verification, file flashing, progress checking, consistency checking and abnormal retry and rollback business functions of the upgrade process based on the chain task process; reuse common business functions in different sensors.
[0067] It should be noted that by aggregating the above-mentioned related communication instruction tasks to form general tasks for specific business functions, and further aggregating the general tasks and instruction tasks of the business function logic to generate top-level general tasks that respond to business requests, chain tasks for business function requests are generated, and chain tasks for business function requests are realized under the task framework of single-threaded asynchronous multi-tasking. General tasks can be nested in multiple layers, and highly decoupled operations can be performed between tasks at the same level, making general tasks highly combinable and reusable. The configuration of general tasks can also realize dependency, exclusivity, interruption and other processing processes between tasks, and then the above-mentioned tasks are combined and connected into a whole according to the logic of the business function. The combined and connected tasks as a whole can realize complex business function requirements. The combined and connected tasks are executed in a chain manner. Each task has a clear execution request and execution feedback, and the direction of the business branch is clear and clear.
[0068] In an embodiment of the present invention, the aforementioned multiple sensor upgrade tasks are aggregated to generate general tasks for the sensor $34 / $38 file transfer, control, and flashing process. The general tasks for unified diagnostic service communication, authentication verification, and file transfer and flashing are further aggregated. Based on the chained process of these general tasks, a complete business function is implemented, including pre-processing, security verification, upgrade file transfer and flashing, upgrade progress checking, upgrade file consistency verification, and retry and rollback of upgrade anomalies. Different sensor upgrade tasks can also reuse the same tasks within a highly common chained process. As shown in Figure 5, using the example of a task aggregation chain within a sensor task process chain, the sensor communication command task can execute the "execution command" and "command feedback event callback" for the upgrade task at a 1:1 ratio; the communication delay timer task can execute the "timer event callback" for the sensor upgrade task at a 1:1 ratio. The sensor communication command task and communication delay timer task are aggregated to form a unified diagnostic service general task. This unified diagnostic service general task includes "sending unified diagnostic service commands" and "calling back unified diagnostic service results." The "sending unified diagnostic service commands" and "calling back unified diagnostic service results" tasks are then broken down into complex business function general tasks at a ratio greater than 1:1. The unified diagnostic service general task for sensor upgrades is broken down into security authentication service general tasks, file transfer and flashing general tasks, and sensor upgrade general tasks. The security authentication service general task includes "sensor authentication mask," "sensor application layer authentication algorithm," and "sensor driver layer authentication algorithm." The file transfer and flashing general task includes "binary file format conversion," "flash storage space clearing," "file transfer control negotiation," "file transfer control," and "flash consistency check." The sensor upgrade general task includes "upgrade pre-order check," "security check," "file transfer and flash," "progress check," "flash consistency check," and "failure rewrite." Furthermore, the chain process of the "Sensor Authentication Mask", "Sensor Application Layer Authentication Algorithm" and "Sensor Driver Layer Authentication Algorithm" in the general task of security authentication service is combined into the general task of sensor upgrade in a 1:1 ratio, and the chain process of the "Binary File Format Conversion", "Flash Storage Space Clearance", "File Transfer Control Negotiation", "File Transfer Control" and "Flash Consistency Verification" in the general task of file transfer and flashing are also combined into the general task of sensor upgrade in a 1:1 ratio, and the chain process combination of the "Upgrade Pre-order Check", "Security Verification", "File Transfer Flashing", "Progress Check", "Flash Consistency Verification" and "Failure Rewrite" tasks of the general task of sensor upgrade is regenerated.
[0069] S3: Determine the relationship between tasks based on their working status; execute tasks in the task queue sequentially; and enter a loop of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task. General tasks include upper-level general tasks and top-level general tasks.
[0070] It should be noted that the task thread is started to process task scheduling. Under the task framework of single-threaded asynchronous multi-tasking, the working thread starts the task working cycle. In the working cycle, the working thread checks the task status results in the cycle in turn to determine the task relationships such as dependency, interruption, and exclusivity between each task; then, tasks arranged in the instruction task queue are executed in sequence, tasks arranged in the general task queue are executed in sequence, and tasks arranged in the top-level general task queue are executed in sequence; finally, according to the preset minimum time slice setting of the instruction task, the instruction task is put into sleep processing and waits for new task requests; or a task event is started to wake up the working thread to continue cyclically processing the task status. Among them, the execution of the instruction task is to execute the communication interaction request with the external module and wait for the result feedback of the communication interaction request; the general task is to process the logic of the business function and execute the instruction task; the chain of tasks is to create and publish new tasks based on the previous execution result, and continuously publish new tasks to each task queue through the task scheduling operation to wait for execution, while managing the execution results of the task, callback feedback and updating the task context tracking status information.
[0071] As shown in Figure 3, the task thread is started, and the task thread starts the working thread, so that the working thread enters the task thread work cycle process, such as checking the task status result, executing the instruction task queue set, executing the general task queue set, executing the top-level general task queue set, waiting for the minimum time slice of the instruction task, and waking up the task or task event in a cyclic manner according to the task thread work cycle process. The chain process of the task creates and publishes a new task based on the execution result of the previous task, and continuously publishes the new task to each task queue for execution through the task scheduling operation, such as the execution instruction task queue set, the execution general task queue set, and the execution top-level general task queue set in the task thread work cycle. At the same time, the execution result of the task is managed, callback feedback and update task status context are updated, and the status information of the execution task context tracking is tracked. The present invention realizes an automated asynchronous parallel multi-task framework by providing a task parallel processing method based on a single-threaded asynchronous multi-task framework, so that each business function is deeply decoupled, the reusability and adaptability of the business function are improved, and the business process is automatically operated and can be optimized and configured.
[0072] Optionally, the general task of generating a business function request based on the related instruction task includes:
[0073] Aggregate related communication instruction tasks to generate general tasks corresponding to business functions;
[0074] Aggregating the general tasks of the business logic and the instruction tasks to generate a top-level general task that responds to the business request;
[0075] Generate chained tasks for business function requests.
[0076] It should be noted that, as shown in Figure 4, taking instruction task A, instruction task B and instruction task C as an example, instruction task A and instruction task B are respectively converted into general task X, and instruction task B is correspondingly converted into top-level general task Z, and instruction task C is converted into general task Y. The communication instruction tasks related to instruction task A, instruction task B and instruction task C form a specific business request Z, and the general task X, instruction task B and general task Y are aggregated to generate the top-level general task Z. In the further execution of the chain execution process of the aggregated task, the above-mentioned top-level general task Z is converted into the chain execution process of executing the aggregated task. For example, when executing the specific business request Z, the top-level general task Z, general task X, instruction task A, instruction task B, general task B, general task Y and instruction task C are executed in sequence. The present invention realizes multi-layer nesting of general tasks and highly decoupled operations between tasks of the same level through the above-mentioned steps of generating chain tasks for business function requests, so that general tasks have strong combinability and reusability. The configuration of general tasks can also realize dependency, exclusivity, interruption and other processing processes between tasks, and then the above-mentioned tasks are combined and connected into a whole according to the logic of the business function, and the combined and connected tasks as a whole can realize complex business function requirements.
[0077] Optionally, general tasks for generating corresponding business functions by aggregating related communication instruction tasks include:
[0078] A general task of unified diagnostic service diagnosis communication is generated by aggregating at least two of the unified diagnostic service and controller area network bus diagnosis, Ethernet network diagnosis sensor communication instruction task and communication delay control timer task.
[0079] It should be noted that a general task for a business function can be a sensor upgrade process. While this process typically involves a long chain of tasks, the chained task flow is clear and well-defined. Various tasks can be constructed based on the sensor upgrade process, ultimately allowing the entire sensor upgrade process to be serialized and chained together. By defining a unified diagnostic service, along with a Controller Area Network bus-based diagnostics task, and a timer task for post-communication delay control, the two tasks are aggregated to form a general task for diagnostic communication within the unified diagnostic service. This allows for general tasks specific to diagnostic communication within the unified diagnostic service.
[0080] Optionally, the aggregation-related communication instruction tasks may generate general tasks corresponding to business functions, including:
[0081] The general task of aggregating and generating unified diagnostic services for diagnostic communications;
[0082] Generate general tasks for the security verification process based on the sensor's authentication mask and the authentication algorithms of the sensor's application layer and driver layer.
[0083] It should be noted that the general task of aggregating and generating unified diagnostic service diagnostic communications, taking sensor upgrade as an example, is to implement the general task of the security verification process based on the authentication mask of the upgraded sensor and the authentication algorithm of the application layer and driver layer of the upgraded sensor, and aggregate and generate unified diagnostic service diagnostic communications.
[0084] Optionally, the aggregation-related communication instruction tasks may generate general tasks corresponding to business functions, including:
[0085] Aggregate and generate diagnostic communication files for unified diagnostic service diagnostic communication;
[0086] Clear the storage area information before the upgrade based on the binary file format, file size and starting address information in the diagnostic communication file transmission;
[0087] Negotiate the transmission of upgraded sensor files, control the transmission of upgraded sensor files, and verify the consistency of the transmitted upgraded sensor files.
[0088] It should be noted that the general tasks of aggregating and generating unified diagnostic service diagnostic communications also include clearing the storage content information in the storage area before the upgrade based on the binary file format, file size and starting address information in the unified diagnostic service diagnostic communication file transmission, realizing the unified diagnostic service system sensor $34 / $38 file transmission negotiation and successful negotiation, completing $36 file transmission control, and $36 file consistency verification after the transmission control is completed.
[0089] Optionally, general tasks for generating corresponding business functions also include:
[0090] Nest multiple layers of related communication instruction tasks; decouple tasks at the same level; combine and serialize decoupled tasks at the same level and communication instruction tasks based on business logic to generate chained general tasks corresponding to business functions.
[0091] It should be noted that, for example, when multiple layers of related communication instruction tasks are nested within multiple layers of related communication instruction tasks within a business function, the multiple related same-level communication instruction tasks are disassembled before nesting to decouple them. Based on the logical relationships of the same-level communication instruction tasks within the business function, the decoupled multiple related communication instruction tasks are combined and connected, so that the same-level tasks and communication instruction tasks generate a single-threaded chain of general tasks corresponding to the business function.
[0092] Optionally, general tasks for generating corresponding business functions also include:
[0093] Obtain task execution and result callback notifications, check the task execution results and related task feedback information based on the result callback notifications, and publish the next task to generate the chain process;
[0094] Chain processes that connect tasks in series, combining complex business functions, decoupled tasks at the same level, and communication instruction tasks;
[0095] Reusing the task instructions that are repeatedly executed in the chain process;
[0096] Feedback callback of the result of each task execution;
[0097] The task flow generated based on each task covers each task branch in the business process and locates abnormal task branches.
[0098] It should be noted that, under the task framework, the task execution method and the result callback notification method can be realized by checking the result of the task execution and the related task feedback information in the result callback notification process; and then continuing to publish the next task, thereby realizing the chain process of the task. The present invention forms a chain process by connecting the chains of tasks together and disassembling and combining complex business functions. In the chain process processing, repeated general task parts can be reused, such as the failure retry processing of a specific process segment. The execution of each task will have a result callback feedback, and the complex functional business can cover each task branch in the normal and abnormal situations in the business function process according to the task flow. Each business function process is very clear and clear, and there will be no omissions in the business process or the running away of the business function. At the same time, the situation points where abnormal tasks occur can be accurately located.
[0099] Optionally, determining the relationship between tasks based on task working status includes:
[0100] Process task scheduling, start task work cycle, check task status results in turn, and judge the relationship between tasks.
[0101] It should be noted that, for example, the task thread is started, task scheduling is processed, and the task work cycle is started, the task thread starts the work thread, so that the work thread enters the task thread work cycle process, such as following the task thread work cycle process to cyclically execute the check task status result, execute the instruction task queue set, execute the general task queue set, execute the top-level general task queue set, wait for the instruction task minimum time slice and wake up the task or task event, and check the status and running results of each task in the above task thread work cycle process in turn to determine the execution relationship between the above tasks.
[0102] Optionally, tasks in the task queue are executed sequentially including:
[0103] Execute the tasks in the instruction task queue sequentially;
[0104] Execute the tasks in the general task queue sequentially;
[0105] The tasks in the top-level general task queue are executed sequentially.
[0106] It should be noted that when executing, the tasks in the instruction task queue, the general task queue, and the top-level general task queue are all executed in the order from beginning to end according to the order in which each task is arranged in its respective task queue.
[0107] Optionally, encapsulating external communication interactions into command tasks includes:
[0108] Encapsulating the externally established communication interaction into a single independent instruction task;
[0109] Establishing the command task corresponding to the communication;
[0110] Aggregating the instruction tasks in an upper-level general task;
[0111] Adding the characteristics of the command task of the aggregation;
[0112] Adapt new features based on the instruction task.
[0113] It should be noted that in the task framework, the communication established between the business itself and the external modules will be encapsulated as independent instruction tasks. For the emergence of new feature requirements, only a new instruction task for the new feature communication needs to be created. The upper-level general tasks only need to add an instruction task to aggregate the new feature. On the one hand, the functional business of the existing tasks is maintained unaffected. On the other hand, the upper-level business functions remain unchanged during implementation. The adaptation of the new feature is completed by simply adding a specific instruction task that adapts to a new feature.
[0114] Optionally, the synchronous blocking request in the communication interaction is encapsulated using the newly added asynchronous adaptation feature task method, including:
[0115] The command task of the CAN bus sensor with the newly added adaptation feature is newly created based on the diagnostic protocol stack of the CAN bus and the CAN bus sensor with the newly added adaptation feature, and the command task is adapted based on the newly added feature to generate a general task of the unified diagnostic service.
[0116] It should be noted that, in an embodiment of the present invention, adaptation to the newly added Controller Area Network Bus sensor can be achieved through a diagnostic protocol stack based on the Controller Area Network Bus. A new instruction task for the newly added Controller Area Network Bus sensor is created; in the description of the newly added feature, the characteristic differences between the newly added Controller Area Network Bus sensor and other similar sensors are fed back into the instruction task. For example, mandatory intervals between Controller Area Network Bus communications, delayed processing after specific communication requests, etc., only require the addition of a corresponding Controller Area Network Bus sensor instruction task for the newly added feature, and other existing Controller Area Network Bus-based diagnostic channel communications are not affected. Within the task framework, it is not suitable to use the time-consuming synchronous blocking call form, which affects the blocking scheduling of task execution. The time-consuming synchronous communication interaction mode can be adjusted or converted to an asynchronous request-response feedback form. The task framework can then focus on the task scheduling process and perform efficient task execution.
[0117] As shown in Figure 6, taking the diagnosis of a sensor as an example, in the sensor's diagnostic request, multiple diagnostic requests generate general tasks for a unified diagnostic service, such as instruction task A, instruction task B, and instruction task C, which correspond to sensor A, sensor B, and the newly added feature sensor C, respectively. Instruction task A, instruction task B, and instruction task C all include execution instructions and instruction feedback event callbacks. Instruction task C also includes differential new feature processing. Instruction task A, instruction task B, and instruction task C correspond to the generation of general tasks for a unified diagnostic service, which includes sending unified diagnostic service instructions and sending unified diagnostic service instruction result callbacks. It can execute diagnostic requests for sensors including the newly added feature sensor C, as well as the diagnostic business functions corresponding to the above diagnostic requests.
[0118] Optionally, encapsulating synchronous blocking requests in communication interactions using the newly added asynchronous adaptation feature also includes:
[0119] Convert the synchronous communication interaction mode into an asynchronous multi-task request response feedback mode.
[0120] It should be noted that, taking sensor upgrades as an example, if blocking unified diagnostic service interface requests are used within the task framework, the compression and decompression of sensor upgrade package files, as well as upgrade package verification, are all time-consuming blocking unified diagnostic service interface requests. In this case, additional threads can be added and modified to non-blocking request-response feedback events. By adding non-blocking events, only efficient task scheduling processes run within the task framework. The asynchronous task scheduling mechanism does not generate time-consuming blocking unified diagnostic service interface requests or non-blocking request-response feedback events that could impact the execution of other tasks. For example, millisecond-level time intervals (such as 30 or 50 milliseconds) in the diagnostic protocol stack based on the Controller Area Network bus, and time-sensitive processes such as the default session with a 5-second interval for diagnostic deactivation during the sensor upgrade process, are not affected by task scheduling and can be consistent with the execution of the task framework actually established during the sensor upgrade process, ensuring real-time and efficient response performance for the task framework. As shown in Figure 7, the task scheduler schedules multiple task schedules established on the task framework, such as task scheduler A and task scheduler B. When the task scheduler schedules task scheduler A, the task framework returns a synchronous blocking call to task scheduler A; when the task scheduler schedules task scheduler B, the task framework returns a synchronous blocking call to task scheduler B. When task scheduler A is scheduling, it is easy to generate a scheduling blocked event due to the long time consumption. When the blocking synchronization is changed to an asynchronous event, the unified diagnostic service interface request of task scheduler A and task scheduler B is executed first on the task scheduler. When the task framework executes the asynchronous event feedback of A and the asynchronous event feedback of B respectively, the task scheduling process is executed as a non-blocking schedule.
[0121] Optionally, the task parallel processing method further includes:
[0122] State information combined with a task context is registered and configured, and only one instruction task in a single path is controlled to be executed based on the state information.
[0123] It should be noted that, under the task framework, different channels are created and registered according to the actual channel requirements, and then different instruction tasks are registered and configured in different channels. By registering and configuring the information of different channels and combining the task context status in each channel, it is possible to control only one instruction task to be executed in a single channel at the current moment, so as to ensure consistency with the single-channel characteristics of the actual sensor channel, and avoid the situation where the previous request is still being processed and the subsequent next request is executed, resulting in failure or no response.
[0124] Optionally, the task parallel processing method further includes:
[0125] Schedule and execute tasks in the same queue in real time;
[0126] Implement concurrent multi-tasking execution for top-level general tasks in different queues;
[0127] Implement concurrent execution of multiple identical general tasks in different queues.
[0128] It should be noted that because the task framework uses non-blocking real-time scheduling, tasks posted to the queue are scheduled for execution sequentially. This demonstrates the concurrent execution of multiple general tasks at the top of the queue. Multiple general tasks can also be configured to execute in parallel. For example, in a sensor upgrade scenario, a single path can be created for each sensor path to be upgraded, regardless of whether the upgraded sensor path is based on CAN bus diagnostics or Ethernet diagnostics. Due to the independence of the sensor upgrade paths, CAN bus-based diagnostic components and Ethernet-based diagnostic components can be updated simultaneously. For example, if there is only one overall path, all sensor components must be updated serially. For example, if four corner radars with CAN bus diagnostics, two lidars with Ethernet diagnostics, and one ultrasonic radar with CAN bus diagnostics are being updated simultaneously, each sensor in a task framework acts as an independent path. Through parallel task scheduling, all sensors can be updated simultaneously. For example, the general task *4 for upgrading the corner radar is created, registered, and configured as the corner radar instruction task path *4; the general task for upgrading the ultrasonic wave is created, registered, and configured as the ultrasonic instruction task path; the general task *2 for upgrading the laser radar is created, registered, and configured as the laser radar instruction task path *2; and the general tasks for upgrading other sensors are created, registered, and configured as other sensor instruction task paths. In this embodiment, the above-mentioned 4 corner radars based on the diagnosis of the LAN bus, 2 laser radars based on the diagnosis of the Ethernet network, and 1 ultrasonic radar sensor based on the diagnosis of the LAN bus are flashed and completed simultaneously in only about 130 seconds. In contrast, the traditional serial flashing of a single upgraded sensor is limited in that when multiple sensors cannot be upgraded in parallel, the conversion, switching, and replacement of the Ethernet-based diagnosis and the Ethernet-based diagnostic path will be limited. It takes about half an hour to complete the flashing of all the diagnostic components of these upgraded sensors, such as the corner radar, laser radar, and ultrasonic radar of the upgraded sensor (see Figure 8). Under the task framework, the present invention uses the task framework to realize parallel multi-tasking such as upgrading multiple sensors, thereby improving the efficiency of the upgrade.
[0129] Optionally, entering into a loop process of waiting for chain tasks and top-level tasks based on a preset condition of the instruction task includes:
[0130] Waiting for the chain task and the top-level task to sleep based on the minimum time slice condition preset by the instruction task;
[0131] Waiting for new task requests; or
[0132] Initiate task work and respond to feedback; or
[0133] In the event of a timer expiration, the task is reactivated and executed.
[0134] It's important to note that after queued tasks are sequentially checked and executed, they wait for new requests or responses based on the minimum timeout preset in the task. If a timer expires, the task is reactivated and executed. This cyclical process allows the task worker thread to achieve automated, streamlined, and efficient processing of business tasks while minimizing workload.
[0135] Optionally, the step of entering into a loop of waiting chain tasks and top-level tasks based on a preset condition of the instruction task further includes:
[0136] After periodically checking and executing the tasks in the queue in sequence, they are processed based on the minimum timer in the instruction task, waiting for new requests and reply feedback; or in the event of a timer timeout, the task work is reactivated and executed.
[0137] It should be noted that, for example, in the task framework, the task thread is periodic. During the implementation of the upgrade process and the offline calibration process, the upgrade processes of various sensors are not exactly the same, and periodic loop processing is performed during the execution of the task thread.
[0138] Optionally, the task parallel processing method further includes:
[0139] In the general task of unified diagnostic service communication of package diagnostics,
[0140] Obtain the file information of the newly added asynchronous adaptation feature configuration of the communication unified diagnosis service, construct a corresponding general task based on the configured file information; and automatically execute the general task.
[0141] It should be noted that since the implementation of the sensor upgrade and offline calibration processes include several columns of diagnostic unified diagnostic service communications, the general tasks of the diagnostic unified diagnostic service communications are encapsulated, and the communication unified diagnostic services during the implementation of the upgrade process and the offline calibration process are described or defined through configuration files. The corresponding general tasks constructed after reading the unified diagnostic service communications in the configuration file are executed through automated tasks under the task framework.
[0142] Optionally, the task parallel processing method further includes:
[0143] Modifying the file information of the corresponding newly added asynchronous adaptation feature configuration based on the communication unified diagnostic service;
[0144] Dynamically adjusting and optimizing the general tasks corresponding to the communication unified diagnostic service business process based on the configured file information; Automatically executing the general tasks.
[0145] It should be noted that during the implementation of the sensor upgrade and the offline calibration process, both include several columns of communication unified diagnostic service communication. Encapsulating the general tasks of the communication unified diagnostic service communication, describing or defining the communication unified diagnostic service and the corresponding newly added features during the implementation of the upgrade process and the offline calibration process through a configuration file, and constructing the corresponding general tasks after reading the communication unified diagnostic service communication of the configuration file. Through the automated task execution under the task framework, the automated implementation of the sensor upgrade process and the offline calibration process is realized, and the content information of the development part under the task framework does not need to be changed. Only by modifying the configuration files of the sensor upgrade process and the offline calibration process can the sensor upgrade business process be dynamically adjusted and optimized. As shown in Figure 9, upgrade process / production line offline process; Parse the process configuration file; Create and execute the general tasks for each node case in sequence according to the process configuration; Generate the general tasks of the unified diagnostic service; In the communication subtask, perform task scheduling based on the diagnosis of the unified diagnostic service and the controller area network bus, the diagnostic sensor communication instruction task of the Ethernet network, and the timer task for post-communication delay control, generate the general tasks of the unified diagnostic service diagnostic communication, as well as the diagnostic communication file of the unified diagnostic service general task and the unified diagnostic service diagnostic communication, and the corresponding diagnostic instruction task. In the diagnostic communication process, generate and execute the chained tasks of the service function request of the diagnostic instruction task, and realize the parallel processing of the sensor upgrade task based on the single-thread asynchronous multi-task framework. Among them, the process of parsing the process configuration file includes:
[0146] ……
[0147] <Node case>
[0148] <Process progress>0< / Process progress>
[0149] <Request type>Transmit data< / Request type>
[0150] <Process single step>Request programming session< / Process single step>
[0151] <Addressing type>Physical addressing< / Addressing type>
[0152] <Request data>10 02< / Request data>
[0153] <Request data length>2< / Request data length>
[0154] <Reply data>50 02< / Reply data>
[0155] <Reply data length>6< / Reply data length>
[0156] <Waiting time>500< / Waiting time>
[0157] <Delay time>1000< / Delay time>
[0158] < / Node case>
[0159] ……
[0160] The present invention also provides a task parallel processing system based on a single-thread asynchronous multi-task framework. As shown in FIG. 10, the task parallel processing system 200 includes:
[0161] An instruction task module 210, configured to encapsulate communication interactions with the external into instruction tasks under a multi-task framework, and encapsulate synchronous blocking requests in communication interactions in a new asynchronous adaptation feature task manner; register the instruction tasks into corresponding paths of different tasks based on the interaction requests of the instruction tasks;
[0162] An aggregation task module 220, configured to generate general tasks and chained tasks of service function requests based on the related instruction tasks; aggregate general tasks of unified diagnostic service communication, authentication verification general tasks, and file transfer and writing general tasks; perform pre-processing, security verification, file writing, progress inspection, consistency verification, and exception retry and rollback service functions of the upgrade process based on the chained task process; reuse common service functions in different sensors;
[0163] A task scheduling module 230, configured to judge the relationship between tasks based on the task working status; sequentially execute tasks in the task queue; enter a loop process of waiting for chained tasks and top-level tasks based on the preset conditions of the instruction tasks;
[0164] Among them, the general tasks include upper-layer general tasks and top-level general tasks.
[0165] It should be noted that when the instruction task module 210, task scheduling module 230, and task scheduling module 230 included in the task parallel processing system 200 run, they execute the task parallel processing method based on the single-thread asynchronous multi-task framework as described above, which will not be elaborated here.
[0166] Optionally, the task parallel processing system 200 further includes:
[0167] The task configuration module 240 is used to register and configure state information combined with the task context, and control only one instruction task in a single path to be executed based on the state information.
[0168] It should be noted that when the task configuration module 240 runs with the above-mentioned task parallel processing system 200, it executes the task parallel processing method based on the single-threaded asynchronous multi-tasking framework as described above. The specific running method can be found in the description of the method above and will not be repeated here.
[0169] Optionally, the task parallel processing system 200 further includes:
[0170] The task thread module 250 is used to schedule and execute tasks in the same queue in real time.
[0171] Implement concurrent multi-tasking execution for top-level general tasks in different queues;
[0172] Implement concurrent execution of multiple identical general tasks in different queues.
[0173] It should be noted that when the task thread module 250 runs with the above-mentioned task parallel processing system 200, it executes the task parallel processing method based on the single-threaded asynchronous multi-tasking framework as described above. The specific running method can be found in the description of the method above and will not be repeated here.
[0174] As shown in FIG11 , the present invention further provides an electronic device, the electronic device 400 including:
[0175] Memory 410 for storing non-transitory computer-readable instructions 430; and
[0176] The processor 420 is configured to run the computer-readable instructions 430 , so that when the computer-readable instructions 430 are executed by the processor 420 , the task parallel processing method based on the single-threaded asynchronous multi-tasking framework is implemented.
[0177] The present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the above-mentioned task parallel processing method based on the single-threaded asynchronous multi-tasking framework.
[0178] As shown in Figure 12, the structure of a single-threaded asynchronous multi-tasking framework provided in another embodiment of the present invention includes a task base class module for processing various business function messages, a task scheduling module for managing task execution processes, a task context tracking module for tracking task status, a task configuration module for configuring task registration, and a task thread module for concurrent task execution threads. Tasks, as the core processing unit within the task framework, primarily include task base classes, single-step tasks, timer tasks, instruction tasks, general tasks, and task events. Task base classes and single-step tasks are both task base classes and do not directly participate in task scheduling. The task base class, a general base class for tasks, serves as a base class for inheritance and is generally not used directly, integrating common processing for a range of tasks. Members of the base task class include a task type, a task identifier, a top-level task identifier, a task processing callback, and a task result. The task type and identifier uniquely identify the task, while the top-level task identifier determines whether the top-level general task was created in response to a business request. The task result and task callback together notify the task caller of the result and task information. The task call process includes publishing the task, executing the task, and the task callback, as well as the time limit for the task response.
[0179] The single-step task includes the single-step task base class, which inherits from the task base class. It is not used directly but needs to be inherited. It integrates a series of general processing except the task base class. In addition to inheriting members from the base class, the members include the task identifier of the single-step task and the timeout event identifier for scheduling the single-step task; the single-step task execution process includes the result and information callback feedback of the single-step task, single-step task execution, single-step task result callback, single-step task interrupt callback and single-step task timer management, which can realize the special setting requirements of task time through timers and timeout events.
[0180] Timer tasks include the Timer Task base class, which inherits from the Single-Step Task class and is primarily used for delay processing during task execution, such as the interval between multiple tasks and the mandatory wait time after task execution. In addition to members inherited from the base class, its members include the timer task's timeout period. The timer task execution process includes timer task execution, timer task timeout callback, and timer task interrupt callback.
[0181] Command tasks include the Command Task base class, which inherits from the Single-Step Task and primarily handles end-to-end interface communication interactions. As the smallest task unit processed within the task system, a Command Task only handles single-step interaction feedback. Subtasks cannot be created within a Command Task as subtasks. Command Tasks do not directly represent external business requests; they serve only as subtasks of general tasks to implement corresponding business functions. In addition to members inherited from the base class, its members include the Command Task ID and the Command Task Status. The Command Task execution process includes timer task execution, callback notification for command task waiting for feedback timeout, and callback notification for command task interruption and cancellation.
[0182] General tasks include a general task base class, which inherits from the task base class. It mainly brings together various instruction tasks, timer tasks, and general tasks. It realizes complex business functions by controlling the chain process and task connection between tasks. The subtasks such as single-step tasks, timer tasks, and general tasks created in general tasks have the parent task of the above subtasks as the general task of the creator. Among them, the top-level general task is a special general task, that is, the top-level task has no parent task and will be set as the top-level task identifier. The top-level general task is mostly a business request directly triggered by the outside to realize a complex and / or large business function, usually including multiple general tasks, instruction tasks, and timer tasks. In addition to the members inherited from the base class, the general task execution process includes general task execution and general task callback.
[0183] Task events include the Task Event base class, which can represent normal, abnormal, interrupted, or timeout feedback during external communication interactions within a command task, a timer timeout event within a timer task, or an external request or status event associated with a command task. As a base class, Task Events integrates common event attributes and execution processes. Its members include the event type, event identifier, event parameters, and accompanying data. The Task Event execution process involves obtaining each member of a Task Event, using the Task Event to drive task execution, and then continuing the execution of the Command Task and Timer Task based on matching Task Events, achieving streamlined and automated task execution.
[0184] The Task Scheduling class is also the central management class for task processing, handling the sequential scheduling of task flows. Members of this class include the task thread, task configuration, and task context. Scheduled tasks are executed within the thread based on the task configuration and context state information. The Task Scheduling class primarily handles the following business functions: initializing, starting, stopping, parsing, and building the task framework itself; processing and callback notifications for tasks entering the cache queue; transferring tasks from the cache queue to the execution queue during execution, and pre-task execution callback notifications; releasing tasks from the queue upon completion, releasing and recycling task resources, and receiving callback notifications for execution results; and handling interrupted tasks and callback notifications for interrupted results.
[0185] The Task Context Tracking class, which tracks task status, is primarily used to process status information during task execution and to determine or track status information within task execution conditions. Members of the Task Context Tracking class include a set of tracked instruction task status contexts and a set of general task status contexts. These classes are primarily used to determine: whether the pending task has been registered; whether the execution channel for the instruction task has been registered; whether the configured execution conditions for the task are currently met; task execution status management; context information about the parent and child tasks associated with the task; and context information associated with general and single-step tasks.
[0186] The task configuration class, which manages task registration configuration, primarily manages task configuration registration information to implement configurable and registered task execution. This class also includes a set of registered instruction task paths, a set of registered instruction tasks, and a set of registered general tasks. It primarily covers the following business operations: registering general tasks, instruction tasks, and timer tasks; registering instruction task execution paths; registering general task execution conditions; registering and configuring the number of concurrent execution queues for general tasks, and the rules for handling excess execution queues.
[0187] The task thread class of the concurrent task execution thread is the carrier for task scheduling to implement concurrent task execution, enabling tasks to be executed in a relatively isolated environment according to the configured automated process. The members of this task thread class include a set of pending instruction tasks, a set of pending timer tasks, a set of pending general tasks, and a set of executing general tasks; the methods include thread operation management, publishing of general tasks / instruction tasks / timer tasks / task events, processing of general tasks / instruction tasks / timer tasks / task events, and scheduling management of task timers. It is mainly used for the following business content: looping through tasks in the queue for execution, scheduling tasks according to timers and events; processing instruction task sets; processing general task sets; converting task events into top-level general tasks for execution; scheduling thread execution for task events; and scheduling thread execution for timer tasks.
[0188] It should be noted that any process or method description in the flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and that the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may be performed in a different order than shown or discussed, including performing functions in a substantially simultaneous manner or in a reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention pertain.
[0189] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection having one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing it in a suitable manner if necessary, and then storing it in a computer memory.
[0190] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement the hardware: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0191] Those skilled in the art will understand that all or part of the steps included in the method for implementing the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0192] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing module, each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be partially implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.
[0193] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and are not to be construed as limiting the present invention. Persons skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
[0194] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Any technician familiar with the present profession can make some changes or modifications to equivalent embodiments using the technical content disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. Task parallel processing method based on single-threaded asynchronous multi-tasking framework, It is characterized in that The method comprises: In the multi-task framework, the communication interaction with the outside is encapsulated as a command task, and the synchronous blocking request in the communication interaction is encapsulated in the newly added asynchronous adaptation feature task mode; based on the interaction request of the command task, the command task is registered in the path corresponding to different tasks; Generate general tasks and chain tasks for business function requests based on the relevant command tasks; aggregate unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and flashing general tasks; perform pre-processing, security verification, file flashing, progress check, consistency check and abnormal retry and rollback business functions of the upgrade process based on the chain task process; reuse common business functions in different sensors; Determine the relationship between tasks based on the task working status; execute the tasks in the task queue in sequence; enter the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction task; The general tasks include upper-level general tasks and top-level general tasks.
2. The method according to claim 1, It is characterized in that The general tasks of generating a business function request based on the related instruction tasks include: Aggregate related communication instruction tasks to generate general tasks corresponding to business functions; Aggregating the general tasks of the business logic and the instruction tasks to generate a top-level general task that responds to the business request; Generate chained tasks for business function requests.
3. The method according to claim 2, in, The general tasks for generating corresponding business functions by aggregation-related communication instruction tasks include: A general task of unified diagnostic service diagnosis communication is generated based on at least two of the unified diagnostic service and controller area network bus diagnosis, Ethernet network diagnosis sensor communication instruction task and communication delay control timer task.
4. The method according to claim 2, in, The general tasks of generating corresponding business functions by aggregation-related communication instruction tasks also include: General tasks of aggregating and generating unified diagnostic services for diagnostic communications; Generate general tasks for the security verification process based on the sensor's authentication mask and the authentication algorithms of the sensor's application layer and driver layer.
5. The method according to claim 2, in, The general tasks of generating corresponding business functions by aggregation-related communication instruction tasks also include: Aggregate and generate diagnostic communication files for unified diagnostic service diagnostic communication; Clear the storage area information before the upgrade based on the binary file format, file size and start address information in the diagnostic communication file transmission; Negotiate the transmission of the upgraded sensor file, control the transmission of the upgraded sensor file, and verify the consistency of the transmitted upgraded sensor file.
6. The method according to claim 2, in, Also includes: Get task execution and result callback notifications, check the task execution results and related task feedback information based on the result callback notifications, and publish the next task to generate the chain process of tasks; Chain processes that connect tasks in series, combining complex business functions to decouple tasks at the same level and communication instruction tasks; Reusing the task instructions that are repeatedly executed in the chain process; Feedback the result callback of each task execution; The task flow generated based on each task covers each task branch in the business process and locates abnormal task branches.
7. The method according to claim 1, in, Judging the relationship between tasks based on task work status includes: Process task scheduling, start task work cycle, check task status results in turn, and determine the relationship between tasks.
8. The method according to claim 1, in, Encapsulating external communication interactions into command tasks includes: Encapsulating the externally established communication interaction into a single independent command task; Establishing the command task corresponding to the communication; Aggregating the instruction tasks in an upper-level general task; Adding the characteristics of the command task of the aggregation; New features are added based on the instruction task adaptation.
9. The method according to claim 1, in, The synchronous blocking request in the communication interaction is encapsulated in the new asynchronous adaptation feature task mode, including: Based on the diagnostic protocol stack of the CAN bus and the CAN bus sensor with the newly added adaptation features, the command task of the CAN bus sensor with the newly added adaptation features is newly created; based on the newly added features, the command task is adapted and a general task of unified diagnostic service is generated.
10. The method according to claim 1, further comprising: include: Schedule and execute tasks in the same queue in real time; Implement concurrent multi-tasking execution for top-level general tasks in different queues; Implement concurrent execution of multiple identical general tasks in different queues.
11. The method according to claim 1, further comprising: include: After periodically checking and executing the tasks in the queue in sequence, they are processed based on the minimum timer in the instruction task, waiting for new requests and reply feedback; or in the event of a timer timeout, the task work is reactivated and executed.
12. The method according to claim 1, further comprising: include: In the general task of unified diagnostic service communication of package diagnostics, Obtain the file information of the newly added asynchronous adaptation feature configuration of the communication unified diagnosis service, build the corresponding general task based on the configured file information; and automatically execute the general task.
13. The method according to claim 12, further comprising: include: Modify the file information of the newly added asynchronous adaptation feature configuration based on the unified communication diagnostic service; Dynamically adjust and optimize general tasks corresponding to the communication unified diagnostic service business process based on the configured file information; The general tasks described are performed automatically. 14.Task parallel processing system based on single-threaded asynchronous multi-tasking framework, It is characterized in that The system comprises: The instruction task module is used to encapsulate the communication interaction with the outside into an instruction task under the multi-task framework, encapsulate the synchronous blocking request in the communication interaction using the newly added asynchronous adaptation feature task mode, and register the instruction task to the path corresponding to different tasks based on the interaction request of the instruction task; Aggregation task module, used to generate general tasks and chain tasks of business function requests based on the related instruction tasks, aggregate unified diagnostic service communication general tasks, authentication verification general tasks and file transfer and writing general tasks, and perform pre-processing, security verification, file writing, progress check, consistency check and abnormal retry and rollback business functions of the upgrade process based on the chain task process, and reuse the common business functions in different sensors; The task scheduling module is used to determine the relationship between the tasks based on the task working status; sequentially execute the tasks in the task queue and enter the loop processing of waiting chain tasks and top-level tasks based on the preset conditions of the instruction tasks; The general tasks include upper-level general tasks and top-level general tasks.
15. The task parallel processing system according to claim 14, further comprising: include: The task thread module is used to schedule and execute tasks in the same queue in real time, implement simultaneous multi-task concurrent execution for top-level general tasks in different queues, and implement simultaneous concurrent execution for multiple identical general tasks in different queues.
Citation Information
Patent Citations
Method for increasing multi-tasking efficiency through thread management
CN102455933A
Multi-node task asynchronous cooperative processing method
CN111309458A
Task parallel processing method and system based on single-thread asynchronous multi-task framework
CN116594743A
System for performing asynchronous file operations requested by runnable threads by processing completion messages with different queue thread and checking for completion by runnable threads
US5758184A
Cited By
Asynchronous execution method and system for ATE test machine
CN120847597A
Batch packaging method for digital objects in digital network
CN121567734A
Asynchronous exporting method and system
CN121636177A
Buried information and warning screen control method, system, device and equipment based on radar waveform state recognition
CN122245232A
