A parallel execution method and system based on task-level isolation
By establishing task execution association records and independent communication channels in the task-level isolation system, and determining the task end boundary based on the task completion event, the problem of inconsistency between task message processing status and resource release is solved, thus achieving task message integrity and accurate resource reclamation.
Patent Information
- Application Number
- CN202611592959.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-15
- Publication Date
- 2026-11-17
AI Technical Summary
In existing task-level isolated execution systems, the task message processing status cannot be accurately determined when a running process exits, leading to improper timing of resource release and potentially resulting in the loss of tail task messages or the inability to guarantee the integrity of results.
By establishing task execution association records, creating independent running processes and task-level communication channels, forming task message reception records, and determining the task end type based on task completion and exit events, generating task message end boundary sequence numbers, it is ensured that resource reclamation is performed only after task message processing is completed.
It improves the operational isolation during task execution, reduces mutual interference between tasks, ensures that resources are reclaimed only after task message processing is completed, and avoids issues such as missing task messages and incomplete results.
Smart Images

Figure CN123114705A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a parallel execution method and system based on task-level isolation. Background Technology
[0002] As computer systems evolve towards multi-task parallel execution and resource isolation, task-level isolated execution technology is widely used in software runtime environments, computing task scheduling, automated execution platforms, and service-oriented systems. Existing task-level isolated execution systems typically deploy different top-level tasks in independent running processes. Process isolation reduces the impact between tasks, and the control layer's main control module is responsible for task creation, runtime status monitoring, communication management, and resource release. During task execution, the independent running processes continuously transmit log information, collection results, download results, and task running status back to the control layer via communication channels. The control layer then records, archives results, and maintains task status based on the received task messages. Therefore, the task-level isolated execution process involves not only the creation and management of independent running processes but also message transmission, result processing, and task lifecycle control during task execution.
[0003] For example, invention patent CN112306685B discloses a task isolation method, apparatus, electronic device, and computer-readable medium, relating to the field of information processing technology. The task isolation method includes: receiving a task processing request sent by a management server, the task processing request including a target isolation environment identifier and a target task; allocating the target task to multiple task isolation environments corresponding to the target isolation environment identifier, so as to execute the target task in the target task isolation environment, wherein each task isolation environment corresponds to a preset account, and the data between any two preset accounts is mutually isolated. The technical solution provided by this disclosure ensures that the executed target task does not interfere with tasks in other task isolation environments, eliminates environmental conflicts caused by multiple tasks running in parallel within a single task environment, enables rapid task execution in the target task isolation environment, and allows different task isolation environments to run tasks independently, thus improving task execution efficiency.
[0004] For example, the invention patent with publication number CN113868636A provides a method and apparatus for isolating the kernel and tasks. By adding a separate trusted base to the computer system, the trusted base is independent of the kernel and tasks. The trusted base, tasks, and kernel each have independent memory, and tasks and kernel cannot access each other's memory. When task scheduling is required, the trusted base configures the memory protection device according to the memory switching configuration information stored in the trusted base's memory. By configuring the memory protection device, the memory access boundary can be switched from the kernel's memory to the task's memory, or vice versa. By switching the memory boundary, access to the memory of both tasks and kernel can be achieved, thereby ensuring the security of tasks and kernel.
[0005] However, existing task-level isolated execution systems typically determine the end of task execution based on the exit event of an independent running process, and directly delete the task process association, close the communication connection, and release task execution resources upon detecting the exit of the running process. However, the running process exit event can only indicate that the life cycle of an independent running process has ended, and cannot indicate whether the task messages generated and entered into the communication channel before the running process exits have been transmitted or whether the corresponding upper-layer processing at the control layer has been completed. In cases where data collection results, log information, or other task result messages are generated in a concentrated manner during the task execution end phase, or when there are queuing transmissions or asynchronous processing delays in the communication channel, there may be a time difference between the time of running process exit and the time of task message completion, resulting in some valid task messages still being transmitted or processed. If task communication and execution resources are released immediately based on the running process exit event, unprocessed task messages may not be able to continue to be archived or updated in status; while using a fixed waiting time to delay resource release is difficult to adapt to different task message quantities, communication loads, and processing time variations, easily leading to a mismatch between the timing of resource release and the completeness of task results.
[0006] Therefore, in order to address the above problems, there is an urgent need for a parallel execution method and system based on task-level isolation. Summary of the Invention
[0007] This application provides a parallel execution method and system based on task-level isolation, which solves the problem that the exit status of the running process and the actual message processing status of the task message cannot be correlated, which leads to the inability to accurately determine the timing of resource release after the task is completed, resulting in the loss of tail task messages and the inability to guarantee the integrity of task results.
[0008] This application provides a parallel execution method based on task-level isolation, comprising: S1, establishing a task execution association record based on a task identifier, creating an independent running process and a task-level communication channel; S2, forming a task message receiving record based on task messages and the task execution association record, performing task message processing, forming a task message processing confirmation record, and determining the processed confirmation sequence number; S3, determining the task end type based on a task completion event, a task stop completion event, and a running process exit event; S4, determining the task message end boundary based on the task execution end flag or communication channel termination event corresponding to the task end type, generating a task message end boundary sequence number, and updating the task message end boundary state; S5, determining the task recycling state as an allowed recycling state or a waiting recycling state based on the task message end boundary state, the task message end boundary sequence number, and the processed confirmation sequence number; and S6, forming a task exit recycling record based on the task execution state and task recycling state in the task execution association record and performing exit recycling processing.
[0009] Another embodiment of this application provides a parallel execution system based on task-level isolation, including: a task execution establishment module, used to establish a task execution association record based on a task identifier, create an independent running process and a task-level communication channel; a task message processing module, used to form a task message receiving record based on task messages and task execution association records, perform task message processing, form a task message processing confirmation record and determine the processed confirmation sequence number; a task end determination module, used to determine the task end type based on a task completion event, a task stop completion event and a running process exit event; a message boundary determination module, used to perform task message end boundary determination based on a task execution end flag or a communication channel termination event corresponding to the task end type, generate a task message end boundary sequence number and update the task message end boundary state; a task recycling judgment module, used to determine the task recycling state as an allowed recycling state or a waiting recycling state based on the task message end boundary state, the task message end boundary sequence number and the processed confirmation sequence number; and a task exit recycling module, used to form a task exit recycling record and perform exit recycling processing based on the task execution state and task recycling state in the task execution association record.
[0010] The beneficial effects achieved by the technical solutions provided in this application include at least the following:
[0011] (1) This scheme establishes independent running processes, task-level communication channels and task running association records for each task, thereby isolating the execution process, message transmission process and resource recycling process of different tasks, thereby reducing the possibility of mutual influence between different tasks due to changes in running status, message transmission or resource release, and improving the running isolation during the execution of parallel tasks.
[0012] (2) According to the task completion type, the task execution completion marker or communication channel termination event is used to determine the task message end boundary number, so that the message processing range after the task ends can be determined by the actual task message transmission process, rather than directly ending the message processing based solely on the running process exit event. This reduces the risk of task message omission when the running process has exited but the tail task message is still in the submission, transmission or reception process.
[0013] (3) In this scheme, the task recycling status is determined by comparing the task message end boundary number with the processed confirmation number. The task recycling status is only allowed after the task message end boundary has been established and the task messages within the boundary range have been processed. This establishes a correspondence between task resource recycling and the actual processing progress of task messages, avoiding premature closure of task-level communication channels or release of receiving side running resources due to the completion of task execution.
[0014] (4) In this scheme, when the task ends but the exit and recycling conditions are not yet met, the task operation association record, task-level communication channel, task message receiving record, task message processing confirmation record and receiving side operation resources are retained. The exit and recycling process is then uniformly executed after the exit and recycling conditions are met, so that the task execution end status, task message processing completion status and resource recycling status can be connected in a determined order, thereby improving the consistency between the task end result and the actual message processing result.
[0015] It should be understood that the content described in this section is not intended to identify key or important features of the embodiments of this application, nor is it intended to limit the scope of this application. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a parallel execution method based on task-level isolation;
[0018] Figure 2 It is a parallel execution system architecture diagram based on task-level isolation;
[0019] Figure 3 This is a diagram illustrating the sequential progression of processed and confirmed sequence numbers;
[0020] Figure 4 This is a diagram illustrating the relationship between task message reception records and task message processing confirmation records. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0022] Please see Figures 1-4 This invention provides a technical solution: a parallel execution method based on task-level isolation, such as... Figure 1 As shown, the process includes the following steps: S1, establishing a task execution association record based on the task identifier, creating an independent running process and a task-level communication channel; S2, forming a task message receiving record based on the task message and the task execution association record, performing task message processing, forming a task message processing confirmation record, and determining the processed confirmation sequence number; S3, determining the task end type based on the task completion event, the task stop completion event, and the running process exit event; S4, determining the task message end boundary based on the task execution end flag or communication channel termination event corresponding to the task end type, generating a task message end boundary sequence number, and updating the task message end boundary status; S5, determining the task recycling status as an allowed recycling status or a waiting recycling status based on the task message end boundary status, the task message end boundary sequence number, and the processed confirmation sequence number; S6, forming a task exit recycling record based on the task execution status and task recycling status in the task execution association record and performing exit recycling processing.
[0023] Specifically, establishing task execution association records based on task identifiers and creating independent running processes and task-level communication channels includes: After receiving a task start request, the main control module queries the task execution association record based on the task identifier in the task start request; whereby the main control module refers to the task lifecycle management logic deployed in the task execution system control layer and located outside the independent running process, used to manage task start, maintenance of task execution association records, and resource retention and release after task execution; the task start request includes at least a task identifier, task configuration, execution content, and running parameters; the main control module generates a task start message based on the task configuration, execution content, and running parameters in the task start request, and associates the task identifier with the task start message, so that the task start message corresponds to the current task execution association record; the same task identifier corresponds to only one task execution instance, and a new task execution association record is allowed to be established based on the same task identifier only after the previous task execution instance has completed the exit and recycling process and deleted the task execution association record; different task execution instances regenerate corresponding task message sequence numbers, and the task-level communication receiving side identifies the task message ownership based on the current task execution association record, and does not process historical task messages that do not have a corresponding task execution association record.
[0024] When there is no task execution association record corresponding to the task identifier, or when there is a task execution association record corresponding to the task identifier but the task execution status is not the task running status and the task recycling status is not the waiting recycling status, an independent running process corresponding to the current task is created, and a corresponding task-level communication channel is established. For this task execution, an association relationship is established based on the task identifier associated running process association information, task-level communication channel association information, task execution status, task recycling status, task end type, task end time, task recycling completion time, task message end boundary status, task message end boundary sequence number, and processed confirmation sequence number to form a task execution association record; otherwise, no new independent running process is created. Among them, the task execution status is set to two values: task running status and task end status, which are used to represent the current task execution life cycle status determined by the main control module based on the life cycle of the independent running process; the task execution status is not directly modified by the task status message sent by the independent running process; the task recycling status is set to three values: not entered recycling status, waiting recycling status, and allowed recycling status, which are used to indicate whether the communication resources, message processing resources, and running resources corresponding to the current task meet the release conditions.
[0025] A task-level communication channel refers to the task-related communication connection established for the current top-level task. This includes a control communication connection between the main control module and the independent running process for transmitting task start messages, and a data communication connection between the independent running process and the task-level communication receiver for transmitting task messages. The independent running process corresponding to the current top-level task acts as the task message generator and the sender of the task-level communication channel. The message writer of the task-level communication channel is managed by the current independent running process. The task-level communication channel is established by the main control module, and the closing timing is determined based on the task recycling status. After the independent running process exits, the communication endpoint and message processing status corresponding to the task-level communication receiver remain unchanged until the task resource release conditions are met. By establishing a task-level communication channel independently for each top-level task, task messages can be isolated and managed based on task identifiers, preventing tail-end task messages from being unable to continue processing due to premature release of receiver resources after the independent running process exits. When an independent running process exits, there is no longer an execution entity capable of writing new task messages to the task-level communication channel corresponding to the current task.
[0026] For the same task identifier, the querying, creation determination, and establishment process of task execution association records are treated as atomic task startup processes that cannot be executed simultaneously by other task startup requests corresponding to the same task identifier. When the task recycling status is in the allowed recycling state but the exit recycling process has not yet been completed, the current task execution association record is maintained, and the creation of new task execution association records based on the same task identifier is not allowed; only after the current task has completed the exit recycling process and deleted the task execution association record is a new task startup request allowed to re-establish the corresponding task execution association record.
[0027] When establishing a task execution association record, the task execution status is set to "task running," the task completion type is set to "undetermined," the task message completion boundary status is set to "not established," the task recycling status is set to "not entered recycling," and the processed confirmation number is set to its initial value. The processed confirmation number represents the largest task message number in the current task that has continuously completed upper-level processing in ascending order of task message number. The processed confirmation number is recorded according to the task message numbering rule and initialized to 0 when the task starts. If any intermediate task message has not formed a task message processing confirmation record with a completed status, the advancement of the processed confirmation number stops, and the processed confirmation number is not updated across unfinished task messages.
[0028] After creating an independent running process and establishing a task-level communication channel, the task-level communication channel sends a task start message. The independent running process then establishes a task execution service based on the task start message and executes the current task. If the task start message fails to be sent to the independent running process, the main control module releases the task-level communication channel established for this task and deletes the task execution association records that have not yet entered the execution phase. Specifically, the task start message is sent from the main control module to the independent running process, and the task message is sent from the independent running process to the task-level communication receiving side. The task execution service refers to the task execution logic deployed within the independent running process that executes the current top-level task based on the task start message and generates task messages, task completion events, or task stop completion events.
[0029] In this implementation scheme, a task execution association record is established based on the task identifier, and the running process association information and task-level communication channel association information are bound to the current task execution instance. This enables the main control module to manage the lifecycle status, message processing status, and resource release status of a task execution process based on the task execution association record. By limiting the same task identifier to correspond to one task execution instance, confusion between task message sequence numbers, task message receiving records, and task message processing confirmation records between different task execution instances is avoided, providing a unique association basis for subsequent task message processing and exit recycling.
[0030] Specifically, the task message receiving record is formed based on the task message and the task execution association record. This includes the task message sequence number, task message receiving record and task message processing confirmation record corresponding to the same task. All of these are associated with the corresponding task execution association record, so that the task message maintains a unique correspondence during the task execution process. During the execution of the current task by an independently running process, the generated log information, collection results, download results, or task running status messages are treated as task messages. A task message sequence number is generated according to the order in which the task messages corresponding to the current task are generated. This sequence number is then associated with the corresponding task message and sent to the task-level communication receiving side via the task-level communication channel corresponding to the current task. The task message consists of log information, collection results, download results, or task running status messages generated by the independently running process during the execution of the top-level task and transmitted back via the task-level communication channel. The task message sequence number identifies the order of task messages generated during the execution of the same task. The task message sequence number is generated by the independently running process for the task messages generated during the execution of the current task, according to the order in which the task messages are generated, and is incremented starting from 1. The task-level communication receiving side identifies the receiving order of task messages corresponding to the same task based on the task message sequence number and establishes task message receiving records and task message processing confirmation records based on the task message sequence number.
[0031] The sequence number of the task message in the same task execution instance is uniformly assigned by the current task and is continuously incremented from the initial task message sequence number according to the order in which the task messages are generated. Once the task message sequence number is assigned, it will not be reassigned due to changes in the submission, transmission or processing status of the task message. The corresponding task message sequence number is retained for task messages that are not successfully submitted, and the task message sequence number is not skipped.
[0032] The task-level communication receiving side determines the current task to which the task message belongs based on the task execution association record, sets the message processing status to pending, and forms a task message reception record based on the task identifier, task message sequence number, task message type, task message content, and message processing status. Then, it sends the task message to the corresponding upper-layer processing module based on the task message reception record. The task message reception record records the task message association information received by the task-level communication receiving side and saves the message data or message data references required for task message processing. Once a task message enters the task-level communication receiving side, its lifecycle is independent of the independent running process that generated it. The task-level communication receiving side refers to the communication processing logic deployed outside the independent running process, used to receive task messages sent by the independent running process. The upper-layer processing module refers to the processing logic deployed outside the independent running process, used for writing task message execution logs, saving collection results, registering download results, or updating task status. The task-level communication receiving side and the upper-layer processing module do not depend on the running status of the independent running process. Even after the independent running process exits, they can still perform subsequent processing based on the task message that has entered the task-level communication channel and form a task message processing confirmation record.
[0033] In this implementation scheme, by setting task execution status and task recycling status, the main control module can record the current task execution lifecycle and resource release condition status respectively. The task execution status is used to distinguish whether the independent running process is still in the task execution stage, and the task recycling status is used to indicate whether the task-level communication channel, task message reception record, task message processing confirmation record, and receiving side running resources meet the release conditions, thereby avoiding directly executing resource release based solely on the end event of the independent running process.
[0034] Specifically, the process of executing task message processing, forming a task message processing confirmation record, and determining the processed confirmation sequence number includes: Executing task message processing based on the task message receiving record: The upper-level processing module executes upper-level processing for the corresponding task message type: When log information is written, collection results are saved, download results are registered, and task status messages are updated according to the task running status record, the upper-level processing is confirmed as successful, the message processing status is set to the processing completed state, and the task-level communication receiving side associates the task identifier, task message sequence number, and message processing status to form a task message processing confirmation record; otherwise, the message processing status is set to the processing failed state, and the task recycling status and task execution status are not updated; no task message processing confirmation record with a processing completed state is generated, and the processed confirmation sequence number does not continue to be updated across this task message; Subsequently, the corresponding task message processing is re-executed based on the task message processing result. When the upper-level processing is successful, a corresponding task message processing confirmation record is generated, and the processed confirmation sequence number is updated in ascending order according to the task message sequence number.
[0035] like Figure 4 As shown, the task-level communication receiving side determines the corresponding task message based on the task identifier and task message sequence number in the task message reception record, and sends the task message to the corresponding upper-layer processing module according to the task message type. Specifically, the upper-layer processing module writes log information, saves collection results, registers download results, and updates task status records. Upon successful processing of the corresponding task message, the task-level communication receiving side generates a task message processing confirmation record based on the task identifier, task message sequence number, and message processing status.
[0036] When the task-level communication receiving side receives duplicate processing confirmation results corresponding to the same task identifier and the same task message sequence number, it does not generate a duplicate task message processing confirmation record, but maintains the status of the existing task message processing confirmation record.
[0037] like Figure 3As shown, the task-level communication receiving side updates the processed confirmation sequence number based on the formed task message processing confirmation record: For each new task message processing confirmation record formed, starting from the next task message sequence number after the current processed confirmation sequence number, the message processing status of the corresponding task messages is checked sequentially in ascending order of task message sequence numbers. When the message processing status of each task message in ascending order of task message sequence numbers is "processed complete," the processed confirmation sequence number is updated to the last task message sequence number in the "processed complete" state. When any intermediate task message has not yet formed a task message processing confirmation record with a "processed complete" state, the sequential processing confirmation sequence number stops advancing; even if a task message following an incomplete task message has been processed, the sequential processing confirmation sequence number is not updated across incomplete task messages. For example, if task messages 1 to 9 have all been processed, task message 10 has not been processed, and task message 11 has been processed, the sequential processing confirmation sequence number remains at 9.
[0038] In this implementation scheme, an independent task-level communication channel is established for each top-level task, so that task start messages and task messages are transmitted based on the corresponding communication connection, and task identifiers are used to identify the ownership of task messages. After the independent running process exits, by maintaining the task-level communication channel, task message receiving record, and task message processing confirmation record, task messages that have entered the transmission process but have not yet been processed can still continue to execute the subsequent task message processing process.
[0039] Specifically, determining the task termination type based on task completion events, task stoppage events, and process exit events includes:
[0040] When the task execution service completes all execution content corresponding to the task start message and generates a task execution end marker based on the task completion event, the task end type is determined to be normal completion. When the independent running process receives a task stop instruction and completes the pre-stop processing to allow continued execution, it generates a task stop completion event and generates a task execution end marker based on the task stop completion event, the task end type is determined to be controlled stop. When a running process exit event is detected and the task-level communication receiving side does not receive a task execution end marker, the task end type is determined to be abnormal exit. Here, the task stop instruction refers to the control message generated by the main control module based on the task stop request and sent to the independent running process to trigger the current task's controlled stop process. The pre-stop processing to allow continued execution means that after the independent running process receives the task stop instruction, it no longer generates new... The task execution activity only continues to complete the task processing processes that have been started and need to be completed before the task stop instruction is received, including the data acquisition and processing, result saving and processing, and task message submission and processing that have entered the task-level communication channel sending process. The running process exit event refers to the process lifecycle event generated when the runtime environment detects that the independent running process corresponding to the current task has ended. The main control module establishes a running process exit event listener for each independent running process. When the independent running process ends normally, ends under controlled stop, or terminates due to abnormal operation, the runtime environment triggers the corresponding running process exit event. The running process exit event only indicates that the process lifecycle of the independent running process has ended. It does not indicate that the task messages submitted to the task-level communication channel before the independent running process exits have been transmitted, nor does it indicate that the corresponding task messages have been processed by the upper layer.
[0041] When a running process exit event is detected, the execution status of the associated records for the same task is updated: the task execution status is changed to the task completion status, and the task recycling status is changed to the waiting recycling status; at the same time, the time of the running process exit event is recorded as the task end time; one task execution process corresponds to one independent running process; when the task execution service completes the normal completion process or the controlled stop process, a task execution end marker is generated, and the execution flow corresponding to the current task is terminated, causing the independent running process to exit; the main control module determines the end of the life cycle of the independent running process by listening to the running process exit event, and performs subsequent task end status updates and exit recycling processing; the task end time is used to represent the moment when the life cycle of the independent running process ends, that is, the moment when the running process exit event occurs, and is independent of the subsequent task message processing and resource recycling completion time.
[0042] When the task termination type is determined to be abnormal exit and the task execution association record corresponding to the current task has not completed the exit and recycling process, if the task-level communication receiving side receives the task execution termination flag corresponding to the current task, it corrects the task termination type according to the task completion event or task stop completion event corresponding to the task execution termination flag. The task-level communication receiving side determines the task termination process based on the task execution termination flag corresponding to the same task execution association record. When the task execution termination flag corresponds to a task completion event, the task termination type is determined to be normal completion; when the task execution termination flag corresponds to a task stop completion event, the task termination type is determined to be controlled stop. The task execution termination flag is only used for the same task execution process corresponding to the task execution association record and is not used to determine the termination type of other task execution instances. The task completion type indicates the reason for the current task entering the termination process, including undetermined, normal completion, controlled stop, and abnormal exit. The task completion event is the event information generated by the task execution service after completing all execution content corresponding to the task start message, used to trigger the generation of the task execution completion marker. The task stop completion event is the event information generated by the task execution service after receiving the task stop instruction and completing the processing procedures that allowed continued execution before the stop, used to indicate that the current task has completed the controlled stop process.
[0043] In this implementation plan, by setting the process of querying, creating, and establishing task execution association records as a task startup process that cannot be executed simultaneously by other task startup requests corresponding to the same task identifier, the same task identifier can still maintain a unique task execution instance relationship under parallel task startup requests. At the same time, by restricting the task execution association records from being re-established before the exit and recycling process is completed, the exit and recycling process of old task execution instances is prevented from affecting new task execution instances.
[0044] Specifically, based on the task execution end marker or communication channel termination event corresponding to the task end type, the task message end boundary is determined, and the task message end boundary sequence number is generated and the task message end boundary status is updated, including:
[0045] When the task completion type is normal completion or controlled stop, the task message end boundary is determined as follows: New task message generation stops, and the submission processing of task messages already formed before the cessation of new task message generation continues. After all task messages formed but not yet submitted before the cessation of new task message generation are submitted, a task execution end marker is submitted along the same task-level communication channel corresponding to the current task. Task message submission processing refers to writing the task message into the task-level communication channel corresponding to the current task, allowing the task message to enter the data transmission flow of the task-level communication channel, rather than simply generating a local send buffer or waiting-to-send queue record. After the cessation of new task message generation, the independently running process only continues the submission processing of task messages formed before the stop but not yet written to the task-level communication channel; the task execution end marker is submitted only after all pending task messages have been written to the task-level communication channel.
[0046] After receiving the task execution end marker corresponding to the current task, the task-level communication receiving side does not generate a task message sequence number for the task execution end marker. Instead, it determines the maximum task message sequence number among the task messages already received before the task execution end marker in the same task execution association record as the task message end boundary sequence number and modifies the task message end boundary status to the established state. When the same task execution end marker is received again, the task message end boundary sequence number is not re-determined, and the current task message end boundary sequence number remains unchanged. When the task execution end marker arrives at the task-level communication receiving side, if there is no task message in the current task execution association record, there is no maximum task message sequence number. In this case, the task message end boundary sequence number is set to the initial value of the processed confirmation sequence number.
[0047] The task execution end marker is generated by the task execution service after determining the task end type. The task-level communication receiving side determines the corresponding task end type based on the end type information carried in the task execution end marker or its association with the task completion event or task stop completion event. The task execution end marker and task messages adopt the same sequential submission mechanism of the same task-level communication channel. The task execution end marker is sent only after all task messages formed before the generation of new task messages has been completed and submitted. The task-level communication receiving side processes task messages and task execution end markers according to the receiving order in the task-level communication channel, and does not change the task message end boundary in parallel before or after receiving the task execution end marker. The task message end boundary status is used to indicate whether the end range of the task message corresponding to the current task has been determined, including an unestablished state and an established state. An unestablished state indicates that the position of the last task message included in the recycling judgment in this task execution has not yet been determined. An established state indicates that the task message end boundary sequence number has been determined according to the task execution end marker or the communication channel termination event. After the task message end boundary status is changed from unestablished to established, the task message end boundary sequence number remains unchanged within the life cycle of the current task running associated record and is no longer modified according to subsequently received end markers or task messages.
[0048] When the task termination type is abnormal exit, the task message termination boundary is determined as follows: The task-level communication channel corresponding to the current task is maintained, and task messages submitted to the task-level communication channel and entering the transmission process before the running process exit event occurs are continued to be received. When the task-level communication receiving side obtains a communication channel termination event and determines, based on the communication channel termination event, that the independently running process can no longer generate new task messages to the task-level communication channel corresponding to the current task, and simultaneously determines that the task-level communication receiving side has completed the reception and processing of task messages that have entered the task-level communication channel, the largest task message sequence number among the task messages received before the communication channel termination event occurs is determined as the task message termination boundary sequence number, and the task message termination boundary status is modified to an established state. The communication channel termination event indicates that the task-level communication receiving side confirms that the communication channel corresponding to the current task no longer has the conditions to continue transmitting task messages, including the sending end closing the communication connection or the communication management logic detecting the communication channel termination status.
[0049] When the task-level communication receiving side receives a task execution end marker or obtains a communication channel termination event, and there is no task message in the task message receiving record corresponding to the current task execution associated record, the task message end boundary sequence number is set to the initial value of the processed confirmation sequence number, and the task message end boundary status is modified to the established status. When the task message end boundary status is already in the established status, if the task-level communication receiving side receives a task message with a task message sequence number greater than the task message end boundary sequence number, the task message end boundary sequence number is not updated using this task message.
[0050] In this implementation scheme, by setting the processed confirmation sequence number to record the maximum processing completion position in the current task message sequence number increment direction, the task-level communication receiving side can determine whether the task messages have been processed in sequence based on the task message processing confirmation record. When there are task messages that have not formed a processing completion status, the processed confirmation sequence number is not updated across the task message, thereby ensuring that the task message processing confirmation status is consistent with the actual processing progress and providing a basis for subsequent task retrieval status judgment.
[0051] Specifically, based on the task message end boundary state, the task message end boundary sequence number, and the processed confirmation sequence number, the task recycling status is determined to be either an allowed recycling state or a waiting recycling state, including:
[0052] When the task message end boundary state is "not established," the task recycling state remains "awaiting recycling." When the task message end boundary state is "established," the processed confirmation number is compared with the task message end boundary number. If the processed confirmation number is less than the task message end boundary number, it is determined that among the task messages whose sequence number is less than or equal to the task message end boundary number, at least one task message has not yet reached a completed processing state. The task recycling state remains "awaiting recycling," and the task recycling state is reassessed based on the updated processed confirmation number after a new task message processing confirmation record is generated, the task message end boundary state is updated, or the task execution state is updated. When the processed confirmation number is equal to the task message end boundary number, the task recycling state is set to "allowed recycling." When the processed confirmation number is greater than the task message end boundary number, the task recycling state remains "awaiting recycling."
[0053] When the task execution status is task completed, the task message end boundary status is not established, and the task message end boundary sequence number cannot be determined by the task execution end marker or communication channel termination event, or the task-level communication receiving side cannot continue to obtain the task message end boundary information, the current task will not be set to the allowable recycling status.
[0054] In this implementation scheme, by distinguishing between task startup messages and task messages, the message transmission process during task startup and task execution is made independent of each other. The task startup message is used to trigger an independently running process to establish a task execution service, while the task message is used to transmit log information, collection results, download results, or messages corresponding to the task running status generated during task execution, thereby clarifying the data transmission relationship between the task lifecycle establishment process and the task message processing process.
[0055] Specifically, based on the task execution status and task recycling status in the task execution association record, a task exit and recycling record is generated, and exit and recycling processing is performed, including:
[0056] After the task execution status, task message end boundary status, or sequential processing confirmation number is updated, when the task execution status is task end and the task recycling status is allowed recycling, a task exit recycling record is formed based on the task end type, task end time, task message end boundary number, and processed confirmation number. The exit recycling process is then executed: the associated information of the running process corresponding to the current task is released, the task-level communication channel corresponding to the current task is closed, the task message receiving record, task message processing confirmation record, and receiving-side running resources corresponding to the current task are released, the current time is recorded as the task recycling completion time, and the task exit recycling record is updated. Subsequently, the task running association record corresponding to the current task is deleted, completing the exit recycling process for the current task. If the exit recycling conditions are not met, the exit recycling process is not executed. The receiving-side running resources are used to continue receiving task messages that have entered the task-level communication receiving side after the running process exits, to save task message receiving records, and to support the upper-level processing process in executing task message processing and forming task message processing confirmation records. The task message processing result is used to indicate the message processing status of task messages within the task message end boundary range, including all processed statuses and task message processing exception statuses. In the task completion type, "abnormal exit" only indicates that the task execution process has ended due to the exit of the running process, and does not indicate that the task execution content has been fully completed. The task message processing result only indicates the processing status of task messages that have entered the processing scope of the task-level communication receiving side. The task history record is used to save the task exit and recycling results corresponding to tasks that have completed the exit and recycling process, so as to query the execution completion information and exit and recycling results of the corresponding task based on the task identifier.
[0057] In this implementation plan, by establishing task execution association records, creating independent running processes, and establishing task-level communication channels, a task execution architecture is formed in which the main control module manages the task lifecycle, the independent running processes execute the task content, and the task-level communication receiving side processes the task messages. This enables the task execution status, task message processing status, and resource reclamation status to be associated based on the same task execution instance, providing a foundation for subsequent task message processing confirmation, task message end boundary determination, and exit reclamation processing.
[0058] Reference Figure 2 As shown, the second aspect of the present invention provides a parallel execution system based on task-level isolation, comprising: a task execution establishment module, used to establish a task execution association record based on a task identifier, create an independent running process and a task-level communication channel; a task message processing module, used to form a task message receiving record based on task messages and task execution association records, perform task message processing, form a task message processing confirmation record and determine the processed confirmation sequence number; a task end determination module, used to determine the task end type based on a task completion event, a task stop completion event and a running process exit event; a message boundary determination module, used to perform task message end boundary determination based on a task execution end flag or a communication channel termination event corresponding to the task end type, generate a task message end boundary sequence number and update the task message end boundary state; a task recycling judgment module, used to determine the task recycling state as an allowed recycling state or a waiting recycling state based on the task message end boundary state, the task message end boundary sequence number and the processed confirmation sequence number; and a task exit recycling module, used to form a task exit recycling record and perform exit recycling processing based on the task execution state and task recycling state in the task execution association record.
[0059] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0060] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0061] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0062] The methods and related apparatuses provided in this application are described with reference to the method flowcharts and / or structural diagrams provided in this application. Specifically, each block of the method flowchart and / or structural diagram, as well as combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to create a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the process. Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 A process or multiple processes and / or structures illustrate the steps of the functions specified in one or more boxes.
[0063] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A method for parallel execution based on task-level isolation, characterized in that, include: S1, establish task execution association records based on task identifiers, and create independent running processes and task-level communication channels; S2, Based on the task message and the task execution association record, a task message receiving record is formed, task message processing is performed, a task message processing confirmation record is formed, and the processed confirmation sequence number is determined. S3, determine the task termination type based on the task completion event, the task stop completion event, and the running process exit event; S4. Based on the task execution end marker or communication channel termination event corresponding to the task end type, determine the task message end boundary, generate the task message end boundary sequence number and update the task message end boundary status. S5. Based on the task message end boundary status, task message end boundary sequence number, and processed confirmation sequence number, determine the task recycling status as either allowed recycling or awaiting recycling. S6. Based on the task execution status and task recycling status in the task running association record, generate a task exit and recycling record and perform exit and recycling processing.
2. The method of claim 1, wherein, The step of establishing a task execution association record based on the task identifier and creating an independent running process and task-level communication channel includes: After receiving a task start request, the main control module queries the task execution association record based on the task identifier in the task start request. If there is no task execution association record corresponding to the task identifier, or if there is a task execution association record corresponding to the task identifier but the task execution status is not in the task running state and the task recycling status is not in the waiting recycling state, an independent running process corresponding to the current task is created, and a corresponding task-level communication channel is established. For this task execution, an association relationship is established based on the task identifier associated running process association information, task-level communication channel association information, task execution status, task recycling status, task end type, task end time, task recycling completion time, task message end boundary status, task message end boundary sequence number, and processed confirmation sequence number to form a task execution association record; otherwise, no new independent running process is created. When establishing task execution association records, the task execution status is set to task running status, the task end type is set to undetermined, the task message end boundary status is set to unestablished status, the task recycling status is set to not entered recycling status, and the processed confirmation sequence number is set to the initial value. After creating an independent running process and establishing a task-level communication channel, the task-level communication channel sends a task start message. The independent running process establishes a task execution service based on the task start message and executes the current task.
3. The method of claim 2, wherein, The process of forming a task message reception record based on task messages and task execution association records includes: During the execution of the current task by the independent running process, the generated log information, collection results, download results or task running status messages are used as task messages. The task message sequence number is generated according to the order of the task messages corresponding to the current task. After associating the task message sequence number with the corresponding task message, it is sent to the task-level communication receiving side through the task-level communication channel corresponding to the current task. The task-level communication receiving side determines the current task to which the task message belongs based on the task execution association record. It forms a task message receiving record based on the task identifier, task message sequence number, task message type, task message content, and message processing status. Then, it sends the task message to the corresponding upper-layer processing module based on the task message receiving record.
4. The method of claim 3, wherein, The execution of task message processing, which generates a task message processing confirmation record and determines the processed confirmation sequence number, includes: Based on the task message reception record, the upper-layer processing module performs the upper-layer processing corresponding to the task message type: when log information is written, collection results are saved, download results are registered, and task status messages are updated, the upper-layer processing is confirmed as successful, and the message processing status is set to the processing completed state. The task-level communication receiving side associates the task identifier, task message sequence number, and message processing status to form a task message processing confirmation record; otherwise, the message processing status is set to the processing failed state, and the task recycling status and task execution status are not updated. Update the processed confirmation sequence number: for each new task message processing confirmation record formed, starting from the next task message sequence number after the current processed confirmation sequence number, the message processing status of the corresponding task messages is checked in ascending order of task message sequence number; when the message processing status of each task message in ascending order of task message sequence number is the processing completed state, the processed confirmation sequence number is updated to the last task message sequence number with the processing completed state.
5. The method of claim 4, wherein, The method of determining the task termination type based on task completion events, task stoppage events, and running process exit events includes: When the task execution service completes all execution content corresponding to the task start message and generates a task execution end marker based on the task completion event, the task end type is determined to be normal completion; when an independently running process receives a task stop instruction and completes the processing procedures that allowed continued execution before stopping, generates a task stop completion event, and generates a task execution end marker based on the task stop completion event, the task end type is determined to be controlled stop; when a running process exit event is detected and the task-level communication receiving side does not receive a task execution end marker, the task end type is determined to be abnormal exit. When a running process exit event is detected, the execution status of the associated records for the same task is updated: the task execution status is changed to the task completed status, and the task recycling status is changed to the waiting recycling status; at the same time, the time when the running process exit event occurs is recorded as the task completion time. When the task end type is determined to be abnormal exit and the task execution association record corresponding to the current task has not completed the exit recycling process, if the task-level communication receiving side receives the task execution end flag corresponding to the current task, the task end type is corrected according to the task completion event or task stop completion event corresponding to the task execution end flag.
6. The method of claim 5, wherein, The step of determining the task message end boundary based on the task execution end marker or communication channel termination event corresponding to the task end type, generating a task message end boundary sequence number, and updating the task message end boundary status includes: When the task completion type is normal completion or controlled stop, the task message end boundary is determined as follows: New task message generation stops, and the submission processing of task messages already formed before the cessation of new task message generation continues; after all task messages formed but not yet submitted before the cessation of new task message generation are submitted, a task execution end marker is submitted along the same task-level communication channel corresponding to the current task; upon receiving the task execution end marker corresponding to the current task, the task-level communication receiving side does not generate a task message sequence number for the task execution end marker, but determines the largest task message sequence number among the task messages received before the task execution end marker in the same task execution association record as the task message end boundary sequence number, and modifies the task message end boundary status to the established state.
7. The method of claim 6, wherein, The step of determining the task message end boundary based on the task execution end marker or communication channel termination event corresponding to the task end type, generating a task message end boundary sequence number, and updating the task message end boundary status includes: When the task termination type is abnormal exit, the task message termination boundary is determined as follows: the task-level communication channel corresponding to the current task is maintained, and task messages that have been submitted to the task-level communication channel and entered the transmission process before the running process exit event occurs are continued to be received; when the task-level communication receiving side obtains the communication channel termination event, and determines that the independent running process can no longer generate new task messages to the task-level communication channel corresponding to the current task, and at the same time determines that the task-level communication receiving side has completed the reception and processing of task messages that have entered the task-level communication receiving side in the task-level communication channel, the largest task message sequence number among the task messages received before the communication channel termination event occurs is determined as the task message termination boundary sequence number, and the task message termination boundary status is modified to the established status; When the task-level communication receiving side receives a task execution end marker or obtains a communication channel termination event, and there is no task message in the task message receiving record corresponding to the current task execution associated record, the task message end boundary sequence number is set to the initial value of the processed confirmation sequence number, and the task message end boundary status is modified to the established status. When the task message end boundary status is already in the established status, if the task-level communication receiving side receives a task message with a task message sequence number greater than the task message end boundary sequence number, the task message end boundary sequence number is not updated using this task message.
8. The method of claim 7, wherein, The step of determining the task recycling status as either an allowed recycling state or a waiting recycling state based on the task message end boundary state, the task message end boundary sequence number, and the processed confirmation sequence number includes: When the task message end boundary state is "not established," the task recycling state remains "awaiting recycling." When the task message end boundary state is "established," the processed confirmation number is compared with the task message end boundary number. If the processed confirmation number is less than the task message end boundary number, it is determined that among the task messages whose sequence number is less than or equal to the task message end boundary number, at least one task message has not yet reached a completed processing state. The task recycling state remains "awaiting recycling," and the task recycling state is reassessed based on the updated processed confirmation number after a new task message processing confirmation record is generated, the task message end boundary state is updated, or the task execution state is updated. When the processed confirmation number is equal to the task message end boundary number, the task recycling state is set to "allowed recycling." When the processed confirmation number is greater than the task message end boundary number, the task recycling state remains "awaiting recycling." 9. The method of claim 8, wherein, The step of generating a task exit and recycling record and performing exit and recycling processing based on the task execution status and task recycling status in the task execution association record includes: When the task execution status is "task completed" and the task recycling status is "recycling allowed," a task exit recycling record is generated based on the task completion type, task completion time, task message completion boundary number, and processed confirmation number. The exit recycling process is then executed: the associated information of the running process corresponding to the current task is released, the task-level communication channel corresponding to the current task is closed, the task message receiving record, task message processing confirmation record, and receiving-side running resources corresponding to the current task are released, the current time is recorded as the task recycling completion time, and the task exit recycling record is updated. Subsequently, the task running association record corresponding to the current task is deleted, completing the exit recycling process for the current task. If the exit recycling conditions are not met, the exit recycling process is not executed.
10. A parallel execution system based on task-level isolation, characterized in that, include: The task execution creation module is used to establish task execution association records based on task identifiers, and to create independent running processes and task-level communication channels; The task message processing module is used to form a task message receiving record based on the task message and the task execution association record, perform task message processing, form a task message processing confirmation record, and determine the processed confirmation sequence number. The task completion determination module is used to determine the task completion type based on the task completion event, the task stop completion event, and the running process exit event. The message boundary determination module is used to determine the task message end boundary based on the task execution end flag or communication channel termination event corresponding to the task end type, generate the task message end boundary sequence number and update the task message end boundary status. The task recycling judgment module is used to determine the task recycling status as either allowed recycling or waiting recycling status based on the task message end boundary status, task message end boundary sequence number, and processed confirmation sequence number. The task exit and recycling module is used to generate task exit and recycling records and perform exit and recycling processes based on the task execution status and task recycling status in the task running association records.
Citation Information
Patent Citations
Task isolation methods, devices, electronic equipment and computer-readable media
CN112306685B
Kernel and task isolation method and device
CN113868636A
