×
SystemC uses simulation processes to model concurrency. It's not true concurrent execution. When multiple processes are simulated as running concurrently, only one is executed at a particular time. However, the simulated time remain unchanged until all concurrent processes finishes their current tasks. Thus, these processes are running concurrently on the same "simulated time". This differs from e.g. the Go language, which is real concurrency. Let's understand the simulated concurrency with a simple example.
Learn with Examples, 2020, MIT license | |
| |
| |
| |
constructor |
|
register thread1 |
|
register thread2 |
|
| |
| |
infinite loop |
|
| |
trigger again after 2 "simulated" seconds |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
define an object |
|
run simulation for 10 seconds |
|
| |
| |
thread1 is running | 0 s: thread1 |
thread2 is running | 0 s: thread2 |
thread1 is running | 2 s: thread1 |
thread2 is running | 3 s: thread2 |
thread1 is running | 4 s: thread1 |
thread2 is running | 6 s: thread2 |
thread1 is running | 6 s: thread1 |
thread1 is running | 8 s: thread1 |
thread2 is running | 9 s: thread2 |
simulation ends after 10 simulated seconds |