[Simgrid-user] The MSG Process entity and The Java Thread one

Martin Quinson martin.quinson at loria.fr
Mon Apr 30 11:02:28 CEST 2012


On Fri, Apr 27, 2012 at 04:21:05PM +0200, Adrien Lèbre wrote:
> Hi all, 
> 
> I'm wondering how SimGrid (i.e. more precisely simgrid-java)  handles the Java Thread entity. 
> IOW, What is the behavior of SG  when a SG Process instantiates and launches one, two, ...  java Threads (i.e. calling the start method).
> What happens if I call waitFor() from my SG Process, does it suspend all internal Threads linked to that  SG Process ? I'm bit lost...

Very bad things will probably happen if you start threads on your own.
They will not be controled by SimGrid the same way that others do,
which may lead to unpredictable issues (your threads will continue
working when the simulated thread that started them are locked by the
simulator).

And if your own thread try to have any SimGrid interaction, you will
probably gain a ClassCastException, as we assume that any Thread doing
so inherits of simgrid.Process (and have the corresponding fields,
such as the semaphores used for synchronizing threads). 

If you try to simply change the type of your threads from Thread into
simgrid.Process, the C data structures corresponding to these threads
will not be initialized, probably leading to quick and definitive
segfaults of the JVM.

For more informations on the threading models in the Java bindings,
check the comments associated to the method Process.unschedule() in
the source code (in the git, I recently updated it).

> Going through the ML, I saw that you can create other Processes from another one (cf. 
> http://lists.gforge.inria.fr/pipermail/simgrid-user/2011-October/002622.html ). 
> What is the normal way to handle such a case : Can I use Threads directly in one of my SG Process or Should I create all internal threads as other SG Processes ?  

You definitely want to have all threads runing in the simulation
started as SG processes. Likewise, you should really bannish the
"synchronized" keyword in your SG simulations, or deadlocks will
probably occure.

Bye, Mt.

-- 
Il n'y a pas de recherche appliquée, mais des applications de la recherche.
  -- Louis Pasteur



More information about the Simgrid-user mailing list