Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright notices
[simgrid.git] / src / simix / smx_deployment.c
index 3b53ec8..bb3b90b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2009-2013. The SimGrid Team.
+/* Copyright (c) 2007, 2009-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@ extern int surf_parse_lineno;
 
 static void parse_process(sg_platf_process_cbarg_t process)
 {
-  smx_host_t host = SIMIX_host_get_by_name(process->host);
+  sg_host_t host = sg_host_by_name(process->host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process->host);
   parse_code = SIMIX_get_registered_function(process->function);
@@ -36,6 +36,23 @@ static void parse_process(sg_platf_process_cbarg_t process)
   smx_process_arg_t arg = NULL;
   smx_process_t process_created = NULL;
 
+  arg = xbt_new0(s_smx_process_arg_t, 1);
+  arg->code = parse_code;
+  arg->data = NULL;
+  arg->hostname = sg_host_name(host);
+  arg->argc = process->argc;
+  arg->argv = xbt_new(char *,process->argc);
+  int i;
+  for (i=0; i<process->argc; i++)
+    arg->argv[i] = xbt_strdup(process->argv[i]);
+  arg->name = xbt_strdup(arg->argv[0]);
+  arg->kill_time = kill_time;
+  arg->properties = current_property_set;
+  if (!sg_host_simix(host)->boot_processes) {
+    sg_host_simix(host)->boot_processes = xbt_dynar_new(sizeof(smx_process_arg_t), _SIMIX_host_free_process_arg);
+  }
+  xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg);
+
   if (start_time > SIMIX_get_clock()) {
     arg = xbt_new0(s_smx_process_arg_t, 1);
     arg->name = (char*)(process->argv)[0];
@@ -54,7 +71,7 @@ static void parse_process(sg_platf_process_cbarg_t process)
     XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_name(host));
 
     if (simix_global->create_process_function)
-      simix_global->create_process_function(&process_created,
+      process_created = simix_global->create_process_function(
                                             (char*)(process->argv)[0],
                                             parse_code,
                                             NULL,
@@ -63,11 +80,11 @@ static void parse_process(sg_platf_process_cbarg_t process)
                                             process->argc,
                                             (char**)(process->argv),
                                             current_property_set,
-                                            auto_restart);
+                                            auto_restart, NULL);
     else
-      simcall_process_create(&process_created, (char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
+      process_created = simcall_process_create((char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
           (char**)process->argv, current_property_set,auto_restart);
-
+    
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
     if (!process_created) {
       return;
@@ -177,10 +194,9 @@ void SIMIX_process_set_function(const char *process_host,
                                 double process_start_time,
                                 double process_kill_time)
 {
-  s_sg_platf_process_cbarg_t process;
-  memset(&process,0,sizeof(process));
+  s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
 
-  smx_host_t host = SIMIX_host_get_by_name(process_host);
+  sg_host_t host = sg_host_by_name(process_host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
   process.host = sg_host_name(host);
@@ -203,8 +219,6 @@ void SIMIX_process_set_function(const char *process_host,
   process.host = process_host;
   process.kill_time = process_kill_time;
   process.start_time = process_start_time;
-  process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
-  process.properties = NULL;
 
   sg_platf_new_process(&process);
 }