Synchronous task execution method, apparatus, device, and medium
By simulating the synchronization mechanism of synchronous tasks in software and scheduling the task queue, the problem of multi-process deadlock is solved, ensuring that tasks are executed in the expected order and avoiding device blockage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI BIREN TECH CO LTD
- Filing Date
- 2025-12-04
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, synchronization primitives share the same channel on hardware, which can lead to deadlocks between processes when multiple processes use the device simultaneously, causing device blocking.
By simulating the synchronization mechanism of synchronous tasks in software, tasks in each task queue are scheduled to be executed in the order expected by the user process. The software also switches task queues that do not meet the execution conditions in real time to avoid deadlock.
This ensures that each task is executed in the order expected by the user, avoiding deadlocks when multiple processes use the device simultaneously, and improving the efficiency and reliability of the device.
Smart Images

Figure CN121255489B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular, to a synchronous task execution method, device, equipment and medium. BACKGROUND
[0002] For general computing acceleration devices, many synchronization primitives are provided to ensure that multiple process tasks can be executed or access shared resources in a specific order, but these synchronization primitives often share the same channel on the hardware, resulting in deadlock between processes when multiple processes use the device at the same time, causing device blocking. SUMMARY
[0003] The present application provides a synchronous task execution method, device, equipment and medium to solve the defect that the synchronization primitives in the prior art often share the same channel on the hardware, resulting in deadlock between processes when multiple processes use the device at the same time, and to realize the scheduling of tasks in each task queue by a software-simulated synchronization mechanism corresponding to a synchronous task, so that each task is executed in turn in the order expected by the user process, software execution of the synchronous task is realized, and in software simulation, the task queue that does not meet the execution condition is switched in real time according to the scheduling rule, avoiding waiting all the time, and further avoiding deadlock between processes when multiple processes use the device at the same time.
[0004] The present application provides a synchronous task execution method applied to a scheduler, comprising the following steps:
[0005] Receiving a task queue set submitted by multiple user processes;
[0006] Obtaining a first execution task from a first task queue in the task queue set;
[0007] In the case that the first execution task is a synchronous task, simulating the first execution task based on a software language, and realizing a synchronization mechanism corresponding to the first execution task;
[0008] Based on the synchronization mechanism and a scheduling rule, executing the execution tasks in the task queue set; wherein the scheduling rule is used to switch the task queues in the task queue set.
[0009] According to the synchronous task execution method provided by the present application, based on the synchronization mechanism and the scheduling rule, the execution tasks in the task queue set are executed, which comprises: based on the synchronization mechanism, determining a first execution condition corresponding to the first execution task; based on the first execution condition and the scheduling rule, executing the execution tasks in the task queue set.
[0010] According to the synchronous task execution method provided by the application, the execution task in the task queue set is executed based on the first execution condition and the scheduling rule, and the method comprises the following steps: in the case that the first execution condition is met in the scheduler, determining the scheduling strategy as a sequential execution strategy from the scheduling rule; based on the sequential execution strategy, executing the next execution task of the first execution task in the first task queue; in the case that the first execution condition is not met in the scheduler, determining the scheduling strategy as a switching strategy from the scheduling rule; based on the switching strategy, switching the first task queue to a second task queue in the task queue set; in the case that the second execution task in the second task queue is a synchronous task, executing the execution task in the task queue set based on the execution result of the second execution task.
[0011] According to the synchronous task execution method provided by the application, the execution task in the task queue set is executed based on the first execution condition and the scheduling rule, and the method comprises the following steps: in the case that the first execution condition is met in the scheduler, determining the scheduling strategy as a sequential execution strategy from the scheduling rule; based on the sequential execution strategy, executing the next execution task of the first execution task in the first task queue; in the case that the first execution condition is not met in the scheduler, determining the scheduling strategy as a switching strategy from the scheduling rule; based on the switching strategy, switching the first task queue to a second task queue in the task queue set; in the case that the second execution task in the second task queue is a synchronous task, executing the execution task in the task queue set based on the execution result of the second execution task.
[0012] According to the synchronous task execution method provided by the application, after the first execution task is obtained from the first task queue in the task queue set, the method further comprises the following steps: analyzing the first execution task to obtain the format corresponding to the first execution task; based on the format corresponding to the first execution task, determining the task type of the first execution task; the task type comprises the synchronous task and the non-synchronous task.
[0013] According to the synchronous task execution method provided by the application, in the case that the first execution task is a non-synchronous task, the first execution task is sent to hardware, and the hardware is used for executing the first execution task.
[0014] According to the synchronous task execution method provided by the application, the first execution task is simulated based on a software language, and the synchronous mechanism corresponding to the first execution task is realized, and the method comprises the following steps: based on the software language, the first execution task is encapsulated to simulate an execution unit corresponding to the first execution task; based on the dependency relationship of the execution unit and the shared resource type of the execution unit, the synchronous mechanism corresponding to the first execution task is determined.
[0015] The application further provides a synchronous task execution device, comprising:
[0016] receive a task queue set submitted by a plurality of user processes;
[0017] obtain a first execution task from a first task queue in the task queue set;
[0018] simulate the first execution task based on a software language in a case where the first execution task is a synchronous task, to implement a synchronous mechanism corresponding to the first execution task;
[0019] execute execution tasks in the task queue set based on the synchronous mechanism and a scheduling rule, wherein the scheduling rule is used to switch task queues in the task queue set.
[0020] The application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the synchronous task execution method when executing the computer program.
[0021] The application further provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the synchronous task execution method.
[0022] The application further provides a computer program product, which includes a computer program, and the computer program is executable on a processor to implement the synchronous task execution method.
[0023] The synchronous task execution method, device, equipment and medium provided by the application receive a task queue set submitted by a plurality of user processes, obtain a first execution task from a first task queue in the task queue set, simulate the first execution task based on a software language in a case where the first execution task is a synchronous task, to implement a synchronous mechanism corresponding to the first execution task, execute execution tasks in the first task queue based on the synchronous mechanism and a scheduling rule, wherein the scheduling rule is used to switch the first task queue to a second task queue in the task queue set. In this way, the synchronous mechanism corresponding to the software simulation synchronous task is simulated to schedule tasks in each task queue, so that each task is executed in turn according to the expected order of the user process, the software executes the synchronous task, and the scheduling rule is used to switch the task queue that does not meet the execution condition in real time in the software simulation, to avoid waiting all the time, and further avoid the formation of process deadlock between processes when multiple processes use the equipment at the same time. BRIEF DESCRIPTION OF DRAWINGS
[0024] In order to make the technical solutions in the present application or prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative effort based on the accompanying drawings are within the protection scope of the present application.
[0025] Figure 1 is a structural schematic diagram of a multi-process deadlock generation principle provided by the prior art.
[0026] Figure 2 is one of flow schematic diagrams of a synchronous task execution method provided by the present application.
[0027] Figure 3 is another of flow schematic diagrams of a synchronous task execution method provided by the present application.
[0028] Figure 4 is a structural schematic diagram of a system for implementing a synchronous scheduling task method provided by the present application.
[0029] Figure 5 is a structural schematic diagram of a synchronous task execution device provided by the present application.
[0030] Figure 6 is a structural schematic diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0031] In order to make the technical solutions in the present application or prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative effort based on the accompanying drawings are within the protection scope of the present application.
[0032] The following describes the generation process of a multi-process deadlock by taking a synchronous primitive of a pass (PASS) and a non-zero pass (NZ-PASS) as an example.
[0033] Figure 1 is a structural schematic diagram of a multi-process deadlock generation principle provided by the prior art, as shown in Figure 1As shown, it comprises: a first process 101, a second process 102, a third process 103, a fourth process 104, a first hardware command queue descriptor (HCQD) 105, a second hardware command queue descriptor 106, a first pipe (PIPE) interface 107, and a second pipe (PIPE) interface 108. Specifically, the first process sends a first non-zero execution pass primitive (NZ-PASS0) to the first pipe (PIPE) interface through the first hardware command queue descriptor, at this time, the shared amount is 0, so the first pipe (PIPE) interface is blocked; the second process sends a second execution pass primitive (PASS1) to the first pipe (PIPE) interface through the first hardware command queue descriptor, at this time, the first pipe (PIPE) interface is blocked, so PASS1 cannot be executed; the third process sends a second non-zero execution pass primitive (NZ-PASS1) to the second pipe (PIPE) interface through the second hardware command queue descriptor, at this time, the shared amount is 0, so the second pipe (PIPE) interface is blocked; the fourth process sends a first execution pass primitive (PASS0) to the second pipe (PIPE) interface through the second hardware command queue descriptor, at this time, the second pipe (PIPE) interface is blocked, so PASS0 cannot be executed. Figure 1 It can be seen that NZ-PASS0 depends on PASS0, PASS0 depends on NZ-PASS1, NZ-PASS1 depends on PASS1, and PASS1 depends on NZ-PASS0, which causes a deadlock loop.
[0034] In summary, for general computing acceleration devices, many synchronization primitives are provided to ensure that multiple process tasks can be executed or access shared resources in a specific order, but these synchronization primitives often share the same channel in hardware, resulting in a deadlock between processes when multiple processes use the device at the same time.
[0035] Based on the above problems, the present application provides a synchronization task execution method, which receives multiple execution tasks submitted by a user process; in the case that a first execution task in the multiple execution tasks is a synchronization task, simulates the first execution task based on a software language to realize a synchronization mechanism corresponding to the first execution task; and schedules the first execution task based on the synchronization mechanism and a scheduling rule, wherein the scheduling rule is used to switch a synchronization task that does not meet an execution condition. In this way, the synchronization mechanism corresponding to the synchronization task is simulated by software to schedule the tasks in each task queue, so that each task is executed in the order expected by the user process, software execution of the synchronization task is realized, and the task queue that does not meet the execution condition is switched in real time according to the scheduling rule in the software simulation, avoiding waiting all the time, and further avoiding a deadlock between processes when multiple processes use the device at the same time.
[0036] The following will be described in combination withFigures 2-5 The synchronous task execution method of the present application is suitable for all synchronous task executions, and the execution subject of the method can be an electronic device or a synchronous task execution device arranged in the electronic device, which can be realized by software, hardware or a combination of both.
[0037] Figure 2 is one of the flowcharts of the synchronous task execution method provided by the present application, as shown in Figure 2 The method is applied to a scheduler and includes the following steps.
[0038] Step 201: Receive a task queue set submitted by multiple user processes.
[0039] Here, the user process refers to an independent execution unit running in the user state of an operating system and initiated by a user or created by an application program.
[0040] It should be noted that each task queue includes multiple execution tasks, which can be synchronous tasks or non-synchronous tasks.
[0041] Here, the scheduler can be driven by a kernel thread.
[0042] It should be noted that the synchronous task execution method is realized by kernel driving, and the upper-layer software does not need to be aware of it and can run normally without any modification, thus having good compatibility with the existing software stack and not needing to limit the user's multi-process usage, which is very friendly to users.
[0043] Step 202: Obtain a first execution task from a first task queue in the task queue set.
[0044] Here, the first execution task can include a synchronous task and a non-synchronous task.
[0045] Step 203: If the first execution task is a synchronous task, simulate the first execution task based on a software language to realize the synchronization mechanism corresponding to the first execution task.
[0046] It should be noted that when the first execution task is a synchronous task, the scheduler will eliminate the first execution task and simulate the first execution task by using a software language.
[0047] Here, the synchronization task is a specific task used to coordinate the execution order, resource access permission or data consistency of multiple execution units (processes, threads, hardware modules) in parallel computing, multi-process / thread cooperation and hardware device interaction scenarios. The core goal is to eliminate execution chaos (such as data competition, sequence disorder) in a concurrent environment, and ensure that each execution unit advances in order according to the preset logic. Its application fields include chip verification, Graphics Processing Unit (GPU) parallel computing, smart card communication and other fields.
[0048] Here, the synchronization mechanism can be understood as a complete solution to implement the synchronization task, that is, to convert the abstract synchronization task into a coordinated behavior that can be implemented, reused and exception-free. Its essence includes synchronization primitives, execution rules and scene adaptation.
[0049] Optionally, the synchronization mechanism corresponding to the synchronization task can be automatically generated by a script, or the synchronization mechanism can be determined by analyzing the dependency relationship and shared resource type corresponding to the synchronization task.
[0050] For example, the first execution task is simulated based on a software language, and the synchronization mechanism corresponding to the first execution task is implemented, including: encapsulating the first execution task based on the software language, simulating the execution unit corresponding to the first execution task; determining the synchronization mechanism corresponding to the first execution task based on the dependency relationship of the execution unit and the shared resource type of the execution unit.
[0051] Here, the logic code, input parameter, output result and execution dependency of the first execution task are encapsulated as a modular independent unit based on the selected software language.
[0052] Here, the execution unit can be a virtual execution carrier for running the first execution task, such as a thread.
[0053] Here, the dependency relationship refers to the logical association between the execution of multiple execution units. For example, serial dependency: execution unit A is completed, and then execution unit B can be started.
[0054] Here, the shared resource type refers to a software resource commonly accessed by multiple execution units during running.
[0055] In the embodiment of the application, the synchronization mechanism of the synchronization task is simulated by software, the software schedules the synchronization task, and the process lock state in the hardware is avoided, so as to cause device blocking.
[0056] Step 204, based on the synchronization mechanism and the scheduling rule, executing the execution task in the task queue set.
[0057] The scheduling rule is used to switch the task queue in the task queue set.
[0058] Here, the scheduling rule is used to determine whether to switch the task queue according to the execution condition of the synchronization task, that is, the execution result.
[0059] Further, the execution of the execution task in the task queue set based on the synchronization mechanism and the scheduling rule comprises: determining the first execution condition corresponding to the first execution task based on the synchronization mechanism; and executing the execution task in the task queue set based on the first execution condition and the scheduling rule.
[0060] Here, the first execution condition can be understood as the execution result of the first execution task. For example, when the synchronization task of NZ-pass0 is executed, the required execution condition is that the shared amount is not 0. When the shared amount is 0, NZ-pass0 cannot be executed.
[0061] Here, the scheduling rule can include various scheduling strategies, such as switching strategies and sequential execution strategies.
[0062] Specifically, after determining the execution condition of the synchronization task according to the synchronization mechanism, the execution task in the task queue is executed according to the execution condition and the scheduling rule.
[0063] Optionally, the execution of the execution task in the task queue can be directly executed, or the execution of the execution task in the task queue can be executed after the execution of the execution task in the task queue.
[0064] In the embodiment of the application, the execution of the execution task in the task queue is executed by the execution condition and the scheduling rule, so as to avoid blocking in the software.
[0065] Exemplarily, the execution of the execution task in the task queue set based on the first execution condition and the scheduling rule comprises: in the case that the first execution condition is met in the scheduler, determining that the scheduling strategy is a sequential execution strategy from the scheduling rule; executing the next execution task of the first execution task in the first task queue based on the sequential execution strategy; in the case that the first execution condition is not met in the scheduler, determining that the scheduling strategy is a switching strategy from the scheduling rule; switching the first task queue to a second task queue in the task queue set based on the switching strategy; and in the case that the second execution task in the second task queue is a synchronization task, executing the execution task in the task queue set based on the execution result of the second execution task.
[0066] Here, the scheduler can be a thread created by a kernel driver. In addition, the kernel driver can create multiple threads to process the execution task in parallel.
[0067] Specifically, in the case that the first execution condition is met in the scheduler, a next execution task of the first execution task in the first task queue is executed, and in the case that the first execution condition is not met in the scheduler, the first task queue is switched to a second task queue in the task queue set, and a second execution task in the second task queue is executed.
[0068] It should be noted that after switching to the second task queue, the type of the second execution task in the second task queue needs to be re-judged, and different processing is performed according to the type, if the type is a synchronous task, the behavior of the synchronous task is simulated by software language in the scheduler, and if the type is a non-synchronous task, the second execution task is uploaded to hardware.
[0069] Here, the execution task in the task queue set can be executed according to the execution result of the second execution task, or the execution task in the task queue set can be executed according to the execution result of the execution task in the third task queue.
[0070] In the embodiment of the application, different scheduling strategies are determined from the scheduling rules according to whether the execution condition exists in the scheduler, and the next execution task is determined according to the scheduling strategy, so that the synchronous task cannot release resources and cause congestion is avoided.
[0071] Further, the execution task in the task queue set is executed based on the execution result of the second execution task, including: determining a target task queue based on the execution result of the second execution task; in the case that the current execution task in the target task queue is a synchronous task, traversing all task queues in the task queue set in order based on the execution result of the current execution task; and in the case that the scheduler is rotated to the first task queue again, executing the execution task in the first task queue.
[0072] Specifically, the second execution task is a synchronous task, the behavior of the second execution task is simulated by software language, and the second execution task is executed, if the execution result is that the second execution task is executed successfully, subsequent tasks of the second task queue, i.e., the target task queue, are continued to be executed, and if the execution result is that the second execution task is executed unsuccessfully, the third task queue, i.e., the target task queue, is switched to, and the type of the current execution task in the third task queue is continued to be judged, if the type is a synchronous task, the behavior of the current execution task is simulated by software language, and the synchronous task is executed, if the execution is successful, the execution task in the third task queue is continued to be executed, otherwise the fourth task queue is switched to, until all task queues are traversed, and the execution task in the first task queue is returned to be executed. If the type of the current execution task is a non-synchronous type, the type of the current execution task is sent to hardware for execution.
[0073] It should be noted that traversing all task queues does not mean that all execution tasks in the task queue are executed successfully, when the execution is not successful, switch to the next task queue, so, repeat the loop to traverse all task queues.
[0074] It should be noted that if a non-synchronous task is encountered in the task queue, the hardware is sent and executed by the hardware.
[0075] In the embodiment of the application, by determining the task type of the second execution task, different processing is performed according to the task type, for a synchronous task, the synchronous behavior of the task is directly discarded and simulated; for a non-synchronous task, the task is submitted to the hardware for execution, avoiding deadlock when multiple processes use the device at the same time due to synchronization primitives.
[0076] In the embodiment of the application, a set of task queues submitted by multiple user processes is received; in the case that the execution task is a synchronous task, the synchronous task is simulated based on a software language to obtain a synchronization mechanism corresponding to the synchronous task; the synchronous task is scheduled based on the synchronization mechanism and a scheduling rule; wherein the scheduling rule is used to switch the task queue that does not meet the execution condition. In this way, the synchronization mechanism corresponding to the synchronous task is simulated by software to schedule the tasks in each task queue, so that each task is executed in turn according to the expected order of the user process, realizing software execution of the synchronous task. At the same time, the synchronous task that does not meet the execution condition is switched in real time according to the scheduling rule in the software simulation, avoiding waiting all the time, and further avoiding deadlock between processes when multiple processes use the device at the same time.
[0077] Figure 3 is a flowchart of a second embodiment of the synchronization task execution method provided by the application, as shown in Figure 3 , comprising:
[0078] Step 201, receiving a set of task queues submitted by multiple user processes.
[0079] Step 202, obtaining a first execution task from a first task queue in the set of task queues.
[0080] Step 301, parsing the first execution task in the multiple execution tasks to obtain a format corresponding to the first execution task.
[0081] Step 302, determining a task type of the first execution task based on the format corresponding to the first execution task.
[0082] The task type includes the synchronous task and the non-synchronous task.
[0083] It should be noted that the synchronous task and the non-synchronous task have respective corresponding formats, and the task type of the execution task is determined according to the format.
[0084] Optionally, the format of the executed task can include interface characteristics, synchronous component calling, execution state representation and the like during the execution of the task.
[0085] Here, the task type can be determined according to the correspondence between the format and the task type.
[0086] In the embodiment of the present application, the task type of the executed task is determined according to the inherent format of the executed task, the determination accuracy of the task type is improved, and a reliable basis is provided for subsequent task processing.
[0087] In step 203, if the first executed task is a synchronous task, the first executed task is simulated based on a software language, and a synchronous mechanism corresponding to the first executed task is realized.
[0088] In step 204, the executed tasks in the task queue set are executed based on the synchronous mechanism and a scheduling rule.
[0089] In another embodiment, if the first executed task is a non-synchronous task, the first executed task is sent to hardware.
[0090] The hardware is configured to execute the first executed task.
[0091] Here, after the non-synchronous task is sent to the hardware, a thread circulates to process a next executed task.
[0092] In the embodiment of the present application, a user process submits a task set, a scheduler receives the task set, a scheduler unpacking module parses the task set, the tasks are classified as synchronous tasks and non-synchronous tasks, and then the tasks are given to a scheduler scheduling module. The scheduler scheduling module receives the tasks and processes the tasks according to the task types. For the synchronous tasks, the tasks are directly discarded and the synchronous behaviors of the tasks are simulated. For the non-synchronous tasks, the tasks are submitted to hardware for execution, and the scheduler circulates to process a next task. In this way, the scheduler processes all the tasks submitted by the user process in parallel. Then, the behaviors of the synchronous tasks are simulated, the same semantics as the hardware synchronization primitives are realized, and the correctness of the synchronization is ensured. Since the synchronization primitives are no longer submitted to the hardware, the multiple processes simultaneously use the device and do not deadlock due to the synchronization primitives.
[0093] Figure 4 is a system structure schematic diagram of the method for implementing the synchronous scheduling task provided by the present application, as shown in Figure 4As shown, it includes a first user queue 401, a second user queue 402, a third user queue 403, a fourth user queue 404, a scheduler 405, a first hardware 406 and a second hardware 407. Specifically, the first user queue sends a first non-zero execution passing primitive (NZ-pass0) to the scheduler, the second user queue sends a second execution passing primitive (PASS1) to the scheduler, the third user queue sends a second non-zero execution passing primitive (NZ-PASS1) to the scheduler, the fourth user queue sends a first execution passing primitive (PASS0) to the scheduler, a depacketizing module in the scheduler parses NZ-pass0, PASS1, NZ-PASS1 and PASS0 execution tasks submitted by each user queue, determines the task type corresponding to each execution task, if it is a synchronous task, uses a scheduling module in the scheduler to directly reject the synchronous task and simulates the synchronous task by software; if it is a non-synchronous task, it is submitted to hardware execution, and the scheduler loops the next task.
[0094] In the embodiment of the application, the scheduler processes all tasks submitted by user processes in parallel. The scheduler rejects synchronous tasks in the task set and then simulates the behavior of the synchronous task to achieve the same semantics as the hardware synchronization primitive, thereby ensuring the correctness of the synchronization. Since the synchronization primitive corresponding to the synchronous task is no longer submitted to the hardware, the multiple processes will not deadlock due to the synchronization primitive when using the device at the same time.
[0095] The kernel driver is used to implement the above, and the upper-layer software does not need to be aware of it and can normally run without any modification, thereby having good compatibility with the existing software stack and being very friendly to users without limiting the use of multiple processes by users.
[0096] The synchronization task execution device provided by the application is described below, and the synchronization task execution device described below can be correspondingly referred to the synchronization task execution method described above.
[0097] Figure 5 is a structural schematic diagram of the synchronization task execution device provided by the application, as Figure 5 shown, the device includes the following:
[0098] The receiving module 510 is configured to receive a task queue set submitted by multiple user processes;
[0099] The obtaining module 520 is configured to obtain a first execution task from a first task queue in the task queue set;
[0100] The simulation module 530 is configured to simulate the first execution task based on a software language in the case that the first execution task is a synchronous task, and implement a synchronization mechanism corresponding to the first execution task;
[0101] The scheduling module 540 is configured to execute the execution tasks in the task queue set based on the synchronization mechanism and a scheduling rule, where the scheduling rule is used to switch the task queues in the task queue set.
[0102] In another embodiment, the scheduling module 540 is specifically configured to determine a first execution condition corresponding to the first execution task based on the synchronization mechanism, and execute the execution tasks in the task queue set based on the first execution condition and the scheduling rule.
[0103] In another embodiment, the scheduling module 540 is further specifically configured to: in a case where the first execution condition is met in the scheduler, determine, from the scheduling rule, that a scheduling strategy is a sequential execution strategy; execute a next execution task of the first execution task in the first task queue based on the sequential execution strategy; in a case where the first execution condition is not met in the scheduler, determine, from the scheduling rule, that the scheduling strategy is a switching strategy; switch the first task queue to a second task queue in the task queue set based on the switching strategy; and in a case where a second execution task in the second task queue is a synchronization task, execute the execution tasks in the task queue set based on an execution result of the second execution task.
[0104] In another embodiment, the scheduling module 540 is further specifically configured to: determine a target task queue based on the execution result of the second execution task; in a case where a current execution task in the target task queue is a synchronization task, sequentially traverse all the task queues in the task queue set based on an execution result of the current execution task; and in a case where the scheduler is rotated to the first task queue again, execute the execution tasks in the first task queue.
[0105] In another embodiment, after the first execution task is acquired from the first task queue in the task queue set, the synchronization task execution apparatus further includes a type determination module configured to: analyze the first execution task to obtain a format corresponding to the first execution task; and determine a task type of the first execution task based on the format corresponding to the first execution task, where the task type includes the synchronization task and a non-synchronization task.
[0106] In another embodiment, the synchronization task execution apparatus further includes a sending module specifically configured to: in a case where the first execution task is a non-synchronization task, send the first execution task to a hardware, where the hardware is configured to execute the first execution task.
[0107] In another embodiment, the simulation module 530 is specifically used to: encapsulate the first execution task based on the software language, and simulate the execution unit corresponding to the first execution task; and determine the synchronization mechanism corresponding to the first execution task based on the dependency relationship of the execution unit and the shared resource type of the execution unit.
[0108] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 6 As shown, the electronic device may include: a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a synchronous task execution method. This method includes: receiving a set of task queues submitted by multiple user processes; obtaining a first execution task from a first task queue in the task queue set; if the first execution task is a synchronous task, simulating the first execution task based on a software language to implement a synchronization mechanism corresponding to the first execution task; and executing the execution tasks in the task queue set based on the synchronization mechanism and scheduling rules; wherein the scheduling rules are used to switch task queues in the task queue set.
[0109] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0110] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer readable storage medium, and the computer program is executable by a processor to enable a computer to perform the synchronization task execution method provided by the above method, which comprises: receiving a task queue set submitted by a plurality of user processes; obtaining a first execution task from a first task queue in the task queue set; in a case where the first execution task is a synchronization task, simulating the first execution task based on a software language, and implementing a synchronization mechanism corresponding to the first execution task; and executing execution tasks in the task queue set based on the synchronization mechanism and a scheduling rule, wherein the scheduling rule is used to switch task queues in the task queue set.
[0111] In another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, which is executable by a processor to implement the synchronization task execution method provided by the above method, which comprises: receiving a task queue set submitted by a plurality of user processes; obtaining a first execution task from a first task queue in the task queue set; in a case where the first execution task is a synchronization task, simulating the first execution task based on a software language, and implementing a synchronization mechanism corresponding to the first execution task; and executing execution tasks in the task queue set based on the synchronization mechanism and a scheduling rule, wherein the scheduling rule is used to switch task queues in the task queue set.
[0112] The device embodiments described above are merely illustrative, wherein the units illustrated as separate components can or can not be physically separate, and the components illustrated as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. Those skilled in the art can understand and implement without creative labor.
[0113] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus necessary universal hardware platforms, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in terms of the contribution to the prior art, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform the methods described in the various embodiments or some parts of the embodiments.
[0114] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of synchronizing task execution, the method comprising: The application is applied to a scheduler, comprising: receiving a task queue set submitted by a plurality of user processes; obtaining a first execution task from a first task queue in the task queue set; in the case that the first execution task is a synchronous task, encapsulating the first execution task based on a software language, and simulating an execution unit corresponding to the first execution task; determining a synchronization mechanism corresponding to the first execution task based on a dependency relationship of the execution unit and a shared resource type of the execution unit; executing execution tasks in the task queue set based on the synchronization mechanism and a scheduling rule, wherein the scheduling rule is used to switch task queues in the task queue set.
2. The method of claim 1, wherein, The execution of the execution tasks in the task queue set based on the synchronization mechanism and the scheduling rule comprises: determining a first execution condition corresponding to the first execution task based on the synchronization mechanism; executing execution tasks in the task queue set based on the first execution condition and the scheduling rule.
3. The method of claim 2, wherein, The execution of the execution tasks in the task queue set based on the first execution condition and the scheduling rule comprises: in the case that the first execution condition is met in the scheduler, determining that a scheduling strategy is a sequential execution strategy from the scheduling rule; executing a next execution task of the first execution task in the first task queue based on the sequential execution strategy; in the case that the first execution condition is not met in the scheduler, determining that the scheduling strategy is a switching strategy from the scheduling rule; switching the first task queue to a second task queue in the task queue set based on the switching strategy; in the case that a second execution task in the second task queue is a synchronous task, executing execution tasks in the task queue set based on an execution result of the second execution task.
4. The method of claim 3, wherein, The execution of the execution tasks in the task queue set based on the execution result of the second execution task comprises: determining a target task queue based on the execution result of the second execution task; in the case that a current execution task in the target task queue is a synchronous task, sequentially traversing all task queues in the task queue set based on an execution result of the current execution task; in the case that the scheduler is rotated to the first task queue again, executing execution tasks in the first task queue.
5. The method of claim 1 to 4, wherein, After the first execution task is obtained from the first task queue in the task queue set, the method further comprises: parsing the first execution task to obtain a format corresponding to the first execution task; determining a task type of the first execution task based on the format corresponding to the first execution task, wherein the task type comprises a synchronous task and a non-synchronous task.
6. The method of claim 1 to 4, wherein, Further comprising: in the case that the first execution task is a non-synchronous task, sending the first execution task to hardware, wherein the hardware is used to execute the first execution task.
7. A synchronous task execution apparatus characterized by comprising: comprising: a receiving module configured to receive a task queue set submitted by a plurality of user processes; an obtaining module configured to obtain a first execution task from a first task queue in the task queue set; The simulation module is configured to, in a case where the first execution task is a synchronous task, encapsulate the first execution task based on a software language, simulate an execution unit corresponding to the first execution task, determine a synchronous mechanism corresponding to the first execution task based on a dependency relationship of the execution unit and a shared resource type of the execution unit. The scheduling module is configured to execute the execution tasks in the task queue set based on the synchronous mechanism and a scheduling rule, wherein the scheduling rule is used to switch the task queues in the task queue set.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor executes the computer program to implement the synchronous task execution method according to any one of claims 1 to 6. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the synchronous task execution method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Deadlock detection method and device
CN113360290A
Multi-task scheduling method, system and equipment based on resource queue management and medium
CN121029354A