Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'v3_9_x'
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 30 Jan 2013 16:15:42 +0000 (17:15 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 30 Jan 2013 16:15:42 +0000 (17:15 +0100)
23 files changed:
CMakeLists.txt
ChangeLog
NEWS
buildtools/Cmake/AddTests.cmake
examples/simdag/test_simdag_tracing.tesh
include/msg/msg.h
include/simgrid/simix.h
src/instr/instr_interface.c
src/msg/msg_global.c
src/msg/msg_gos.c
src/msg/msg_private.h
src/msg/msg_process.c
src/msg/msg_task.c
src/simix/smx_global.c
src/simix/smx_process.c
src/simix/smx_process_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/xbt/xbt_main.c
teshsuite/msg/CMakeLists.txt
teshsuite/msg/pid.c [new file with mode: 0644]
teshsuite/msg/pid.tesh [new file with mode: 0644]
teshsuite/msg/pid.xml [new file with mode: 0644]

index 4945197..b9c2a97 100644 (file)
@@ -53,9 +53,10 @@ set(CMAKE_Fortran_LINK_FLAGS "" CACHE TYPE INTERNAL FORCE)
 # 3.7.{0,1} -> release 3.7, 3.7.1
 # 3.8.{0,1} -> release 3.8, 3.8.1
 # 3.9.0 -> release 3.9
+# 3.10.0 -> release 3.10
 
 set(SIMGRID_VERSION_MAJOR "3")
-set(SIMGRID_VERSION_MINOR "9")
+set(SIMGRID_VERSION_MINOR "10")
 set(SIMGRID_VERSION_PATCH "0")
 
 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
index 181c147..d7b768a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+SimGrid (3.10) NOT RELEASED; urgency=low
+
+ (to complete)
+
+-- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
+
 SimGrid (3.9) stable; urgency=low
 
  The Grasgory release: GRAS is really dead now.
diff --git a/NEWS b/NEWS
index d7f271c..1f8b413 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+                    _               _____  _  ___
+__   _____ _ __ ___(_) ___  _ __   |___ / / |/ _ \
+\ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \ | | | | |
+ \ V /  __/ |  \__ \ | (_) | | | |  ___) || | |_| |
+  \_/ \___|_|  |___/_|\___/|_| |_| |____(_)_|\___/
+
+(to complete)
                     _               _____ ___
 __   _____ _ __ ___(_) ___  _ __   |___ // _ \
 \ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \ (_) |
@@ -10,7 +17,6 @@ The "Grasgory" release. Major changes:
  * Gras was completely removed from this version.
  * Documentation reorganization to ease browsing it.
  * New default value for the TCP_gamma parameter: 4MiB
-
                     _               _____  ___   _
 __   _____ _ __ ___(_) ___  _ __   |___ / ( _ ) / |
 \ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \ / _ \ | |
index 7e59b1b..25c58ca 100644 (file)
@@ -68,6 +68,15 @@ if(NOT enable_memcheck)
     ADD_TEST(tesh-msg-get-sender-ucontext       ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/get_sender.tesh)
   endif()
 
+  ADD_TEST(tesh-msg-pid-thread           ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/pid.tesh)
+  if(HAVE_RAWCTX)
+    ADD_TEST(tesh-msg-pid-raw            ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/pid.tesh)
+  endif()
+  if(CONTEXT_UCONTEXT)
+    ADD_TEST(tesh-msg-pid-ucontext       ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/pid.tesh)
+  endif()
+
+
   IF(enable_debug) # these tests need the assertion mechanism
     ADD_TEST(tesh-simdag-parser-bogus-symmetric ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms two_hosts_asymetric.tesh)
   ENDIF()
index 3fc9699..34b8439 100644 (file)
@@ -248,12 +248,12 @@ $ tail -n +3 ./simgrid.trace
 > 16 0 7 0 topology 21 22
 > 15 0 8 0 topology 21 23
 > 16 0 8 0 topology 8 23
-> 1 9 3 btaskA "0.000000 0.000985 0.041631"
-> 1 10 1 ptaskA "0.000000 0.000985 0.041631"
-> 1 11 3 btaskB "0.176643 0.364602 0.091331"
-> 1 12 1 ptaskB "0.176643 0.364602 0.091331"
-> 1 13 3 btaskC "0.092298 0.487217 0.526750"
-> 1 14 1 ptaskC "0.092298 0.487217 0.526750"
+> 1 9 3 btaskA "0.800026 0.545312 0.857926"
+> 1 10 1 ptaskA "0.800026 0.545312 0.857926"
+> 1 11 3 btaskB "0.904944 0.089118 0.069832"
+> 1 12 1 ptaskB "0.904944 0.089118 0.069832"
+> 1 13 3 btaskC "0.696799 0.247098 0.497311"
+> 1 14 1 ptaskC "0.696799 0.247098 0.497311"
 > 7 8.800300 1 10
 > 7 8.800300 1 1
 > 7 8.800300 1 3
index 41b9483..330ed56 100644 (file)
@@ -205,6 +205,9 @@ XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
 XBT_PUBLIC(double) MSG_task_get_compute_duration(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_compute_duration(msg_task_t task,
                                                double compute_duration);
+XBT_PUBLIC(void) MSG_task_set_data_size(msg_task_t task,
+                                              double data_size);
+
 XBT_PUBLIC(double) MSG_task_get_remaining_computation(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
@@ -224,12 +227,14 @@ XBT_PUBLIC(msg_error_t)
 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
 
 XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias);
+XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate);
 XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task,
                                                     const char *alias,
                                                     int (*match_fun)(void*,void*, smx_action_t),
                                                     void *match_data);
 
 XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup);
+XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate);
 XBT_PUBLIC(msg_comm_t) MSG_task_irecv(msg_task_t * task, const char *alias);
 XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
 XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms);
@@ -249,6 +254,10 @@ XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias,
 XBT_PUBLIC(msg_error_t)
     MSG_task_send_with_timeout(msg_task_t task, const char *alias,
                            double timeout);
+    
+XBT_PUBLIC(msg_error_t)
+    MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias,
+                           double timeout, double maxrate);
 
 XBT_PUBLIC(msg_error_t)
     MSG_task_send(msg_task_t task, const char *alias);
index 46763d4..c53fd4e 100644 (file)
@@ -342,7 +342,7 @@ XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
                                           int auto_restart);
 
 XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
-XBT_PUBLIC(void) simcall_process_killall(void);
+XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
 
 /* Process handling */
 XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
index 3c06b95..e18be1f 100644 (file)
@@ -111,7 +111,7 @@ void TRACE_category_with_color (const char *category, const char *color)
     snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
   }
 
-  XBT_DEBUG("CAT,declare %s, %s", category, final_color);
+  XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", category, color, final_color);
 
   //define the type of this category on top of hosts and links
   instr_new_variable_type (category, final_color);
index f40bf21..3a3ad8c 100644 (file)
@@ -46,7 +46,6 @@ void MSG_init_nocheck(int *argc, char **argv) {
 #ifdef MSG_USE_DEPRECATED
     msg_global->max_channel = 0;
 #endif
-    msg_global->PID = 1;
     msg_global->sent_msg = 0;
     msg_global->task_copy_callback = NULL;
     msg_global->process_data_cleanup = NULL;
@@ -152,14 +151,12 @@ void MSG_config(const char *key, const char *value){
  */
 int MSG_process_killall(int reset_PIDs)
 {
-  simcall_process_killall();
+  simcall_process_killall(reset_PIDs);
 
-  if (reset_PIDs > 0) {
-    msg_global->PID = reset_PIDs;
+  if (reset_PIDs > 0)
     msg_global->session++;
-  }
 
-  return msg_global->PID;
+  return 0;
 
 }
 
index bcc59e1..d5ba36e 100644 (file)
@@ -271,6 +271,25 @@ msg_comm_t MSG_task_isend(msg_task_t task, const char *alias)
   return MSG_task_isend_with_matching(task,alias,NULL,NULL);
 }
 
+/** \ingroup msg_task_usage
+ * \brief Sends a task on a mailbox with a maximum rate
+ *
+ * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test()
+ * to end the communication. The maxrate parameter allows the application
+ * to limit the bandwidth utilization of network links when sending the task.
+ *
+ * \param task a #msg_task_t to send on another location.
+ * \param alias name of the mailbox to sent the task to
+ * \param maxrate the maximum communication rate for sending this task .
+ * \return the msg_comm_t communication created
+ */
+msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate)
+{
+  task->simdata->rate = maxrate;
+  return MSG_task_isend_with_matching(task,alias,NULL,NULL);
+}
+
+
 /** \ingroup msg_task_usage
  * \brief Sends a task on a mailbox, with support for matching requests
  *
@@ -388,6 +407,66 @@ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup)
 #endif
 }
 
+
+/** \ingroup msg_task_usage
+ * \brief Sends a task on a mailbox with a maximal rate.
+ *
+ * This is a non blocking detached send function.
+ * Think of it as a best effort send. Keep in mind that the third parameter
+ * is only called if the communication fails. If the communication does work,
+ * it is responsibility of the receiver code to free anything related to
+ * the task, as usual. More details on this can be obtained on
+ * <a href="http://lists.gforge.inria.fr/pipermail/simgrid-user/2011-November/002649.html">this thread</a>
+ * in the SimGrid-user mailing list archive.
+ *
+ * \param task a #msg_task_t to send on another location.
+ * \param alias name of the mailbox to sent the task to
+ * \param cleanup a function to destroy the task if the
+ * communication fails, e.g. MSG_task_destroy
+ * (if NULL, no function will be called)
+ * \param maxrate the maximum communication rate for sending this task
+ * 
+ */
+void MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate)
+{
+  task->simdata->rate = maxrate;
+  
+  simdata_task_t t_simdata = NULL;
+  msg_process_t process = MSG_process_self();
+  msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
+
+  /* Prepare the task to send */
+  t_simdata = task->simdata;
+  t_simdata->sender = process;
+  t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
+
+  xbt_assert(t_simdata->isused == 0,
+              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+
+  t_simdata->isused = 1;
+  t_simdata->comm = NULL;
+  msg_global->sent_msg++;
+
+#ifdef HAVE_TRACING
+  int call_end = TRACE_msg_task_put_start(task);
+#endif
+
+  /* Send it by calling SIMIX network layer */
+  smx_action_t comm = simcall_comm_isend(mailbox, t_simdata->message_size,
+                       t_simdata->rate, task, sizeof(void *), NULL, cleanup, NULL, 1);
+  t_simdata->comm = comm;
+#ifdef HAVE_TRACING
+    if (TRACE_is_enabled()) {
+      simcall_set_category(comm, task->category);
+    }
+#endif
+
+#ifdef HAVE_TRACING
+  if (call_end)
+    TRACE_msg_task_put_end();
+#endif
+}
+
 /** \ingroup msg_task_usage
  * \brief Starts listening for receiving a task from an asynchronous communication.
  *
@@ -744,6 +823,29 @@ MSG_task_send_with_timeout(msg_task_t task, const char *alias,
                                       task, timeout);
 }
 
+/** \ingroup msg_task_usage
+ * \brief Sends a task to a mailbox with a timeout and with a maximum rate
+ *
+ * This is a blocking function, the execution flow will be blocked
+ * until the task is sent or the timeout is achieved.
+ *
+ * \param task the task to be sent
+ * \param alias the mailbox name to where the task is sent
+ * \param timeout is the maximum wait time for completion (if -1, this call is the same as #MSG_task_send)
+ * \param maxrate the maximum communication rate for sending this task
+ *
+ * \return Returns #MSG_OK if the task was successfully sent,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise.
+ */
+msg_error_t
+MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias,
+                           double timeout, double maxrate)
+{
+  task->simdata->rate = maxrate;
+  return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias),
+                                      task, timeout);
+}
+
 /** \ingroup msg_task_usage
  * \brief Check if there is a communication going on in a mailbox.
  *
index b7801c9..cbc10c8 100644 (file)
@@ -58,8 +58,6 @@ typedef struct simdata_gpu_task {
 
 typedef struct simdata_process {
   msg_host_t m_host;              /* the host on which the process is running */
-  int PID;                      /* used for debugging purposes */
-  int PPID;                     /* The parent PID */
   msg_host_t put_host;            /* used for debugging purposes */
 #ifdef MSG_USE_DEPRECATED
   m_channel_t put_channel;      /* used for debugging purposes */
@@ -112,7 +110,6 @@ typedef struct MSG_Global {
 #ifdef MSG_USE_DEPRECATED
   int max_channel;
 #endif
-  int PID;
   int session;
   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
   void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
index cf7ce52..097cfaa 100644 (file)
@@ -162,7 +162,6 @@ msg_process_t MSG_process_create_with_environment(const char *name,
   msg_process_t process;
 
   /* Simulator data for MSG */
-  simdata->PID = msg_global->PID++;
   simdata->waiting_action = NULL;
   simdata->waiting_task = NULL;
   simdata->m_host = host;
@@ -171,23 +170,17 @@ msg_process_t MSG_process_create_with_environment(const char *name,
   simdata->data = data;
   simdata->last_errno = MSG_OK;
 
-  if (SIMIX_process_self()) {
-    simdata->PPID = MSG_process_get_PID(MSG_process_self());
-  } else {
-    simdata->PPID = -1;
-  }
-
-#ifdef HAVE_TRACING
-  TRACE_msg_process_create(name, simdata->PID, simdata->m_host);
-#endif
   /* 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, sg_host_name(host), -1,
                            argc, argv, properties,0);
 
+  #ifdef HAVE_TRACING
+    TRACE_msg_process_create(name, simcall_process_get_PID(process), simdata->m_host);
+  #endif
+
   if (!process) {
     /* Undo everything we have just changed */
-    msg_global->PID--;
     xbt_free(simdata);
     return NULL;
   }
@@ -344,10 +337,7 @@ int MSG_process_get_PID(msg_process_t process)
   if (process == NULL) {
     return 0;
   }
-
-  simdata_process_t simdata = simcall_process_get_data(process);
-
-  return simdata != NULL ? simdata->PID : 0;
+  return simcall_process_get_PID(process);
 }
 
 /** \ingroup m_process_management
@@ -361,9 +351,7 @@ int MSG_process_get_PPID(msg_process_t process)
 {
   xbt_assert(process != NULL, "Invalid parameter");
 
-  simdata_process_t simdata = simcall_process_get_data(process);
-
-  return simdata->PPID;
+  return simcall_process_get_PPID(process);
 }
 
 /** \ingroup m_process_management
index 101689c..a32e0d8 100644 (file)
@@ -342,6 +342,23 @@ void MSG_task_set_compute_duration(msg_task_t task,
 
 }
 
+/** \ingroup m_task_management
+ * \brief set the amount data attached with a task #msg_task_t.
+ *
+ * \warning If the transfer is ongoing (already started and not finished),
+ * it is not modified by this call. 
+ */
+
+void MSG_task_set_data_size(msg_task_t task,
+                                   double data_size)
+{
+  xbt_assert(task, "Invalid parameter");
+  task->simdata->message_size = data_size;
+
+}
+
+
+
 /** \ingroup m_task_management
  * \brief Returns the remaining computation amount of a task #msg_task_t.
  *
index 6c0623c..7cd414d 100644 (file)
@@ -124,7 +124,7 @@ static void SIMIX_clean(void)
 #endif
 
   /* Kill everyone (except maestro) */
-  SIMIX_process_killall(simix_global->maestro_process);
+  SIMIX_process_killall(simix_global->maestro_process, 1);
 
   /* Exit the SIMIX network module */
   SIMIX_network_exit();
index 6172807..ff48a35 100644 (file)
@@ -144,6 +144,12 @@ void SIMIX_create_maestro_process()
   maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro);
   maestro->simcall.issuer = maestro;
 
+  if (SIMIX_process_self()) {
+    maestro->ppid = SIMIX_process_get_PID(SIMIX_process_self());
+  } else {
+    maestro->ppid = -1;
+  }
+
   simix_global->maestro_process = maestro;
   return;
 }
@@ -249,6 +255,12 @@ void SIMIX_process_create(smx_process_t *process,
     (*process)->comms = xbt_fifo_new();
     (*process)->simcall.issuer = *process;
     
+     if (SIMIX_process_self()) {
+       (*process)->ppid = SIMIX_process_get_PID(SIMIX_process_self());
+     } else {
+       (*process)->ppid = -1;
+     }
+
     /* Process data for auto-restart */
     (*process)->auto_restart = auto_restart;
     (*process)->code = code;
@@ -370,14 +382,14 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
 
 }
 
-void SIMIX_pre_process_killall(smx_simcall_t simcall) {
-  SIMIX_process_killall(simcall->issuer);
+void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid) {
+  SIMIX_process_killall(simcall->issuer, reset_pid);
 }
 /**
  * \brief Kills all running processes.
  * \param issuer this one will not be killed
  */
-void SIMIX_process_killall(smx_process_t issuer)
+void SIMIX_process_killall(smx_process_t issuer, int reset_pid)
 {
   smx_process_t p = NULL;
 
@@ -387,6 +399,9 @@ void SIMIX_process_killall(smx_process_t issuer)
     }
   }
 
+  if (reset_pid > 0)
+    simix_process_maxpid = reset_pid;
+
   SIMIX_context_runall();
 
   SIMIX_process_empty_trash();
@@ -538,6 +553,28 @@ int SIMIX_process_count(void)
   return xbt_swag_size(simix_global->process_list);
 }
 
+int SIMIX_pre_process_get_PID(smx_simcall_t simcall, smx_process_t self){
+   return SIMIX_process_get_PID(self);
+}
+
+int SIMIX_process_get_PID(smx_process_t self){
+  if (self == NULL)
+    return 0;
+  else
+    return self->pid;
+}
+
+int SIMIX_pre_process_get_PPID(smx_simcall_t simcall, smx_process_t self){
+  return SIMIX_process_get_PPID(self);
+}
+
+int SIMIX_process_get_PPID(smx_process_t self){
+  if (self == NULL)
+    return 0;
+  else
+    return self->ppid;
+}
+
 void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t self){
   return SIMIX_process_self_get_data(self);    
 }
index 414d8b1..de9b038 100644 (file)
@@ -36,6 +36,7 @@ typedef struct s_smx_process {
   s_xbt_swag_hookup_t destroy_hookup;
 
   unsigned long pid;
+  unsigned long ppid;
   char *name;                   /**< @brief process name if any */
   smx_host_t smx_host;          /* the host on which the process is running */
   smx_context_t context;        /* the context (uctx/raw/thread) that executes the user function */
@@ -72,7 +73,7 @@ void SIMIX_process_create(smx_process_t *process,
                           int auto_restart);
 void SIMIX_process_runall(void);
 void SIMIX_process_kill(smx_process_t process, smx_process_t issuer);
-void SIMIX_process_killall(smx_process_t issuer);
+void SIMIX_process_killall(smx_process_t issuer, int reset_pid);
 smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args);
 void SIMIX_create_maestro_process(void);
 void SIMIX_process_stop(smx_process_t arg);
@@ -88,6 +89,7 @@ void SIMIX_process_change_host(smx_process_t process,
 void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process);
 smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer);
 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer);
+int SIMIX_process_get_PID(smx_process_t self);
 void* SIMIX_process_get_data(smx_process_t process);
 void SIMIX_process_set_data(smx_process_t process, void *data);
 smx_host_t SIMIX_process_get_host(smx_process_t process);
@@ -111,11 +113,12 @@ void SIMIX_pre_process_create(smx_simcall_t simcall, smx_process_t *process,
                              const char *hostname, double kill_time, int argc,
                              char **argv, xbt_dict_t properties, int auto_restart);
 void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process);
-void SIMIX_pre_process_killall(smx_simcall_t simcall);
+void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid);
 void SIMIX_pre_process_cleanup(smx_simcall_t simcall, smx_process_t process);
 void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process);
 int SIMIX_pre_process_count(smx_simcall_t simcall);
 void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t process);
+int SIMIX_pre_process_get_PID(smx_simcall_t simcall, smx_process_t self);
 void* SIMIX_pre_process_get_data(smx_simcall_t simcall, smx_process_t process);
 void SIMIX_pre_process_set_data(smx_simcall_t simcall, smx_process_t process,
                                 void *data);
index a418dd0..aaa090f 100644 (file)
@@ -276,12 +276,14 @@ ACTION(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_AN
 ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
 ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
-ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result)) sep \
+ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result), TINT(reset_pid)) sep \
 ACTION(SIMCALL_PROCESS_CLEANUP, process_cleanup, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_CHANGE_HOST, process_change_host, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TSPEC(dest, smx_host_t)) sep \
 ACTION(SIMCALL_PROCESS_SUSPEND, process_suspend, WITHOUT_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_RESUME, process_resume, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_COUNT, process_count, WITH_ANSWER, TINT(result)) sep \
+ACTION(SIMCALL_PROCESS_GET_PID, process_get_PID, WITH_ANSWER, TINT(result), TSPEC(process, smx_process_t)) sep  \
+ACTION(SIMCALL_PROCESS_GET_PPID, process_get_PPID, WITH_ANSWER, TINT(result), TSPEC(process, smx_process_t)) sep  \
 ACTION(SIMCALL_PROCESS_GET_DATA, process_get_data, WITH_ANSWER, TPTR(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_SET_DATA, process_set_data, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TPTR(data)) sep \
 ACTION(SIMCALL_PROCESS_GET_HOST, process_get_host, WITH_ANSWER, TSPEC(result, smx_host_t), TSPEC(process, smx_process_t)) sep \
index 15fca99..b9099f5 100644 (file)
@@ -323,9 +323,9 @@ void simcall_process_kill(smx_process_t process)
  * \ingroup simix_process_management
  * \brief Kills all SIMIX processes.
  */
-void simcall_process_killall(void)
+void simcall_process_killall(int reset_pid)
 {
-  simcall_BODY_process_killall();
+  simcall_BODY_process_killall(reset_pid);
 }
 
 /**
@@ -393,6 +393,38 @@ int simcall_process_count(void)
   return simcall_BODY_process_count();
 }
 
+/**
+ * \ingroup simix_process_management
+ * \brief Return the PID of a #smx_process_t.
+ * \param process a SIMIX process
+ * \return the PID of this process
+ */
+int simcall_process_get_PID(smx_process_t process)
+{
+  if (process == SIMIX_process_self()) {
+    /* avoid a simcall if this function is called by the process itself */
+    return SIMIX_process_get_PID(process);
+  }
+
+  return simcall_BODY_process_get_PID(process);
+}
+
+/**
+ * \ingroup simix_process_management
+ * \brief Return the parent PID of a #smx_process_t.
+ * \param process a SIMIX process
+ * \return the PID of this process parenrt
+ */
+int simcall_process_get_PPID(smx_process_t process)
+{
+  if (process == SIMIX_process_self()) {
+    /* avoid a simcall if this function is called by the process itself */
+    return SIMIX_process_get_PPID(process);
+  }
+
+  return simcall_BODY_process_get_PPID(process);
+}
+
 /**
  * \ingroup simix_process_management
  * \brief Return the user data of a #smx_process_t.
index 89a67a6..e09d03d 100644 (file)
@@ -35,6 +35,7 @@ int xbt_initialized = 0;
  */
 static void xbt_preinit(void) _XBT_GNUC_CONSTRUCTOR(200);
 static void xbt_postexit(void);
+static unsigned int seed = 2147483647;
 
 #ifdef _XBT_WIN32
 # undef _XBT_NEED_INIT_PRAGMA
@@ -118,8 +119,9 @@ void xbt_init(int *argc, char **argv)
     xbt_dynar_push(xbt_cmdline,&(argv[i]));
   }
 
-  srand((unsigned int) time(NULL));
-
+  srand(seed);
+  srand48(seed);
+  
   xbt_log_init(argc, argv);
 }
 
index 4f22b3c..eeb9d84 100644 (file)
@@ -3,17 +3,21 @@ cmake_minimum_required(VERSION 2.6)
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
 add_executable(get_sender ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/get_sender.c)
+add_executable(pid ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/pid.c)
 
 ### Add definitions for compile
 if(NOT WIN32)
-  target_link_libraries(get_sender simgrid m pthread )
+  target_link_libraries(get_sender simgrid)
+  target_link_libraries(pid simgrid m pthread)
 else()
   target_link_libraries(get_sender simgrid)
+  target_link_libraries(pid simgrid)
 endif()
 
 set(tesh_files
   ${tesh_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/get_sender.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/pid.tesh
   PARENT_SCOPE
   )
 set(xml_files
@@ -21,11 +25,13 @@ set(xml_files
   ${CMAKE_CURRENT_SOURCE_DIR}/get_sender.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/get_sender_d.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/get_sender_p.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/pid.xml
   PARENT_SCOPE
   )
 set(teshsuite_src
   ${teshsuite_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/get_sender.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/pid.c
   PARENT_SCOPE
   )
 set(bin_files
diff --git a/teshsuite/msg/pid.c b/teshsuite/msg/pid.c
new file mode 100644 (file)
index 0000000..1f04fb2
--- /dev/null
@@ -0,0 +1,65 @@
+/* Copyright (c) 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* 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 "msg/msg.h"
+#include "xbt/sysdep.h"        
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
+char* mailbox = "mailbox";
+#define task_comp_size 1000
+#define task_comm_size 100000
+
+int onexit(void* data){
+  XBT_INFO("Process \"%d\" killed.", *((int*)data));  
+}
+
+int sendpid(int argc, char *argv[])
+{
+  int pid = MSG_process_self_PID();
+  MSG_process_on_exit(onexit, &pid);  
+  msg_task_t task = MSG_task_create("pid", task_comp_size, task_comm_size, &pid);
+  XBT_INFO("Sending pid of \"%d\".", pid);
+  MSG_task_send(task, mailbox);
+  XBT_INFO("Send of pid \"%d\" done.", pid);
+  MSG_process_suspend(MSG_process_self());
+}
+
+int killall(int argc, char *argv[]){
+  msg_task_t task = NULL;
+  _XBT_GNUC_UNUSED int res;
+  int i;
+  for (i=0; i<3;i++) {
+    res = MSG_task_receive(&(task), mailbox);
+    int pid = *((int*)MSG_task_get_data(task));
+    XBT_INFO("Killing process \"%d\".", pid);
+    MSG_process_kill(MSG_process_from_PID(pid));
+    task = NULL;
+  }
+}
+
+/** Main function */
+int main(int argc, char *argv[])
+{
+  msg_error_t res = MSG_OK;
+
+  MSG_init(&argc, argv);
+
+  /*   Application deployment */
+  MSG_function_register("sendpid", &sendpid);
+  MSG_function_register("killall", &killall);
+
+  MSG_process_killall(atoi(argv[2]));
+
+  MSG_create_environment(argv[1]);
+  MSG_launch_application(argv[1]);
+  res = MSG_main();
+
+  if (res == MSG_OK)
+    return 0;
+  else
+    return 1;
+}
diff --git a/teshsuite/msg/pid.tesh b/teshsuite/msg/pid.tesh
new file mode 100644 (file)
index 0000000..04b6943
--- /dev/null
@@ -0,0 +1,27 @@
+$ msg/pid ${srcdir:=.}/msg/pid.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:sendpid@toto) Sending pid of "1".
+> [  0.000000] (2:sendpid@toto) Sending pid of "2".
+> [  0.000000] (3:sendpid@toto) Sending pid of "3".
+> [  0.001082] (4:killall@toto) Killing process "1".
+> [  0.001082] (1:sendpid@toto) Send of pid "1" done.
+> [  0.001082] (1:sendpid@toto) Process "1" killed.
+> [  0.002165] (2:sendpid@toto) Send of pid "2" done.
+> [  0.002165] (4:killall@toto) Killing process "2".
+> [  0.002165] (2:sendpid@toto) Process "2" killed.
+> [  0.003247] (3:sendpid@toto) Send of pid "3" done.
+> [  0.003247] (4:killall@toto) Killing process "3".
+> [  0.003247] (3:sendpid@toto) Process "3" killed.
+
+$ msg/pid ${srcdir:=.}/msg/pid.xml 2 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (2:sendpid@toto) Sending pid of "2".
+> [  0.000000] (3:sendpid@toto) Sending pid of "3".
+> [  0.000000] (4:sendpid@toto) Sending pid of "4".
+> [  0.001082] (5:killall@toto) Killing process "2".
+> [  0.001082] (2:sendpid@toto) Send of pid "2" done.
+> [  0.001082] (2:sendpid@toto) Process "2" killed.
+> [  0.002165] (3:sendpid@toto) Send of pid "3" done.
+> [  0.002165] (5:killall@toto) Killing process "3".
+> [  0.002165] (3:sendpid@toto) Process "3" killed.
+> [  0.003247] (4:sendpid@toto) Send of pid "4" done.
+> [  0.003247] (5:killall@toto) Killing process "4".
+> [  0.003247] (4:sendpid@toto) Process "4" killed.
diff --git a/teshsuite/msg/pid.xml b/teshsuite/msg/pid.xml
new file mode 100644 (file)
index 0000000..8b7d1d8
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+   <!-- Platform -->
+ <AS  id="AS0"  routing="Full">
+   <host id="toto" power="1000000"/>
+   <link id="lb" bandwidth="100000000" latency="0.000000"/>
+   <route src="toto" dst="toto"><link_ctn id="lb"/></route>    
+  </AS>  
+   
+   <!-- Deployment -->
+   <process host="toto" function="sendpid"/>
+   <process host="toto" function="sendpid"/>
+   <process host="toto" function="sendpid"/>
+   <process host="toto" function="killall"/>
+
+ </platform>