CSIM for C/C++ and SimPy for Python. Both
the classes of simulators mentioned above will not
be dealt with in the discussion that follows, which
will consider only Java-based simulators supporting
a process-oriented world view.
2.1 Thread-based Simulators
SimJava (Howell and McNab, 1998) and JSim (Miller
et al., 1997) are among the first implementations of
the thread-based class of simulators. These early ef-
forts pay particular attention to web-based simulation
and to the Java Applet deployment model. Many sim-
ulators aim at replicating the functionality and design
of Simula in Java. For example, Javasimulation (Hels-
gaun, 2000) follows the Simula design so close that
coroutines are presented as the main mechanism for
implementing simulation processes. However, corou-
tines are in their turn implemented by exploiting the
Java threading.
DesmoJ (Lechler and Page, 1999) supports ad-
vanced process-oriented modeling features. These
include capacity-constrained resources, conditional
waiting and special process relationships as pro-
ducer/consumer and asymmetric master/slave. SSJ
(L’Ecuyer and Buist, 2005) is designed for perfor-
mance, flexibility and extensibility. It offers its users
the possibility to choose between many alternatives
for most of the internal algorithms and data structures
of the simulator.
As mentioned before, Java threads are a power-
ful resource, but using them just for saving an exe-
cution context for later resume is probably overkill,
and introduces unnecessary overheads and limitations
on the maximum number of simulated processes. Let
us consider the two issues separately. As regards the
overheads, it should be pointed out that most typically
Java platforms implement threads as system threads.
Hence threads are individually scheduled by the OS
and managed through system calls. This makes it
possible to exploit multiple processors, but also intro-
duces a non-negligible overhead associated to thread
management activities. As for the limitation on the
maximum number of simulated processes, it can be
observed that Java threads have a minimum size
3
that
cannot be reduced due to the presence of guard pages
on the stack. When the address spaces are not so large
(e.g., in 32 bit systems), the maximum number of sim-
ulated processes is severely limited by the maximum
number of threads that can be allocated in a memory
where the heap is usually dominant due to the Java
execution model. In practice, in a 32-bit Linux sys-
3
Platform dependent, 48 KB on a typical 32-bit Linux
box.
tem, where the addressable space is 4 GB, of which
1 GB is typically reserved to the kernel, less than 3
GB are available for the rest. Under the reasonable
assumption that 1.5 GB are used for the JVM text and
data sections and the heap, only 1.5 GB remain for the
stack. Even with the lowest setting of stack size for
a thread (48 KB), the maximum number of allowed
threads will be about 30,000. In fact, this huge num-
ber of threads turns out to be not sufficient for models
of complex systems in which a considerable number
of simultaneously active entities must be simulated
(e.g., parallel computers, wide area networks, multi-
tasking operating systems, sensors networks, ... ).
2.2 Beyond Threads
In light of all the above, the use of alternatives to
threads for saving and resuming a context seems at
least reasonable. In recent years, different approaches
have been followed to provide a better implementa-
tion of the process interaction view, all of which try
to deal with the lack of support for coroutines in the
standard Java language and virtual machine. D-SOL
(Jacobs et al., 2002) is based on the use of a process
interpreter. This can be thought of as a virtual ma-
chine implemented in Java that executes the code of
the process class. The interpreter takes care of paus-
able methods and is able to save their execution con-
text. To avoid unnecessary overhead, the methods in-
voked by the process that do not lead to process sus-
pension are directly executed through reflection. Cur-
rently, a D-SOL based interpretation engine is found
in the current version of the above-mentioned SSJ
simulator. Tortuga (Weatherly and Page, 2004) pro-
vides an implementation of coroutines in Java which
is not based on threads. This is based on a modifica-
tion of a non-standard Java virtual machine, the Jikes
RVM, able to provide the state-saving mechanism.
Works as (Stadler, 2011) are paving the way for
the integration of coroutines or of a continuation-
like mechanism in the standard Java platform. In
the meantime, the use of continuations is beginning
to spread in discrete-event simulation. The My-
TimeWarp simulator by Kunert (Kunert, 2008) hinges
on the JavaFlow continuation library (which is also
adopted for the JADES simulator presented in this pa-
per) and focuses on process-oriented time warp opti-
mistic parallel simulation. However, no performance
tests and source code are available to make compari-
son with our work.
Process-orientedDiscrete-eventSimulationinJavawithContinuations-QuantitativePerformanceEvaluation
89