Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI: Change the reference speed to a command line option
[simgrid.git] / src / xbt / xbt_context_thread.c
index 8e54725..a00612b 100644 (file)
@@ -14,6 +14,7 @@
 #include "xbt/swag.h"
 #include "xbt/xbt_os_thread.h"
 
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_context);
 
 typedef struct s_xbt_ctx_thread {
   XBT_CTX_BASE_T;
@@ -75,6 +76,7 @@ static int
 xbt_ctx_thread_factory_create_master_context(xbt_context_t * maestro)
 {
   *maestro = (xbt_context_t) xbt_new0(s_xbt_ctx_thread_t, 1);
+  (*maestro)->name = (char *) "maestro";
   return 0;
 }
 
@@ -95,6 +97,7 @@ xbt_ctx_thread_factory_create_context(const char *name, xbt_main_func_t code,
 {
   xbt_ctx_thread_t context = xbt_new0(s_xbt_ctx_thread_t, 1);
 
+  VERB1("Create context %s", name);
   context->code = code;
   context->name = xbt_strdup(name);
   context->begin = xbt_os_sem_init(0);
@@ -148,6 +151,7 @@ static void xbt_ctx_thread_free(xbt_context_t context)
 
 static void xbt_ctx_thread_kill(xbt_context_t context)
 {
+  DEBUG1("Kill context '%s'", context->name);
   context->iwannadie = 1;
   xbt_ctx_thread_swap(context);
 }
@@ -163,6 +167,7 @@ static void xbt_ctx_thread_kill(xbt_context_t context)
  */
 static void xbt_ctx_thread_schedule(xbt_context_t context)
 {
+  DEBUG1("Schedule context '%s'", context->name);
   xbt_assert0((current_context == maestro_context),
               "You are not supposed to run this function here!");
   xbt_ctx_thread_swap(context);
@@ -178,6 +183,7 @@ static void xbt_ctx_thread_schedule(xbt_context_t context)
  */
 static void xbt_ctx_thread_yield(void)
 {
+  DEBUG1("Yield context '%s'", current_context->name);
   xbt_assert0((current_context != maestro_context),
               "You are not supposed to run this function here!");
   xbt_ctx_thread_swap(current_context);
@@ -187,6 +193,7 @@ static void xbt_ctx_thread_start(xbt_context_t context)
 {
   xbt_ctx_thread_t ctx_thread = (xbt_ctx_thread_t) context;
 
+  DEBUG1("Start context '%s'", context->name);
   /* create and start the process */
   ctx_thread->thread =
     xbt_os_thread_create(ctx_thread->name, xbt_ctx_thread_wrapper,
@@ -198,6 +205,7 @@ static void xbt_ctx_thread_start(xbt_context_t context)
 
 static void xbt_ctx_thread_stop(int exit_code)
 {
+  /* please no debug here: our procdata was already free'd */
   if (current_context->cleanup_func)
     ((*current_context->cleanup_func)) (current_context->cleanup_arg);
 
@@ -213,6 +221,7 @@ static void xbt_ctx_thread_stop(int exit_code)
 
 static void xbt_ctx_thread_swap(xbt_context_t context)
 {
+  DEBUG2("Swap context: '%s' -> '%s'", current_context->name, context->name);
   if ((current_context != maestro_context) && !context->iwannadie) {
     /* (0) it's not the scheduler and the process doesn't want to die, it just wants to yield */
 
@@ -273,6 +282,8 @@ static void xbt_ctx_thread_suspend(xbt_context_t context)
   /* save the current context */
   xbt_context_t self = current_context;
 
+  DEBUG1("Suspend context '%s'", context->name);
+
   /* update the current context to this context */
   current_context = context;
 
@@ -288,6 +299,8 @@ static void xbt_ctx_thread_resume(xbt_context_t context)
   /* save the current context */
   xbt_context_t self = current_context;
 
+  DEBUG1("Resume context '%s'", context->name);
+
   /* update the current context */
   current_context = context;