An Embedded System Simulation Method and Device Supporting Multiple Timing Constraints
By establishing embedded system simulation methods with multiple timing constraints, the problem that traditional simulation methods cannot describe the relationship between complex embedded system tasks is solved, and more reliable simulation results are achieved, supporting modeling and simulation of multiple task types.
Patent Information
- Application Number
- CN202210882889.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-07-26
AI Technical Summary
Traditional simulation methods cannot accurately characterize the dependencies between tasks in complex embedded systems, especially the execution jitter of random tasks and occasional tasks, resulting in insufficient reliability of simulation results and cannot meet the timing analysis requirements of safety-critical embedded systems.
Establish a task model, define task trigger relationship, communication model, resource access control model and data access control model, and simulate the embedded system with simulation parameters, supporting multiple timing constraints for periodic tasks, occasional tasks, random tasks and event-triggered tasks.
It improves the reliability of simulation results, can describe the relationship between tasks in complex embedded systems, supports task release jitter, execution jitter, priority relationship, etc., and the method is simple and easy to implement.
Smart Images

Figure CN116186959B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer applications, and in particular to an embedded system simulation method and device supporting multiple timing constraints. Background Art
[0002] Embedded systems are widely used in all aspects of human life. In safety-critical embedded systems such as aviation control, automotive electronics, high-precision industrial control, and medical equipment, the execution of various tasks in the system is subject to strict time constraints. Timing anomalies can have devastating effects on the system, leading to serious loss of life and property. Therefore, safety-critical embedded systems require thorough demonstration of timing correctness. Current embedded system timing simulation tools often abstract the system into independent periodic tasks, simulate them under a specified scheduling algorithm, and determine whether tasks have timed out. This analysis approach often suffers from insufficient model description capabilities when applied to complex embedded systems, failing to accurately characterize the dependencies between tasks in complex embedded systems. Furthermore, in addition to periodic tasks, real embedded systems also include random and sporadic tasks. The generation of periodic tasks is influenced by the actual system operation and is not strictly periodic. Traditional simulation methods cannot describe these random and sporadic tasks and cannot characterize the jitter during system execution. These issues with traditional simulation methods lead to unreliable simulation results, limiting the application scenarios for timing analysis through simulation.
[0003] For the above problems, no effective solutions have been proposed yet. Summary of the Invention
[0004] The embodiments of the present invention provide an embedded system simulation method and apparatus supporting multiple timing constraints, so as to at least solve the technical problem that traditional simulation methods cannot describe the relationship between complex embedded system tasks.
[0005] According to one aspect of an embodiment of the present invention, a method for simulating an embedded system supporting multiple timing constraints is provided, comprising: establishing a task model for the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks, and event-triggered tasks; defining task triggering relationships; defining an inter-task communication model; defining a system resource model; defining a task resource access control model; defining a data access control model; setting simulation parameters; and simulating the embedded system based on the task model, the task triggering relationships, the inter-task communication model, the system resource model, the task resource access control model, the data access control model, and the simulation parameters. The simulation processing comprises: at the beginning of each simulation step, determining whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined based on the total simulation duration and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, simulating the simulation step, and sequentially executing task release operations, job scheduling, resource allocation, data allocation, job message generation, job dependency messages, job generated data, job dependency data, and resource recovery operations; and terminating the simulation if the current number of simulation steps is greater than the number of simulations.
[0006] Optionally, establishing a task model for the embedded system includes: abstracting the task model based on the embedded system, wherein the task model is expressed as follows:
[0007]
[0008] Where C represents the worst-case execution time of the task; D represents the task deadline; T represents the period of the periodic task or the minimum arrival interval of the sporadic task; P represents the task priority; SYNC represents the synchronization type of the task; et represents the task execution time jitter; srt represents the time when the task first releases the job; Θ represents the set of random task release times, Θ = {rt1, ..., rt n}; rj represents the task release job time jitter; type represents the task type; PT represents the periodic task; ST represents the occasional task; AT represents the random task; ET represents the event-triggered task.
[0009] Optionally, a task triggering relationship is defined, including: a task releasing job triggers another task releasing job after execution is completed, wherein the task triggering relationship is defined as:
[0010]
[0011] Among them, τ k , τ j Represents τ i The task triggered by the job; atk Represents τ i Job execution at k Trigger task after time τ k ;at j Represents τ i Job execution at j Trigger task after time τ j ; C i Represents the task τ i The worst-case execution time.
[0012] Optionally, define an inter-task communication model, including: during the execution of a task, a dependency on a message is generated by another task; when the message on which the task depends exists, the task continues to execute; otherwise, it is blocked until the message arrives; wherein, when the synchronization type of the task is true, a job released by the task will be blocked after generating a message until the message generated by the task is consumed by another job; and when the synchronization type of the task is false, a job released by the task will continue to execute without waiting for a return command after generating a message;
[0013] Among them, the task τ i The expression that generates the message is as follows:
[0014]
[0015] Among them, mn represents the name of the job generating the message; mt represents the time when the job generates the message; C i Represents the task τ i Worst-case execution time;
[0016] The job depends on multiple messages during execution, and the task τ i The expressions that depend on messages during execution are as follows:
[0017]
[0018] Among them, dmn represents the name of the job dependency message; dmt represents the time of the job dependency message; C i Represents the task τ i The worst-case execution time.
[0019] Optionally, the expression of the system resource model is as follows:
[0020] ω={name,num}
[0021] Where ω represents the resource being applied for; name represents the name of the resource being applied for; and num represents the number of resources being applied for.
[0022] Optionally, the task resource access control model is expressed as follows:
[0023]
[0024] Among them, ω i ′ represents the resources obtained by the task application; τ i Indicates the task of applying for resources; ω indicates the resource being applied for; num indicates the number of resources applied for.
[0025] Optionally, define a data access control model, including: Task τ i Resources obtained through application i ′ becomes data, in τ i After the execution is completed, i ′ is treated as other tasks τ j , τ k Resources i Use; where, when τ j Read res i When, res i At the same time, τ k Read; when τ j Write res i When res i Lock, lock successfully and continue to execute, if in res i Locked period τ k Need to use res i , τ k Will be blocked, after the write operation is completed τ j Release res i , then res i τ k Use; when all use res i After the task is completed, release res i , then the recycling task τ i Resources applied for;
[0026] Among them, the task τ k The expression of the model for reading data is as follows:
[0027]
[0028] Among them, ω i ′ represents the task τ i The resources applied for; rst represents the task τ k The time to start reading resources; ret represents the task τ k The time when reading resources ends;
[0029] Task τ k The expression of the model for writing data is as follows:
[0030]
[0031] Among them, ω i ′ represents the task τ i The resources applied for; wst represents the task τ k The time to start writing resources; wet represents the task τ k The time when writing the resource was completed.
[0032] Optionally, the simulation parameters include total simulation duration, simulation step length and task scheduling algorithm.
[0033] Optionally, the calculation expression of the simulation times is as follows:
[0034] sc=T / S
[0035] Wherein, sc represents the number of simulations; T represents the total simulation time; and S represents the simulation step size.
[0036] According to another aspect of an embodiment of the present invention, there is also provided an embedded system simulation device supporting multiple timing constraints, comprising: an establishment module for establishing a task model of the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks; a first definition module for defining task triggering relationships; a second definition module for defining an inter-task communication model; a third definition module for defining a system resource model; a fourth definition module for defining a task resource access control model; a fifth definition module for defining a data access control model; a setting module for setting simulation parameters; a simulation processing module for defining the task model, the task triggering relationships, the inter-task communication model, the task resource access control ... The embedded system is simulated using the system resource model, the task resource access control model, the data access control model and the simulation parameters; wherein the simulation processing includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined based on the total simulation time and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, simulating the simulation steps, and sequentially executing task release operations, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations; if the current number of simulation steps is greater than the number of simulations, the simulation ends.
[0037] In an embodiment of the present invention, a task model of an embedded system is established, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks; task triggering relationships are defined; an inter-task communication model is defined; a system resource model is defined; a task resource access control model is defined; a data access control model is defined; simulation parameters are set; and the embedded system is simulated according to the task model, task triggering relationships, inter-task communication model, system resource model, task resource access control model, data access control model and simulation parameters; wherein the simulation processing includes: at the beginning of each simulation step, determining whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation time and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, then simulating the simulation step, and executing task release jobs, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations in sequence; if the current number of simulation steps is greater than the number of simulations, then the simulation ends. That is to say, the embodiments of the present invention can support the simulation of embedded systems with multiple timing constraints, can model and simulate complex embedded systems, and support the simulation of the release jitter, execution jitter, priority relationship, AND constraint, OR constraint, Fork / Join concurrent execution process, task deadline, task trigger relationship, etc. of embedded system tasks, thereby solving the technical problem that traditional simulation methods cannot describe the relationship between complex embedded system tasks, achieving the goal of improving the reliability of simulation results, and at the same time having the technical effects of simple method, strong description ability and easy implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0039] Figure 1 A flowchart of an embedded system simulation method supporting multiple timing constraints provided by an embodiment of the present invention;
[0040] Figure 2 Flowchart of the parallel execution process of task τ1 Fork / Join provided in an embodiment of the present invention;
[0041] Figure 3 A simulation flow chart within a single simulation step provided by an embodiment of the present invention;
[0042] Figure 4 A schematic diagram of an embedded system simulation device supporting multiple timing constraints provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions 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 embodiments described 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 efforts should fall within the scope of protection of the present invention.
[0044] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present invention are used to distinguish different objects rather than to limit a specific order.
[0045] According to one aspect of an embodiment of the present invention, a method for simulating an embedded system that supports multiple timing constraints is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0046] Figure 1 The flowchart of the embedded system simulation method supporting multiple timing constraints provided by the embodiment of the present invention is as follows: Figure 1 As shown, the method includes the following steps:
[0047] Step S102: establishing a task model for the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks, and event-triggered tasks;
[0048] Step S104, defining task triggering relationships;
[0049] The above task triggering relationship can represent the predecessor constraint relationship between tasks.
[0050] Step S106, defining an inter-task communication model;
[0051] Step S108, defining a system resource model;
[0052] Step S110, defining a task resource access control model;
[0053] Step S112 , defining a data access control model; the data access control model may represent AND constraints between tasks and / or OR constraints between tasks.
[0054] Step S114, setting simulation parameters; the simulation parameters include but are not limited to total simulation duration, simulation step length and task scheduling algorithm.
[0055] Step S116, simulate the embedded system according to the task model, task trigger relationship, inter-task communication model, system resource model, task resource access control model, data access control model and simulation parameters; wherein, the simulation processing includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation time and simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, then simulate the simulation steps, and execute task release jobs, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations in sequence; if the current number of simulation steps is greater than the number of simulations, then the simulation ends.
[0056] In an optional implementation, the calculation expression for the above simulation times is as follows:
[0057] sc=T / S
[0058] Among them, sc represents the number of simulations; T represents the total simulation time; S represents the simulation step size.
[0059] In an embodiment of the present invention, a task model of an embedded system is established, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks; task triggering relationships are defined; an inter-task communication model is defined; a system resource model is defined; a task resource access control model is defined; a data access control model is defined; simulation parameters are set; and the embedded system is simulated according to the task model, task triggering relationships, inter-task communication model, system resource model, task resource access control model, data access control model and simulation parameters; wherein the simulation processing includes: at the beginning of each simulation step, determining whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation time and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, then simulating the simulation step, and executing task release jobs, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations in sequence; if the current number of simulation steps is greater than the number of simulations, then the simulation ends. That is to say, the embodiments of the present invention can support the simulation of embedded systems with multiple timing constraints, can model and simulate complex embedded systems, and support the simulation of the release jitter, execution jitter, priority relationship, AND constraint, OR constraint, Fork / Join concurrent execution process, task deadline, task trigger relationship, etc. of embedded system tasks, thereby solving the technical problem that traditional simulation methods cannot describe the relationship between complex embedded system tasks, achieving the goal of improving the reliability of simulation results, and at the same time having the technical effects of simple method, strong description ability and easy implementation.
[0060] In an optional implementation, establishing a task model for an embedded system includes: abstracting a task model based on the embedded system, wherein the task model is expressed as follows:
[0061]
[0062] where C represents the worst-case execution time of the task; D represents the task deadline; T represents the period of a periodic task or the minimum arrival interval of an occasional task; P represents the task priority; SYNC represents the synchronization type of the task; et represents the task execution time jitter; srt represents the time when the task first releases the job; Θ represents the set of random task release times, Θ = {rt1, ..., rt n}; rj indicates the task release time jitter; type indicates the task type; PT indicates a periodic task; ST indicates an occasional task; AT indicates a random task; and ET indicates an event-triggered task.
[0063] In an optional embodiment, a task triggering relationship is defined, including: a task releasing job triggers another task releasing job after execution is completed, wherein the task triggering relationship is defined as:
[0064]
[0065] Among them, τ k , τ j Represents τ i The task triggered by the job; at k Represents τ i Job execution at k Trigger task after time τ k ;at j Represents τ i Job execution at j Trigger task after time τ j ; C i Represents the task τ i The worst-case execution time.
[0066] In an optional embodiment, a communication model between tasks is defined, including: during the execution of a task, a dependency on a message is generated by another task. When the message that the task depends on exists, the task continues to execute; otherwise, it is blocked until the message arrives. When the synchronization type of the task is true, the job released by the task will be blocked after generating a message until the message generated by the task is consumed by another job. When the synchronization type of the task is false, the job released by the task does not need to wait for a return command to continue execution after generating a message.
[0067] Among them, the task τ i The expression that generates the message is as follows:
[0068]
[0069] Among them, mn represents the name of the job generating the message; mt represents the time when the job generates the message; C i Represents the task τ i Worst-case execution time;
[0070] The job depends on multiple messages during execution, and the task τ i The expressions that depend on messages during execution are as follows:
[0071]
[0072] Among them, dmn represents the name of the job dependency message; dmt represents the time of the job dependency message; C i Represents the task τ i The worst-case execution time.
[0073] It should be noted that the message dependency time can be different or the same, and the time a job depends on a message cannot be greater than the worst-case execution time of the job.
[0074] Furthermore, using both the message-based task triggering mechanism and the message-based mechanism simultaneously can describe complex task execution processes, such as tasks executed using a Fork / Join approach. It should be noted that Fork / Join employs a divide-and-conquer approach: Based on a task, it is continuously decomposed until a subtask meets a certain condition (such as being less than a certain value), at which point the subtask can be executed; once the subtask is processed, it is merged.
[0075] Figure 2 The flowchart of the parallel execution process of task τ1 Fork / Join provided in the embodiment of the present invention is as follows: Figure 2 As shown, task τ1 uses the Fork / Join parallel framework. During execution, it splits the large task into two subtasks τ2 and τ3, which are executed concurrently. τ3 is further split into two subtasks τ4 and τ5. τ3 processes the calculation results of τ4 and τ5. After τ2 and τ3 are executed, τ1 processes the calculation results of τ2 and τ3 in one step, and then τ1 execution ends. The results of modeling the execution process of τ1 using this model are shown below:
[0076]
[0077]
[0078]
[0079]
[0080] Task τ1 triggers tasks τ2 and τ3 at time t1 and is blocked due to dependent messages m2 and m3; τ2 and τ3 start to execute, and τ2 generates message m2 after execution; τ3 triggers tasks τ4 and τ5 at time t3 and is blocked due to dependent messages m4 and m5; τ4 and τ5 start to execute, and generate messages m4 and m5 after execution respectively; τ3 obtains the dependent messages and continues to execute, and generates message m3 after execution; τ1 obtains the dependent messages m2 and m3 and continues to execute until execution ends.
[0081] In an optional implementation, the expression of the system resource model is as follows:
[0082] ω={name,num}
[0083] Where ω represents the resource being applied for; name represents the name of the resource being applied for; and num represents the number of resources being applied for.
[0084] In an optional implementation, a task needs to acquire all resources before it can start executing. Otherwise, it will be blocked until all resources are acquired. The expression of the task resource access control model is as follows:
[0085]
[0086] Among them, ω i ′ represents the resources obtained by the task application; τ i Indicates the task of applying for resources; ω indicates the resource being applied for; num indicates the number of resources applied for.
[0087] In an optional implementation, a data access control model is defined, including: task τ i Resources obtained through application i ′ becomes data, in τ i After the execution is completed, i ′ is treated as other tasks τ j , τ k Resources i Use, that is, τ i After the execution is completed, τ j , τ k To be executed. j Use res i There are two ways to read and write. j Read res i When, res i At the same time, τ k Read; when τ j Write res i When res i Lock, lock successfully and continue to execute, if in res i Locked period τk Need to use res i , τ k Will be blocked, after the write operation is completed τ j Release res i , then res i τ k Use; when all use res i After the task is completed, release res i , at this time the system recycles the task τ i Resources applied for;
[0088] Among them, the task τ k The expression of the model for reading data is as follows:
[0089]
[0090] Among them, ω i ′ represents the task τ i The resources applied for; rst represents the task τ k The time to start reading resources; ret represents the task τ k The time when reading resources ends;
[0091] Task τ k The expression of the model for writing data is as follows:
[0092]
[0093] Among them, ω i ′ represents the task τ i The resources applied for; wst represents the task τ k The time to start writing resources; wet represents the task τ k The time when writing the resource was completed.
[0094] Furthermore, the above data access control model can express AND constraints between tasks, such as τ k Must be in τ i and τ j It can only be executed after the execution is completed. The model is represented as follows:
[0095]
[0096]
[0097]
[0098]
[0099] The above data access control model can express OR constraints between tasks, such as τ k In τi or τ j It can only be executed after the execution is completed. The model is represented as follows:
[0100]
[0101]
[0102]
[0103] Figure 3 The simulation flow chart of a single simulation step provided by the embodiment of the present invention is as follows: Figure 3 As shown, the simulation of the simulation step includes the following implementation steps: reading the system model; calculating the global virtual clock frequency; calculating the total simulation cycle according to the global virtual clock; determining the cycle of job and interrupt generation; judging whether the job generation cycle has been reached; if so, the task releases the job, and then judges whether the interrupt generation cycle has been reached, if not, directly judges whether the interrupt generation cycle has been reached; judges whether the interrupt generation cycle has been reached, if so, the interrupt is generated, and then the interrupt and job are allocated to the kernel according to the scheduling algorithm, if not, the interrupt and job are directly allocated to the kernel according to the scheduling algorithm; after the interrupt and job are allocated to the kernel according to the scheduling algorithm, the kernel is executed synchronously, and at this time, the execution process of the two kernels is the same until the execution of the two kernels ends, for example, judging whether the local virtual clock jumps, if so, the local virtual clock is increased by one, and then the kernel executes the interrupt and job, and finally records the kernel execution process, if not, directly records the kernel execution process; after the kernel execution ends, the global virtual clock cycle is increased by one, and then judges whether the global virtual clock cycle is greater than the total simulation cycle, if so, obtains the analysis simulation result, if not, continues to execute the judgment of whether the job generation cycle has been reached and the related steps after the judgment.
[0104] According to another aspect of an embodiment of the present invention, an embedded system simulation device supporting multiple timing constraints is provided. Figure 4 A schematic diagram of an embedded system simulation device supporting multiple timing constraints provided by an embodiment of the present invention, such as Figure 4 As shown, the embedded system simulation device supporting multiple timing constraints includes: an establishment module 402, a first definition module 404, a second definition module 406, a third definition module 408, a fourth definition module 410, a fifth definition module 412, a setting module 414, and a simulation processing module 416. The embedded system simulation device supporting multiple timing constraints is described in detail below.
[0105] Establishing module 402, for establishing a task model of the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks;
[0106] A first definition module 404, connected to the establishment module 402, is used to define a task trigger relationship;
[0107] A second definition module 406, connected to the first definition module 404, is used to define an inter-task communication model;
[0108] A third definition module 408, connected to the second definition module 406, is used to define a system resource model;
[0109] A fourth definition module 410 , connected to the third definition module 408 , is used to define a task resource access control model;
[0110] A fifth definition module 412 , connected to the fourth definition module 410 , is used to define a data access control model;
[0111] A setting module 414, connected to the fifth definition module 412, for setting simulation parameters;
[0112] The simulation processing module 416 is connected to the above-mentioned setting module 414 and is used to simulate the embedded system according to the task model, task trigger relationship, inter-task communication model, system resource model, task resource access control model, data access control model and simulation parameters; wherein, the simulation processing includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation time and simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, then the simulation step is simulated, and the task release job, job scheduling, resource allocation, data allocation, job generation message, job dependency message, job generation data, job dependency data and resource recovery operations are executed in sequence; if the current number of simulation steps is greater than the number of simulations, then the simulation ends.
[0113] It should be noted here that the above-mentioned establishment module 402, first definition module 404, second definition module 406, third definition module 408, fourth definition module 410, fifth definition module 412, setting module 414 and simulation processing module 416 correspond to steps S102 to S116 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules and corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned method embodiment.
[0114] In an embodiment of the present invention, the embedded system simulation device that supports multiple timing constraints adopts a task model for establishing an embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks; defines task triggering relationships; defines an inter-task communication model; defines a system resource model; defines a task resource access control model; defines a data access control model; sets simulation parameters; simulates the embedded system according to the task model, task triggering relationships, inter-task communication model, system resource model, task resource access control model, data access control model and simulation parameters; wherein the simulation processing includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation time and simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, then simulating the simulation step, and executing task release jobs, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations in sequence; if the current number of simulation steps is greater than the number of simulations, then the simulation ends. That is to say, the embodiments of the present invention can support the simulation of embedded systems with multiple timing constraints, can model and simulate complex embedded systems, and support the simulation of the release jitter, execution jitter, priority relationship, AND constraint, OR constraint, Fork / Join concurrent execution process, task deadline, task trigger relationship, etc. of embedded system tasks, thereby solving the technical problem that traditional simulation methods cannot describe the relationship between complex embedded system tasks, achieving the goal of improving the reliability of simulation results, and at the same time having the technical effects of simple method, strong description ability and easy implementation.
[0115] According to another aspect of an embodiment of the present invention, an electronic device is provided, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute any one of the above method steps.
[0116] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above method steps.
[0117] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0118] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0119] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0120] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0121] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0122] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0123] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for simulating an embedded system supporting multiple timing constraints, characterized in that: include: Establishing a task model for the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks, and event-triggered tasks; Define task trigger relationships; Define the inter-task communication model; Define the system resource model; Define the task resource access control model; Define data access control model; Set simulation parameters; The embedded system is simulated according to the task model, the task trigger relationship, the inter-task communication model, the system resource model, the task resource access control model, the data access control model and the simulation parameters; wherein the simulation includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation duration and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, simulating the simulation steps, and sequentially executing task release operations, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations; if the current number of simulation steps is greater than the number of simulations, the simulation ends; Establish a task model for the embedded system, including: The task model is abstracted according to the embedded system, wherein the expression of the task model is as follows: ; in, represents the worst-case execution time of a task; Indicates the time limit of the task; Indicates the period of the periodic task or the minimum arrival interval of the sporadic task; Indicates task priority; Indicates the synchronization type of the task; Indicates task execution time jitter; Indicates the time when the task first releases the job; represents the set of random task release times, ; Indicates the jitter of task release time; Indicates the task type; Represents the periodic task; represents said occasional task; represents the random task; Indicates that the event triggers a task; Define task trigger relationships, including: After the task release job is completed, it triggers another task release job, where the task triggering relationship is defined as: ; in, express Tasks triggered by jobs; express Job execution Trigger task after time ; express Job execution Trigger task after time ; Indicates a task Worst-case execution time; Define the inter-task communication model, including: During the execution of a task, a dependency on a message is generated by another task. If the message on which the task depends exists, the task continues to execute; otherwise, it is blocked until the message arrives. If the synchronization type of the task is true, the job released by the task will be blocked after generating a message until the message generated by the task is consumed by another job. If the synchronization type of the task is false, the job released by the task will continue to execute without waiting for a return command after generating a message. Among them, the task The expression that generates the message is as follows: ; in, Indicates the name of the job generating the message; Indicates the time when the job generates the message; Indicates a task Worst-case execution time; The job depends on multiple messages and tasks during execution. The expressions that depend on messages during execution are as follows: ; in, Indicates the name of the job dependency message; Indicates the time when the job depends on the message; Indicates a task Worst-case execution time; The expression of the system resource model is as follows: ; in, Indicates the resource being requested; Indicates the name of the resource being applied for; Indicates the number of resources requested; The expression of the task resource access control model is as follows: ; in, Indicates the resources obtained by the task application; Indicates the task of applying for resources; Indicates the resource being requested; Indicates the number of resources requested; Define the data access control model, including: Task Resources requested Become data, After the execution is completed, Treated as other tasks 、 Resources Use; among them, when read hour, At the same time Read; when Write When, right Lock, lock successfully and continue to execute, if Locked period Need to use , Will be blocked, after the write operation is completed release ,but quilt Use; when all use Released after the task is completed , then the recycling task Resources applied for; Among them, the task The expression of the model for reading data is as follows: ; in, Indicates a task Resources obtained through application; Indicates a task The time when resource reading started; Indicates a task The time when reading resources ends; Task The expression of the model for writing data is as follows: ; in, Indicates a task Resources obtained through application; Indicates a task When to start writing resources; Indicates a task The time when writing the resource was completed.
2. The method according to claim 1, characterized in that The simulation parameters include total simulation time, simulation step length and task scheduling algorithm.
3. The method according to any one of claims 1 to 2, characterized in that The calculation expression of the simulation times is as follows: ; in, represents the number of simulations; Indicates the total duration of the simulation; Represents the simulation step size.
4. An embedded system simulation device supporting multiple timing constraints, characterized in that: include: An establishment module is used to establish a task model of the embedded system, wherein the task model includes periodic tasks, occasional tasks, random tasks and event-triggered tasks; The first definition module is used to define the task trigger relationship; The second definition module is used to define the inter-task communication model; The third definition module is used to define the system resource model; The fourth definition module is used to define the task resource access control model; The fifth definition module is used to define a data access control model; Setting module, used to set simulation parameters; A simulation processing module is used to simulate the embedded system according to the task model, the task trigger relationship, the inter-task communication model, the system resource model, the task resource access control model, the data access control model and the simulation parameters; wherein, the simulation processing includes: at the beginning of each simulation step, judging whether the current number of simulation steps is less than or equal to the number of simulations, wherein the number of simulations is determined according to the total simulation duration and the simulation step length in the simulation parameters; if the current number of simulation steps is less than or equal to the number of simulations, simulating the simulation steps, and sequentially executing task release operations, job scheduling, resource allocation, data allocation, job generation messages, job dependency messages, job generation data, job dependency data and resource recovery operations; if the current number of simulation steps is greater than the number of simulations, the simulation ends; Establish a task model for the embedded system, including: The task model is abstracted according to the embedded system, wherein the expression of the task model is as follows: ; in, represents the worst-case execution time of a task; Indicates the time limit of the task; Indicates the period of the periodic task or the minimum arrival interval of the sporadic task; Indicates task priority; Indicates the synchronization type of the task; Indicates task execution time jitter; Indicates the time when the task first releases the job; represents the set of random task release times, ; Indicates the jitter of task release time; Indicates the task type; Represents the periodic task; represents said occasional task; represents the random task; Indicates that the event triggers a task; Define task trigger relationships, including: After the task release job is completed, it triggers another task release job, where the task triggering relationship is defined as: ; in, express Tasks triggered by jobs; express Job execution Trigger task after time ; express Job execution Trigger task after time ; Indicates a task Worst-case execution time; Define the inter-task communication model, including: During the execution of a task, a dependency on a message is generated by another task. If the message on which the task depends exists, the task continues to execute; otherwise, it is blocked until the message arrives. If the synchronization type of the task is true, the job released by the task will be blocked after generating a message until the message generated by the task is consumed by another job. If the synchronization type of the task is false, the job released by the task will continue to execute without waiting for a return command after generating a message. Among them, the task The expression that generates the message is as follows: ; in, Indicates the name of the job generating the message; Indicates the time when the job generates the message; Indicates a task Worst-case execution time; The job depends on multiple messages and tasks during execution. The expressions that depend on messages during execution are as follows: ; in, Indicates the name of the job dependency message; Indicates the time when the job depends on the message; Indicates a task Worst-case execution time; The expression of the system resource model is as follows: ; in, Indicates the resource being requested; Indicates the name of the resource being applied for; Indicates the number of resources requested; The expression of the task resource access control model is as follows: ; in, Indicates the resources obtained by the task application; Indicates the task of applying for resources; Indicates the resource being requested; Indicates the number of resources requested; Define the data access control model, including: Task Resources requested Become data, After the execution is completed, Treated as other tasks 、 Resources Use; among them, when read hour, At the same time Read; when Write When, right Lock, lock successfully and continue to execute, if Locked period Need to use , Will be blocked, after the write operation is completed release ,but quilt Use; when all use Released after the task is completed , then the recycling task Resources applied for; Among them, the task The expression of the model for reading data is as follows: ; in, Indicates a task Resources obtained through application; Indicates a task The time when resource reading started; Indicates a task The time when reading resources ends; Task The expression of the model for writing data is as follows: ; in, Indicates a task Resources obtained through application; Indicates a task When to start writing resources; Indicates a task The time when writing the resource was completed.
Citation Information
Patent Citations
Implementation method of complex industrial control system
CN108919672A
Method of programming a co-verification system
US20060015313A1