A simulation scheduling method and system for activity diagrams
Through the simulation scheduling method and system for activity graphs, executable objects in the activity graph are parsed and task scheduling is used by the scheduler, which solves the problem of insufficient support for recursive calls and multi-threading in the prior art, and achieves efficient and stable simulation efficiency and logical expansion.
Patent Information
- Application Number
- CN202210948239.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-09
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-08-09
AI Technical Summary
The existing technology is prone to program crashes due to recursive calls and long-term simulation when simulating UML and SysML models, and lacks support for multi-threaded simulation, so it is impossible to effectively expand the running logic and implement breakpoint debugging.
A simulation scheduling method and system for activity graphs is proposed. By analyzing executable objects in the activity graph, using the scheduler to schedule the simulation tasks, supporting multi-threaded parallel execution, realizing the polling and time slice allocation of the virtual machine control scheduler.
It solves the problems of recursive calls and multi-threading support, improves simulation efficiency and stability, supports simulation breakpoint debugging and logical extension, and is suitable for complex UML and SysML active graph simulations.
Smart Images

Figure CN115454590B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of simulation scheduling, and in particular relates to a simulation scheduling method and system oriented to an activity graph. Background Art
[0002] With the increasing popularity of system modeling, or MBSE (Model-Based Systems Engineering is a formal method used to support requirements, design, analysis, and validation related to the development of complex systems), the demand for simulation of system modeling is also growing. However, there is a lack of in-depth research and application in the field of simulation-related technologies.
[0003] The operation process of the commonly used open source simulation engine implemented according to standard specifications such as fUML includes: simulation initialization and simulation execution. Simulation initialization generates simulation data and simulation execution objects based on the input UML and SysML models, and then inputs these contents into the simulation execution part to start simulation execution. The logic of simulation execution is that after the simulation engine runs the current node, it searches for subsequent execution nodes according to the actual structure of the UML and SysML models, and after finding the node, it passes in the Token data and directly calls the running function of the execution node to keep the simulation running.
[0004] Unified Modeling Language (UML), also known as unified modeling language or standard modeling language, is an OMG standard that began in 1997. It is a graphical language that supports modeling and software system development, providing modeling and visualization support for all stages of software development. SysML is a general-purpose graphical modeling language with a semantic basis for modeling system requirements, behaviors, structures, and parameters, representing a subset of UML.
[0005] The above method fully complies with the standard specifications and meets the semantic specifications of the model definition. However, since the node execution is performed by directly calling the running function of the execution node, when the simulated model object has an infinite loop or the simulation time is too long, the simulation method will cause the program to crash because the program call stack is too deep.
[0006] Secondly, this method does not have good support capabilities for multi-threaded simulation. This method does not fully consider the various requirements for multi-threaded program execution. There are various problems when performing true multi-threaded simulation, such as thread exceptions or data conflicts.
[0007] In addition, for some special UML and SysML model execution requirements, this method cannot complete the expansion of the operation logic well. Finally, this method cannot realize the addition of functions such as simulation run breakpoint debugging without comprehensive modification. It can be seen that although the above method can complete certain UML and SysML model simulation functions and conform to standard specifications, there are many problems in practical applications and need to be improved. Summary of the invention
[0008] In order to solve the above technical problems, this patent proposes a simulation scheduling method and system for activity diagrams.
[0009] The first aspect of the present invention discloses a simulation scheduling method for activity diagrams. The activity diagram is a UML activity diagram or a SysML activity diagram, and the method comprises: parsing a number of executable objects from the activity diagram, and determining the next executable task and the required simulation data based on the executable objects to execute the simulation process, and using a scheduler to schedule each task in the simulation process; wherein: the scheduler comprises a number of executable object schedulers, each of which corresponds to an executable object, and is used to schedule the process of the executable object, and each of which contains a number of threads; each of which comprises a number of task schedulers, each of which corresponds to a thread, and is used to schedule the thread, and each thread contains a number of tasks.
[0010] According to the method of the first aspect of the present invention, the activity diagram includes a plurality of execution nodes and a plurality of edges connecting the execution nodes, and the edges in the activity diagram represent the execution logic between the execution nodes; during the simulation process, each execution node sends a Token token to each subsequent output edge after completing the execution, and before each execution node starts execution, each edge of its predecessor input contains the Token token.
[0011] According to the method of the first aspect of the present invention, using the scheduler to schedule each task in the simulation process specifically includes: a virtual machine controls the execution scheduling of several schedulers, and the virtual machine polls each scheduler in turn in a linear order. When all schedulers have completed their respective execution scheduling, the virtual machine completes its execution scheduling; the scheduler schedules the next executed process in accordance with the linear order or random order, and allocates a time slice to each of the processes. When all processes have completed their respective execution scheduling, the scheduler completes its execution scheduling; wherein each process has an independent data space, and in the time slice of each process, a sub-segment is allocated to each of the several threads contained in the process for executing each task in the thread, and the scheduling of the several threads contained in the process is performed in accordance with the linear order or the random order.
[0012] According to the method of the first aspect of the present invention, executing each task in the thread specifically includes: in the task execution scheduling in the thread, maintaining a ready queue, an execution queue and a waiting queue for each task, and each task has a ready state, an execution state, a waiting state and a completion state; when executing the scheduling, first check whether there is an executable task in the execution queue, if so, execute the task directly; if not, check whether there is a ready task in the ready queue, if so, put the ready task into the execution queue; wherein, the overflowed executable tasks are put into the waiting queue, and when the ready queue, the execution queue and the waiting queue are all empty, the task scheduling of the thread is completed.
[0013] According to the method of the first aspect of the present invention, in the task execution scheduling in the thread, the newly created task is in the ready state, and when the newly created task meets the execution condition through scheduling, it is converted to the execution state. When the executable tasks in the execution queue overflow, the newly created task is placed in the waiting queue and converted to the waiting state. After the newly created task is executed, its state is changed to the completed state, and the virtual machine executes the deletion operation on the task in the completed state.
[0014] According to the method of the first aspect of the present invention, in the task execution scheduling in the thread, a preparation queue is also maintained for each task, and when the virtual machine is initialized, multiple starting nodes are placed in the preparation queue in reverse order, so that the execution logic of the multiple starting nodes meets the definition specifications of the UML activity diagram or the SysML activity diagram.
[0015] According to the method of the first aspect of the present invention, when there are multiple subsequent output nodes of any node, it is determined whether there is a sequence between the multiple subsequent output nodes. If so, the node tasks are executed in sequence; if not, a new thread is created for each subsequent output node, and the newly created thread node tasks are executed in parallel.
[0016] The second aspect of the present invention discloses a simulation scheduling system for activity diagrams. The activity diagram is a UML activity diagram or a SysML activity diagram, and the system includes: a simulation unit, configured to: parse a number of executable objects from the activity diagram, and determine the next executable task and the required simulation data based on the executable object to execute the simulation process; a scheduler, configured to: use the scheduler to schedule each task in the simulation process; wherein: the scheduler includes a number of executable object schedulers, each of the executable object schedulers corresponds to an executable object, and is used to schedule the process of the executable object, and each of the processes includes a number of threads; each of the executable object schedulers includes a number of task schedulers, each of the task schedulers corresponds to a thread, and is used to schedule the thread, and each thread includes a number of tasks.
[0017] According to the system of the second aspect of the present invention, the activity diagram includes a plurality of execution nodes and a plurality of edges connecting the execution nodes, and the edges in the activity diagram represent the execution logic between the execution nodes; during the simulation process, each execution node sends a Token token to each subsequent output edge after completing the execution, and before each execution node starts execution, each edge of its predecessor input contains the Token token.
[0018] According to the system of the second aspect of the present invention, using the scheduler to schedule each task in the simulation process specifically includes: a virtual machine controls the execution scheduling of a plurality of the schedulers, the virtual machine sequentially polls each scheduler in a linear order, and when all schedulers complete their respective execution scheduling, the virtual machine completes its execution scheduling;
[0019] The scheduler schedules the next executed process according to the linear order or the random order, and allocates a time slice to each of the processes. When all processes complete their respective execution scheduling, the scheduler completes its execution scheduling; wherein each process has an independent data space, and in the time slice of each process, a sub-segment is allocated to each of the several threads contained in the process for executing each task in the thread, and the scheduling of the several threads contained in the process is performed according to the linear order or the random order.
[0020] According to the system of the second aspect of the present invention, executing each task in the thread specifically includes: in the task execution scheduling in the thread, a ready queue, an execution queue and a waiting queue are maintained for each task, and each task has a ready state, an execution state, a waiting state and a completion state; when executing the scheduling, first check whether there is an executable task in the execution queue, if so, execute the task directly; if not, check whether there is a ready task in the ready queue, if so, put the ready task into the execution queue; wherein, the overflowed executable tasks are put into the waiting queue, and when the ready queue, the execution queue and the waiting queue are all empty, the task scheduling of the thread is completed.
[0021] According to the system of the second aspect of the present invention, in the task execution scheduling in the thread, the newly created task is in the ready state, and when the newly created task meets the execution condition through scheduling, it is converted to the execution state. When the executable tasks in the execution queue overflow, the newly created task is put into the waiting queue and converted to the waiting state. After the newly created task is executed, its state is changed to the completed state, and the virtual machine executes the deletion operation of the task in the completed state.
[0022] According to the system of the second aspect of the present invention, in the task execution scheduling in the thread, a preparation queue is also maintained for each task. When initializing the virtual machine, multiple starting nodes are placed in the preparation queue in reverse order, so that the execution logic of the multiple starting nodes meets the definition specifications of the UML activity diagram or the SysML activity diagram.
[0023] According to the system of the second aspect of the present invention, when any node has multiple subsequent output nodes, it is determined whether there is a sequence between the multiple subsequent output nodes. If so, the node tasks are executed in sequence; if not, a new thread is created for each subsequent output node, and the newly created thread node tasks are executed in parallel.
[0024] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the activity diagram-oriented simulation scheduling method described in any one of the first aspects of the present disclosure are implemented.
[0025] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the activity diagram-oriented simulation scheduling methods described in the first aspect of the present disclosure.
[0026] In summary, the technical solution provided by the present invention proposes a simulation scheduling solution for activity diagrams from the perspective of actual needs and applications, which solves the problems of recursive calls, multi-threaded support, simulation breakpoint debugging, etc. in the prior art. It has good scalability and can be used for complex UML and SysML activity diagram simulations. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 A schematic diagram of simulation scheduling according to an embodiment of the present invention;
[0029] Figure 2a-2c An example of an activity diagram for characterizing the direction of Token transfer according to an embodiment of the present invention;
[0030] Figure 3 A schematic diagram of the structure of a virtual machine according to an embodiment of the present invention;
[0031] Figure 4 A schematic diagram of task execution on each time slice according to an embodiment of the present invention;
[0032] Figure 5 The figure is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0034] The first aspect of the present invention discloses a simulation scheduling method for activity diagrams. The activity diagram is a UML activity diagram or a SysML activity diagram, and the method comprises: parsing a number of executable objects from the activity diagram, and determining the next executable task and the required simulation data based on the executable objects to execute the simulation process, and using a scheduler to schedule each task in the simulation process; wherein: the scheduler comprises a number of executable object schedulers, each of which corresponds to an executable object, and is used to schedule the process of the executable object, and each of which contains a number of threads; each of which comprises a number of task schedulers, each of which corresponds to a thread, and is used to schedule the thread, and each thread contains a number of tasks.
[0035] The operation process of UML and SysML simulation engines is divided into three key steps. The first is that the user provides the UML or SysML model to the simulation engine, and the simulation engine performs a preliminary analysis of the model to generate a list of executable objects, representing various node elements in the simulation diagram model. Secondly, the executable objects are analyzed according to the simulation execution status to generate the next executable task and the simulation data required in the simulation. After completing the above steps, the simulation scheduling algorithm finally schedules the tasks in the simulation to realize the operation logic of various simulation models. There are already related technologies for simulation model analysis. This solution is not limited to using the following simulation engine to implement the analysis process, and any method in the existing technology can also be used to implement the analysis of the simulation model.
[0036] Figure 1 Schematic diagram of simulation scheduling according to an embodiment of the present invention; Figure 1 As shown, the simulation engine receives the input model (activity diagram), generates executable objects through internal parsing, and generates a scheduler for simulation based on the executable objects. The key structure of simulation execution is the scheduler. The scheduler is composed of multiple executable object schedulers, and each executable object scheduler schedules and manages the executable objects parsed by the simulation engine. Each scheduler can also have a sub-scheduler to meet the execution of mutual calls of simulation models. In order to enhance the scheduling and management capabilities of executable objects, each executable object scheduler has multiple task schedulers to simulate the running effect of executing tasks on multiple threads. When the scheduler completes the execution of all tasks, it means that the simulation of the model corresponding to the scheduler ends. When all schedulers complete the execution, it means that all simulations end. The important structures related to the scheduler runtime are the task generator and the data generator. The task generator generates the next task to be executed based on the execution of the current simulation, and the data generator parses the executable object to obtain the corresponding data information when the simulation needs data to support the simulation operation.
[0037] In some embodiments, the activity diagram includes a plurality of execution nodes and a plurality of edges connecting the execution nodes, and the edges in the activity diagram represent the execution logic between the execution nodes; during the simulation process, each execution node sends a Token to each subsequent output edge after completing the execution, and before each execution node starts execution, each edge of its preceding input contains the Token.
[0038] In activity diagram simulation, a key concept is token. The running node will issue tokens to all subsequent output edges. For a node to be executed, it can only be executed after all input edges have tokens. Figure 2a In the activity diagram shown in the figure, after node 1 is executed, the number of tokens on the edge of node 3 is insufficient. Therefore, node 2 must be executed and issued a token before all the edges of node 3 meet the token requirements before it can run. Figure 2b In the activity diagram shown, after node 1 is executed, tokens are issued to the two subsequent edges in sequence, so that the branch where 2 is located can be executed only after the branch where 3 is located is executed. The execution of this part is sequential execution, and there is no parallel execution. Figure 2c The activity diagram shown uses a Fork node, which leads to parallel execution of the activity diagram. The execution of nodes 2 and 3 is no longer in order, but will be executed simultaneously.
[0039] In some embodiments, using the scheduler to schedule each task in the simulation process specifically includes: a virtual machine controls the execution scheduling of several schedulers, and the virtual machine polls each scheduler in turn in a linear order. When all schedulers complete their respective execution scheduling, the virtual machine completes its execution scheduling; the scheduler schedules the next executed process in the linear order or random order, and allocates a time slice to each of the processes. When all processes complete their respective execution scheduling, the scheduler completes its execution scheduling; wherein each process has an independent data space, and in the time slice of each process, a sub-segment is allocated to each of the several threads contained in the process for executing each task in the thread, and the scheduling of the several threads contained in the process is performed in the linear order or the random order.
[0040] In order to understand the concept of simulation scheduling algorithm more intuitively, the structure of simulation scheduler is mapped with the structure of operating system to facilitate understanding and development. The concept corresponding to scheduler is virtual machine, the concept corresponding to executable object scheduler is virtual process, and the concept corresponding to task scheduler is virtual thread. All simulation scheduling is performed inside the virtual machine. By providing an independent execution environment, the virtual machine uses the concepts of virtualization and layering to simulate the execution environment of various UML and SysML models respectively, making it possible to simulate models with various different logics. There are various processes inside the virtual machine to simulate the parallel execution of multiple simulation executable objects, and the executable objects are scheduled and managed through virtual processes. There are virtual threads inside the virtual process, which represent the multi-threaded concept inside the executable object, such as the multi-threaded model corresponding to the Fork node. Virtual machine, virtual process, and virtual thread together constitute the simulation scheduler.
[0041] Specifically, the simulation operation is performed by a simulation virtual machine (such as Figure 3 As shown in the figure, the simulation virtual machine is the top-level structure of the simulation operation. The simulation virtual machine simulates the structure of the computer system, schedules the virtual processes, virtual threads and tasks running inside, and makes them run according to the expected logic. The simulation virtual machine provides simulation functions of various executable objects to the outside. The interior of the simulation virtual machine is composed of multiple schedulers, which are responsible for managing the execution process of the virtual process. Each scheduler is responsible for different scheduling logics, thereby different virtual process operation logics can be divided, which is convenient for expanding the scheduling logic and managing the internal virtual processes. The simulation structure corresponding to each actual simulation graph, such as the activity graph and the state graph, is a virtual process. Each virtual process represents the operation of a graph. There can be a parent-child relationship between processes, which represents the operation logic of the graph call graph. Each process has one or more virtual threads that execute tasks. The parent process must wait for the child process to complete before it can end, but the parent process can directly end the operation of the child process through the termination method to forcibly terminate the simulation.
[0042] In some embodiments, executing each task in the thread specifically includes:
[0043] In the task execution scheduling in the thread, a ready queue, an execution queue and a waiting queue are maintained for each task, and each task has a ready state, an execution state, a waiting state and a completion state; when executing the scheduling, first check whether there is an executable task in the execution queue, if so, execute the task directly; if not, check whether there is a ready task in the ready queue, if so, put the ready task into the execution queue; wherein, the overflowed executable tasks are put into the waiting queue, and when the ready queue, the execution queue and the waiting queue are all empty, the task scheduling of the thread is completed.
[0044] In some embodiments, in the task execution scheduling in the thread, the newly created task is in the ready state, and when the newly created task meets the execution condition through scheduling, it is converted to the execution state. When the executable tasks in the execution queue overflow, the newly created task is placed in the waiting queue and converted to the waiting state. After the newly created task is executed, its state is changed to the completed state, and the virtual machine executes the deletion operation on the task in the completed state.
[0045] Virtual threads have the responsibility of task execution and management, and are the most basic abstract concept of simulated virtual machines. The core concept of virtual thread execution is to use a single thread to simulate multiple threads. There are multiple task queues inside the virtual thread, representing tasks in different states, including Ready queue, Changed queue, Prepared queue, Running queue and Waiting queue, and manage the state transition of tasks according to the specified logic. When all tasks of the thread are executed, they are destroyed by the upper virtual process. The actual simulation object is the task. The task of the simulated virtual machine is to execute and manage tasks and output the required results. The structure corresponding to the task and the simulation model is the execution node in each diagram. Each task has 5 states, namely Ready, Running and Waiting. After meeting the corresponding conditions, the virtual thread manages tasks in different states. The virtual machine execution adopts the concept of sliced execution. Multiple schedulers in the virtual machine have a slice of execution time each time. In the scheduler (such as Figure 4 As shown in the figure, tick represents time slice), each virtual process also has a corresponding execution segment. In a virtual process, each thread has an execution segment. In a virtual thread, each task in the Running state also has an execution segment.
[0046] The operation process of the simulation virtual machine is mainly the management of the simulation scheduler. The virtual machine polls each scheduler in a linear order. If all schedulers have completed execution, the virtual machine completes execution. Since different virtual processes require different scheduling logic, different schedulers are abstracted in the virtual machine to implement different scheduling algorithms.
[0047] The main responsibility of the scheduler is to manage virtual processes. Different schedulers have different strategies for selecting the next virtual process to execute. They can schedule in a linear order or in a random order. Each virtual process has a fragment for task execution. When all virtual processes are completed, the execution of the scheduler ends.
[0048] The virtual process is responsible for managing virtual threads. There can be multiple threads in a process, and each process has an independent data space to avoid data interference. The virtual process allocates a segment to each thread in each time slice to execute the tasks in the thread. According to the requirements, the management of threads can be executed in linear or random order to meet the logical simulation requirements of different UML and SysML models. When all threads complete execution, the execution of the process ends.
[0049] The virtual thread is responsible for managing tasks, including the Ready queue, the Running queue, and the Waiting queue. There are five states for tasks, namely Ready, Running, Waiting, and Finished. Each time a virtual thread executes in the current segment, it traverses the queue according to the logic in the figure below to execute the corresponding task. After starting the virtual machine, first check the Running queue to see if there are any executable tasks. If there are executable tasks, execute the tasks. If the task status changes after execution, change the task to the target state after completing the execution. If the Running queue is empty, start checking the Ready queue. If the Ready queue is not empty, take out a task and put it into the Running queue. If the thread is still in the execution state, return to the beginning and loop again. When the Running queue, Ready queue, and Waiting queue are all empty, the virtual thread completes execution.
[0050] Each Task is divided into Ready, Running, Waiting and Finished states. A newly created task is in the Ready state. When the conditions are met, the scheduler converts it to the Running state. The execution of the task can convert the task to the Waiting state or the Finished state, depending on the execution logic within the task. The state transitions of other parts are completed by the virtual machine. When the task is in the Waiting state, the task can only be converted from the Waiting state to the Running state when the scheduler receives the corresponding event. When the task is in the Finished state, the virtual machine will delete the task. The above state transitions constitute the complete task operation logic.
[0051] In some embodiments, in the task execution scheduling in the thread, a preparation queue is also maintained for each task. When initializing the virtual machine, multiple starting nodes are placed in the preparation queue in reverse order, so that the execution logic of the multiple starting nodes meets the definition specifications of the UML activity diagram or the SysML activity diagram.
[0052] In some embodiments, when there are multiple subsequent output nodes for any node, it is determined whether there is a sequence between the multiple subsequent output nodes. If so, the node tasks are executed in sequence; if not, a new thread is created for each subsequent output node, and the newly created thread node tasks are executed in parallel.
[0053] When initializing the virtual machine to run, multiple starting node tasks can be placed in the Prepared queue in reverse order. After that, the simulation virtual machine can be run according to normal logic to obtain multiple starting node execution logics and meet the specifications defined by the UML and SysML models. For the situation shown in the figure below, when Node1 completes the run and it is found that there are multiple nodes running later, the logic is executed in the order in which the branch creation model is created. In order to meet the requirements, Node2 is placed in the Running queue, and Node3 and other subsequent nodes are placed in the Prepared queue to continue the simulation execution, which can meet the simulation requirements of multiple subsequent nodes. If the Fork node encounters multiple subsequent parallel branches, it will notify the Virtual Process to create multiple Virtual Threads as needed to simulate multi-threaded operation to meet the requirements of parallel execution.
[0054] In summary, the method of the first aspect of the present invention takes into account the support of simulation scheduling for multi-threading, which can provide higher efficiency; at the same time, it solves all inherent problems related to simulation in open source methods and provides a basis for simulation; further, the method can also easily expand the functions of breakpoint debugging and single-step debugging, which can improve the efficiency of designers in system simulation verification; in addition, the method has high logical scalability, and each component can be customized according to actual needs to meet the simulation execution logic in different situations. For example, by changing the execution logic of the task scheduler, it is possible to switch from activity diagram simulation scheduling to state diagram simulation scheduling, or by modifying the scheduler, it is possible to switch from sequential execution to asynchronous execution to complete multi-thread support.
[0055] The second aspect of the present invention discloses a simulation scheduling system for activity diagrams. The activity diagram is a UML activity diagram or a SysML activity diagram, and the system includes: a simulation unit, configured to: parse a number of executable objects from the activity diagram, and determine the next executable task and the required simulation data based on the executable object to execute the simulation process; a scheduler, configured to: use the scheduler to schedule each task in the simulation process; wherein: the scheduler includes a number of executable object schedulers, each of the executable object schedulers corresponds to an executable object, and is used to schedule the process of the executable object, and each of the processes includes a number of threads; each of the executable object schedulers includes a number of task schedulers, each of the task schedulers corresponds to a thread, and is used to schedule the thread, and each thread includes a number of tasks.
[0056] According to the system of the second aspect of the present invention, the activity diagram includes a plurality of execution nodes and a plurality of edges connecting the execution nodes, and the edges in the activity diagram represent the execution logic between the execution nodes; during the simulation process, each execution node sends a Token token to each subsequent output edge after completing the execution, and before each execution node starts execution, each edge of its predecessor input contains the Token token.
[0057] According to the system of the second aspect of the present invention, using the scheduler to schedule each task in the simulation process specifically includes: a virtual machine controls the execution scheduling of a plurality of the schedulers, the virtual machine sequentially polls each scheduler in a linear order, and when all schedulers complete their respective execution scheduling, the virtual machine completes its execution scheduling;
[0058] The scheduler schedules the next executed process according to the linear order or the random order, and allocates a time slice to each of the processes. When all processes complete their respective execution scheduling, the scheduler completes its execution scheduling; wherein each process has an independent data space, and in the time slice of each process, a sub-segment is allocated to each of the several threads contained in the process for executing each task in the thread, and the scheduling of the several threads contained in the process is performed according to the linear order or the random order.
[0059] According to the system of the second aspect of the present invention, executing each task in the thread specifically includes: in the task execution scheduling in the thread, a ready queue, an execution queue and a waiting queue are maintained for each task, and each task has a ready state, an execution state, a waiting state and a completion state; when executing the scheduling, first check whether there is an executable task in the execution queue, if so, execute the task directly; if not, check whether there is a ready task in the ready queue, if so, put the ready task into the execution queue; wherein, the overflowed executable tasks are put into the waiting queue, and when the ready queue, the execution queue and the waiting queue are all empty, the task scheduling of the thread is completed.
[0060] According to the system of the second aspect of the present invention, in the task execution scheduling in the thread, the newly created task is in the ready state, and when the newly created task meets the execution condition through scheduling, it is converted to the execution state. When the executable tasks in the execution queue overflow, the newly created task is put into the waiting queue and converted to the waiting state. After the newly created task is executed, its state is changed to the completed state, and the virtual machine executes the deletion operation of the task in the completed state.
[0061] According to the system of the second aspect of the present invention, in the task execution scheduling in the thread, a preparation queue is also maintained for each task. When initializing the virtual machine, multiple starting nodes are placed in the preparation queue in reverse order, so that the execution logic of the multiple starting nodes meets the definition specifications of the UML activity diagram or the SysML activity diagram.
[0062] According to the system of the second aspect of the present invention, when any node has multiple subsequent output nodes, it is determined whether there is a sequence between the multiple subsequent output nodes. If so, the node tasks are executed in sequence; if not, a new thread is created for each subsequent output node, and the newly created thread node tasks are executed in parallel.
[0063] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the activity diagram-oriented simulation scheduling method described in any one of the first aspects of the present disclosure are implemented.
[0064] Figure 5 is a structural diagram of an electronic device according to an embodiment of the present invention, such as Figure 5As shown, the electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, near field communication (NFC) or other technologies. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covered on the display screen, or a button, a trackball or a touch pad set on the housing of the electronic device, or an external keyboard, touch pad or mouse, etc.
[0065] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a structural diagram of the part related to the technical solution of the present disclosure, and does not constitute a limitation on the electronic device to which the technical solution of the present application is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0066] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the activity diagram-oriented simulation scheduling methods described in the first aspect of the present disclosure.
[0067] In summary, the technical solution provided by the present invention proposes a simulation scheduling solution for activity diagrams from the perspective of actual needs and applications, which solves the problems of recursive calls, multi-threaded support, simulation breakpoint debugging, etc. in the prior art. It has good scalability and can be used for complex UML and SysML activity diagram simulations.
[0068] Please note that the technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above-mentioned embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several variations and improvements can be made, which all belong to the scope of protection of the present application. Therefore, the scope of protection of the patent in this application shall be based on the attached claims.
Claims
1. A simulation scheduling method for activity diagrams, characterized in that: The activity diagram is a UML activity diagram or a SysML activity diagram, and the method comprises: A plurality of executable objects are parsed from the activity diagram, and the next executable task and the required simulation data are determined based on the executable objects to execute the simulation process, and the various tasks in the simulation process are scheduled by a scheduler; wherein: The scheduler includes several executable object schedulers, each of which corresponds to an executable object and is used to schedule the process of the executable object, and each of the processes includes several threads; each of the executable object schedulers includes several task schedulers, each of which corresponds to a thread and is used to schedule the thread, and each thread includes several tasks.
2. The activity diagram-oriented simulation scheduling method according to claim 1, characterized in that: The activity diagram includes a plurality of execution nodes and a plurality of edges connecting the execution nodes. The edges in the activity diagram represent the execution logic between the execution nodes. During the simulation process, each execution node sends a Token to each edge of the subsequent output after completing the execution, and before each execution node starts the execution, each edge of its preceding input contains the Token.
3. The activity diagram-oriented simulation scheduling method according to claim 2, characterized in that: Using the scheduler to schedule each task in the simulation process specifically includes: The execution scheduling of the plurality of schedulers is controlled by a virtual machine, and the virtual machine polls each scheduler in turn in a linear order. When all schedulers have completed their respective execution scheduling, the virtual machine completes its execution scheduling; The scheduler schedules the next executed process according to the linear order or random order, and allocates a time slice to each of the processes. When all the processes complete their respective execution scheduling, the scheduler completes its execution scheduling; Each process has an independent data space. In the time slice of each process, a sub-segment is allocated to each of the several threads contained in the process for executing each task in the thread. The scheduling of the several threads contained in the process is performed in accordance with the linear order or the random order.
4. The activity diagram-oriented simulation scheduling method according to claim 3, characterized in that: Executing each task in the thread specifically includes: In the task execution scheduling in the thread, a ready queue, an execution queue and a waiting queue are maintained for each task, and each task has a ready state, an execution state, a waiting state and a completion state; When executing scheduling, first check whether there is an executable task in the execution queue. If so, execute the task directly; if not, check whether there is a ready task in the ready queue. If so, put the ready task into the execution queue; wherein, the overflowed executable tasks are put into the waiting queue, and when the ready queue, the execution queue and the waiting queue are all empty, the task scheduling of the thread is completed.
5. The activity diagram-oriented simulation scheduling method according to claim 4, characterized in that: In the task execution scheduling in the thread, the newly created task is in the ready state. When the newly created task meets the execution condition through scheduling, it is converted to the execution state. When the executable tasks in the execution queue overflow, the newly created task is put into the waiting queue and converted to the waiting state. After the newly created task is executed, its state is changed to the completed state, and the virtual machine executes the deletion operation of the task in the completed state.
6. The activity diagram-oriented simulation scheduling method according to claim 5, characterized in that: In the task execution scheduling in the thread, a preparation queue is also maintained for each task. When initializing the virtual machine, multiple starting nodes are placed in the preparation queue in reverse order, so that the execution logic of the multiple starting nodes meets the definition specifications of the UML activity diagram or the SysML activity diagram.
7. The activity diagram-oriented simulation scheduling method according to claim 6, characterized in that: When there are multiple subsequent output nodes for any node, determine whether there is a sequence between the multiple subsequent output nodes. If yes, execute the node tasks in the sequence. If not, a new thread is created for each subsequent output node, and the newly created thread node tasks are executed in parallel.
8. A simulation scheduling system for activity diagrams, characterized in that: The activity diagram is a UML activity diagram or a SysML activity diagram, and the system includes: A simulation unit is configured to: parse a plurality of executable objects from the activity diagram, and determine a next executable task and required simulation data based on the executable objects to execute a simulation process; The scheduler is configured to: use the scheduler to schedule each task in the simulation process; wherein: the scheduler includes a plurality of executable object schedulers, each of the executable object schedulers corresponds to an executable object, and is used to schedule the process of the executable object, and each of the processes includes a plurality of threads; each of the executable object schedulers includes a plurality of task schedulers, each of the task schedulers corresponds to a thread, and is used to schedule the thread, and each thread includes a plurality of tasks.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the activity diagram-oriented simulation scheduling method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the activity diagram-oriented simulation scheduling method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and system for visually displaying simulation execution
CN114090185A
Task management device and method, operation judgment device and method, and program to be judged
CN1643498A