Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rewrite the kill_time mecanism.
authornavarro <navarro@caraja.(none)>
Fri, 27 Apr 2012 10:57:25 +0000 (12:57 +0200)
committernavarro <navarro@caraja.(none)>
Fri, 27 Apr 2012 11:00:53 +0000 (13:00 +0200)
14 files changed:
examples/msg/start_kill_time/deployment_start_kill.xml
include/msg/msg.h
include/simix/datatypes.h
include/simix/simix.h
src/gras/Virtu/sg_process.c
src/msg/msg_private.h
src/msg/msg_process.c
src/simix/smx_deployment.c
src/simix/smx_process.c
src/simix/smx_process_private.h
src/simix/smx_smurf.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/xbt/xbt_sg_synchro.c

index 474c99d..4342a09 100644 (file)
@@ -2,9 +2,9 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
     <process host="c-0.me" function="master"/>
-       <process host="c-1.me" function="slave" start_time="1" kill_time="10"/>
-       <process host="c-2.me" function="slave" start_time="2" kill_time="10"/>
-       <process host="c-3.me" function="slave" start_time="3" kill_time="10"/>
-       <process host="c-4.me" function="slave" start_time="4" kill_time="10"/>
-       <process host="c-5.me" function="slave" start_time="5" kill_time="10"/>
+       <process host="c-1.me" function="slave" start_time="1" kill_time="5"/>
+       <process host="c-2.me" function="slave" start_time="2" kill_time="6"/>
+       <process host="c-3.me" function="slave" start_time="3" kill_time="7"/>
+       <process host="c-4.me" function="slave" start_time="4" kill_time="8"/>
+       <process host="c-5.me" function="slave" start_time="5" kill_time="9"/>
 </platform>
\ No newline at end of file
index 4dccee2..4d3bc10 100644 (file)
@@ -100,6 +100,7 @@ XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char
                                                             code,
                                                             void *data,
                                                             m_host_t host,
+                                                            double kill_time,
                                                             int argc,
                                                             char **argv,
                                                             xbt_dict_t
index b41e989..97e8af5 100644 (file)
@@ -88,6 +88,7 @@ typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
                                       /* code */ xbt_main_func_t,
                                       /* userdata */ void*,
                                       /* hostname */ const char*,
+                                      /* kill_time */ double,
                                       /* argc */ int,
                                       /* argv */ char**,
                                       /* props */ xbt_dict_t);
index 2de942e..59522ff 100644 (file)
@@ -128,6 +128,7 @@ XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
                                           xbt_main_func_t code,
                                           void *data,
                                           const char *hostname,
+                                          double kill_time,
                                           int argc, char **argv,
                                           xbt_dict_t properties);
 
index 44ca9d5..b524417 100644 (file)
@@ -29,7 +29,7 @@ void gras_agent_spawn(const char *name,
 
   smx_process_t process;
   simcall_process_create(&process, name, code, NULL,
-                           gras_os_myname(), argc, argv, properties);
+                           gras_os_myname(), -1.0, argc, argv, properties);
 }
 
 /* **************************************************************************
index c43de1e..c966362 100644 (file)
@@ -133,7 +133,7 @@ void __MSG_display_process_status(void);
 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
                                    xbt_main_func_t code, void *data,
-                                   const char *hostname, int argc,
+                                   const char *hostname, double kill_time,  int argc,
                                    char **argv, xbt_dict_t properties);
 void MSG_process_kill_from_SIMIX(smx_process_t p);
 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
index 43b782b..e8bf1b7 100644 (file)
@@ -58,12 +58,12 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc)
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
 void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name,
                                     xbt_main_func_t code, void *data,
-                                    const char *hostname, int argc, char **argv,
+                                    const char *hostname, double kill_time, int argc, char **argv,
                                     xbt_dict_t properties)
 {
   m_host_t host = MSG_get_host_by_name(hostname);
   m_process_t p = MSG_process_create_with_environment(name, code, data,
-                                                      host, argc, argv,
+                                                      host, kill_time, argc, argv,
                                                       properties);
   *((m_process_t*) process) = p;
 }
@@ -79,7 +79,7 @@ m_process_t MSG_process_create(const char *name,
                                xbt_main_func_t code, void *data,
                                m_host_t host)
 {
-  return MSG_process_create_with_environment(name, code, data, host, -1,
+  return MSG_process_create_with_environment(name, code, data, host, -1, -1,
                                              NULL, NULL);
 }
 
@@ -113,7 +113,7 @@ m_process_t MSG_process_create_with_arguments(const char *name,
                                               void *data, m_host_t host,
                                               int argc, char **argv)
 {
-  return MSG_process_create_with_environment(name, code, data, host,
+  return MSG_process_create_with_environment(name, code, data, host, -1.0,
                                              argc, argv, NULL);
 }
 
@@ -136,6 +136,7 @@ m_process_t MSG_process_create_with_arguments(const char *name,
    object.  It is for user-level information and can be NULL. It can
    be retrieved with the function \ref MSG_process_get_data.
  * \param host the location where the new process is executed.
+ * \param kill_time the time when the process is killed.
  * \param argc first argument passed to \a code
  * \param argv second argument passed to \a code
  * \param properties list a properties defined for this process
@@ -145,6 +146,7 @@ m_process_t MSG_process_create_with_arguments(const char *name,
 m_process_t MSG_process_create_with_environment(const char *name,
                                                 xbt_main_func_t code,
                                                 void *data, m_host_t host,
+                                                double kill_time,
                                                 int argc, char **argv,
                                                 xbt_dict_t properties)
 {
@@ -174,7 +176,7 @@ m_process_t MSG_process_create_with_environment(const char *name,
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
-  simcall_process_create(&process, name, code, simdata, host->name,
+  simcall_process_create(&process, name, code, simdata, host->name, kill_time,
                            argc, argv, properties);
 
   if (!process) {
index 6c7d332..d1cbbf6 100644 (file)
@@ -33,8 +33,8 @@ static void parse_process_init(void)
   parse_argv = xbt_new(char *, 2);
   parse_argv[0] = xbt_strdup(A_surfxml_process_function);
   parse_argc = 1;
-  start_time= surf_parse_get_double(A_surfxml_process_start_time);
-  kill_time = surf_parse_get_double(A_surfxml_process_kill_time);
+  start_time = surf_parse_get_double(A_surfxml_process_start_time);
+  kill_time  = surf_parse_get_double(A_surfxml_process_kill_time);
 }
 
 static void parse_argument(void)
@@ -48,6 +48,7 @@ static void parse_process_finalize(void)
   smx_process_arg_t arg = NULL;
   smx_process_t process = NULL;
   parse_argv[parse_argc] = NULL;
+
   if (start_time > SIMIX_get_clock()) {
     arg = xbt_new0(s_smx_process_arg_t, 1);
     arg->name = parse_argv[0];
@@ -59,7 +60,7 @@ static void parse_process_finalize(void)
     arg->kill_time = kill_time;
     arg->properties = current_property_set;
 
-    XBT_DEBUG("Process %s(%s) will be started at time %f", arg->name,
+    XBT_INFO("Process %s(%s) will be started at time %f", arg->name,
            arg->hostname, start_time);
     SIMIX_timer_set(start_time, &SIMIX_process_create_from_wrapper, arg);
   } else {                      // start_time <= SIMIX_get_clock()
@@ -68,22 +69,21 @@ static void parse_process_finalize(void)
     if (simix_global->create_process_function)
       simix_global->create_process_function(&process,
                                             parse_argv[0],
-                                            parse_code, NULL,
-                                            parse_host, parse_argc,
+                                            parse_code,
+                                            NULL,
+                                            parse_host,
+                                            kill_time,
+                                            parse_argc,
                                             parse_argv,
                                             current_property_set);
     else
-      simcall_process_create(&process, parse_argv[0], parse_code, NULL, parse_host, parse_argc, parse_argv,
+      simcall_process_create(&process, parse_argv[0], parse_code, NULL, parse_host, kill_time, parse_argc, parse_argv,
                                current_property_set);
+
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
     if (!process) {
       return;
     }
-    if (kill_time > SIMIX_get_clock()) {
-      if (simix_global->kill_process_function) {
-        SIMIX_timer_set(start_time, simix_global->kill_process_function, process);
-      }
-    }
   }
   current_property_set = NULL;
 }
index 326f0ae..69105c9 100644 (file)
@@ -156,6 +156,7 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
       args->code,
       args->data,
       args->hostname,
+      args->kill_time,
       args->argc,
       args->argv,
       args->properties);
@@ -177,6 +178,7 @@ void SIMIX_process_create(smx_process_t *process,
                           xbt_main_func_t code,
                           void *data,
                           const char *hostname,
+                          double kill_time,
                           int argc, char **argv,
                           xbt_dict_t properties) {
 
@@ -222,6 +224,14 @@ void SIMIX_process_create(smx_process_t *process,
     XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, host->name);
     xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
   }
+
+  if (kill_time > SIMIX_get_clock()) {
+    if (simix_global->kill_process_function) {
+      XBT_INFO("Process %s(%s) will be kill at time %f", (*process)->name,
+          (*process)->smx_host->name, kill_time);
+      SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process);
+    }
+  }
 }
 
 /**
@@ -253,7 +263,7 @@ void SIMIX_process_runall(void)
  */
 void SIMIX_process_kill(smx_process_t process) {
 
-  XBT_DEBUG("Killing process %s on %s", process->name, process->smx_host->name);
+  XBT_INFO("Killing process %s on %s", process->name, process->smx_host->name);
 
   process->context->iwannadie = 1;
   process->blocked = 0;
index 1099cca..d5295c9 100644 (file)
@@ -50,6 +50,7 @@ void SIMIX_process_create(smx_process_t *process,
                           xbt_main_func_t code,
                           void *data,
                           const char *hostname,
+                          double kill_time,
                           int argc, char **argv,
                           xbt_dict_t properties);
 void SIMIX_process_runall(void);
index df7fb25..c752587 100644 (file)
@@ -306,6 +306,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
          simcall->process_create.code,
          simcall->process_create.data,
          simcall->process_create.hostname,
+         simcall->process_create.kill_time,
          simcall->process_create.argc,
          simcall->process_create.argv,
          simcall->process_create.properties);
index a0888c1..c16c605 100644 (file)
@@ -223,6 +223,7 @@ typedef struct s_smx_simcall {
       xbt_main_func_t code;
       void *data;
       const char *hostname;
+      double kill_time;
       int argc;
       char **argv;
       xbt_dict_t properties;
index 8c08f25..2663088 100644 (file)
@@ -343,6 +343,7 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
  * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
  * It can be retrieved with the function \ref simcall_process_get_data.
  * \param hostname name of the host where the new agent is executed.
+ * \param kill_time time when the process is killed
  * \param argc first argument passed to \a code
  * \param argv second argument passed to \a code
  * \param properties the properties of the process
@@ -351,6 +352,7 @@ void simcall_process_create(smx_process_t *process, const char *name,
                               xbt_main_func_t code,
                               void *data,
                               const char *hostname,
+                              double kill_time,
                               int argc, char **argv,
                               xbt_dict_t properties)
 {
@@ -362,6 +364,7 @@ void simcall_process_create(smx_process_t *process, const char *name,
   simcall->process_create.code = code;
   simcall->process_create.data = data;
   simcall->process_create.hostname = hostname;
+  simcall->process_create.kill_time = kill_time;
   simcall->process_create.argc = argc;
   simcall->process_create.argv = argv;
   simcall->process_create.properties = properties;
index 34dba4a..db92f65 100644 (file)
@@ -66,7 +66,7 @@ xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code,
   /*   char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */
   simcall_process_create(&res->s_process, name,
                            xbt_thread_create_wrapper, res,
-                           SIMIX_host_self_get_name(), 0, NULL,
+                           SIMIX_host_self_get_name(), -1.0, 0, NULL,
                            /*props */ NULL);
   res->joinable = joinable;
   res->done = 0;