You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ The documentation covers the following aspects:
7
7
+[Processes](#processes)
8
8
+[Resources](#resources)
9
9
+[Samples](#samples)
10
+
+[Environments](#environments)
10
11
*[Monitoring](#monitoring)
11
12
+[Reports](#reports)
12
13
@@ -82,6 +83,23 @@ A *Container* contains a continuous amount of some substance. Again, the substan
82
83
83
84
In any case, it is simple to extend the standard resources given that the code is open source. The classes are of moderate complexity, e.g. the *Resource* class is described in about 200 lines of code.
84
85
86
+
### Environments
87
+
88
+
Sim# offers several different simulation environments. The default environment is called `Simulation` and is the fastest. There is also a `ThreadSafeSimulation` which synchronises access to the event queue. This is useful if there is a separate thread that may create processes or which may fire events. It should be noted that the simulation itself is not multi-threaded. At any time there may only be a single process that is active. The "simulation thread" is that thread that called the `Run()` method.
89
+
90
+
#### Realtime Simulation
91
+
92
+
Starting with Sim# 3.3 we introduce a `PseudoRealtimeSimulation` environment that derives from `ThreadSafeSimulation`. It will put the simulation thread to sleep for the duration given by the next event in the queue, i.e., a delay of 5 seconds will put the simulation to sleep 5 seconds. An actual realtime guarantee is however not made. In fact, the overhead of the environment, for instance waking up processes, adding and removing from the event queue, and so on are not accounted for. Thus, this may lag behind the actual wall clock time.
93
+
94
+
However, this environment allows *switching between real and virtual time* and also accepts a realtime scale so that it can be used to perform faster and slower than the actual real time by a certain factor. It offers to method to control the speed:
95
+
96
+
*`SetVirtualTime()` will process items as fast as `ThreadSafeSimulation`
97
+
*`SetRealtime(double scale)` will switch the simulation into realtime mode.
98
+
99
+
These methods are thread safe and may be called from different threads.
100
+
101
+
Obtaining the current simulation time using `Now` in realtime mode will account for the duration that the simulation is sleeping. Thus, calling this property from a different thread will always receive the actual simulation time, i.e., the time of the last event plus the elapsed time.
102
+
85
103
### Samples
86
104
87
105
Processes that interact with common resources may create highly dynamic behavior which may not be analytically tractable and thus have to be simulated. Sim# includes a number of samples that, while being easy to understand and simple, show how to model certain processes such as preemption, interruption, handover of resource requests and more. A short summary of the provided samples together with the highlights are given in the following:
@@ -134,6 +152,12 @@ This model describes a simple producer-consumer situation. It shows how processe
134
152
135
153
These model describe a two-step production. The first step may be blocked by the second. The models should show how one process may obtain a resource, but another processes releases that resource.
* Running a process that awaits some timeout in realtime
158
+
159
+
This model describes a single process that will define a timeout which is awaited in realtime.
160
+
137
161
## Monitoring
138
162
139
163
Monitoring has been introduced with Sim# 3.2. Instead of following the SimPy approach which is difficult to translate to .NET. The implementation in Sim# is more akin to [Salabim](https://www.salabim.org).
0 commit comments