Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a TESH for the new sthread feature
[simgrid.git] / src / sthread / sthread_impl.cpp
index f2afe1e..1780543 100644 (file)
@@ -30,7 +30,7 @@ int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**
   std::ostringstream id;
   id << std::this_thread::get_id();
 
-  XBT_INFO("sthread main() is starting in thread %s", id.str().c_str());
+  XBT_DEBUG("sthread main() is starting in thread %s", id.str().c_str());
 
   sg4::Engine e(&argc, argv);
   auto* zone = sg4::create_full_zone("world");
@@ -38,14 +38,16 @@ int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**
   zone->seal();
 
   /* Launch the user's main() on an actor */
-  sthread_inside_simgrid   = 0;
+  sthread_enable();
   sg4::ActorPtr main_actor = sg4::Actor::create("tid 0", lilibeth, raw_main, argc, argv, envp);
 
-  XBT_INFO("sthread main() is launching the simulation");
+  XBT_INFO("Starting the simulation.");
   sg4::Engine::get_instance()->run();
+  XBT_INFO("All threads exited. Terminating the simulation.");
 
   return 0;
 }
+
 struct sthread_mutex {
   s4u_Mutex* mutex;
 };
@@ -56,17 +58,17 @@ static void thread_create_wrapper(void* (*user_function)(void*), void* param)
   if (SMPI_is_inited())
     SMPI_thread_create();
 #endif
-  sthread_inside_simgrid = 0;
+  sthread_enable();
   user_function(param);
-  sthread_inside_simgrid = 1;
+  sthread_disable();
 }
 
 int sthread_create(unsigned long int* thread, const /*pthread_attr_t*/ void* attr, void* (*start_routine)(void*),
                    void* arg)
 {
-  static int TID = 1;
-
+  static int TID = 0;
   TID++;
+  XBT_VERB("Create thread %d", TID);
   int rank = 0;
 #if HAVE_SMPI
   if (SMPI_is_inited())