Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
include the right files
[simgrid.git] / src / msg / deployment.c
index 87649dd..eacb7fe 100644 (file)
@@ -5,10 +5,10 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
-#include "surf/surf_parse.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "surf/surf_parse_private.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(deployment, msg,
                                "Logging specific to MSG (environment)");
 
@@ -43,8 +43,31 @@ static void parse_argument(void)
 
 static void parse_process_finalize(void)
 {
-  MSG_process_create_with_arguments(parse_argv[0], parse_code, NULL, parse_host,
-                                   parse_argc,parse_argv,start_time,kill_time);
+  process_arg_t arg = NULL;
+  m_process_t process = NULL;
+  if(start_time>MSG_get_clock()) {
+    arg = xbt_new0(s_process_arg_t,1);
+    arg->name = parse_argv[0];
+    arg->code = parse_code;
+    arg->data = NULL;
+    arg->host = parse_host;
+    arg->argc = parse_argc;
+    arg->argv = parse_argv;
+    arg-> kill_time = kill_time;
+
+    surf_timer_resource->extension_public->set(start_time, (void*) &MSG_process_create_with_arguments,
+                                              arg);
+  }
+  if((start_time<0) || (start_time==MSG_get_clock())) {
+    process = MSG_process_create_with_arguments(parse_argv[0], parse_code, 
+                                               NULL, parse_host,
+                                               parse_argc,parse_argv);
+    if(kill_time > MSG_get_clock()) {
+      surf_timer_resource->extension_public->set(kill_time, 
+                                                (void*) &MSG_process_kill,
+                                                (void*) process);
+    }
+  }
 }
 
 /** \ingroup msg_easier_life
@@ -83,7 +106,7 @@ void MSG_launch_application(const char *file)
  */
 void MSG_function_register(const char *name,m_process_code_t code)
 {
-  xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_function_register.");
+  xbt_assert0(msg_global,"MSG_global_init has to be called before MSG_function_register.");
 
   xbt_dict_set(msg_global->registered_functions,name,code,NULL);
 }
@@ -99,51 +122,10 @@ m_process_code_t MSG_get_registered_function(const char *name)
 {
   m_process_code_t code = NULL;
 
-  xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_get_registered_function.");
+  xbt_assert0(msg_global,"MSG_global_init has to be called before MSG_get_registered_function.");
  
-  xbt_dict_get(msg_global->registered_functions,name,(void **) &code);
+  code = xbt_dict_get(msg_global->registered_functions,name);
 
   return code;
 }
 
-/** \ingroup msg_easier_life
- * \brief Get the arguments of the current process.
- * \deprecated{Not useful since #m_process_code_t is int (*)(int argc, char *argv[])}
- *
- * This functions returns the values set for the current process 
- * using #MSG_set_arguments or #MSG_launch_application.
- * \param argc the number of arguments
- * \param argv the arguments table
- */
-MSG_error_t MSG_get_arguments(int *argc, char ***argv)
-{
-  m_process_t process = MSG_process_self();
-  simdata_process_t simdata = NULL;
-
-  xbt_assert0((argc) && (argv), "Invalid parameters");
-  simdata = process->simdata;
-  *argc = simdata->argc;
-  *argv = simdata->argv;
-
-  return MSG_OK;
-}
-
-/** \ingroup msg_easier_life
- * \brief Set the arguments of a process.
- *
- * This functions sets the argument number and the arguments table for a
- * proces.
- * \param process is the process you want to modify
- * \param argc the number of arguments
- * \param argv the arguments table
- */
-MSG_error_t MSG_set_arguments(m_process_t process,int argc, char *argv[])
-{
-  simdata_process_t simdata = NULL;
-
-  xbt_assert0(0,"Deprecated ! Do not use anymore. "
-             "Use MSG_process_create_with_arguments instead.\n");
-
-  return MSG_OK;
-}
-