Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master', remote branch 'git-hub-cristian/master'
[simgrid.git] / src / simix / smx_user.c
index 7846058..5b58220 100644 (file)
@@ -345,8 +345,18 @@ void SIMIX_req_process_kill(smx_process_t process)
   SIMIX_request_push();
 }
 
+/** \brief Kills all SIMIX processes.
+ */
+void SIMIX_req_process_killall(void)
+{
+  smx_req_t req = SIMIX_req_mine();
+
+  req->call = REQ_PROCESS_KILLALL;
+  SIMIX_request_push();
+}
+
 /** \brief Cleans up a SIMIX process.
- * \param process poor victim
+ * \param process poor victim (must have already been killed)
  */
 void SIMIX_req_process_cleanup(smx_process_t process)
 {
@@ -366,13 +376,12 @@ void SIMIX_req_process_cleanup(smx_process_t process)
  * \param source name of the previous host
  * \param dest name of the new host
  */
-void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
+void SIMIX_req_process_change_host(smx_process_t process, smx_host_t dest)
 {
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_PROCESS_CHANGE_HOST;
   req->process_change_host.process = process;
-  req->process_change_host.source = source;
   req->process_change_host.dest = dest;
   SIMIX_request_push();
 }
@@ -387,7 +396,7 @@ void SIMIX_req_process_change_host(smx_process_t process, const char *source, co
  */
 void SIMIX_req_process_suspend(smx_process_t process)
 {
-  xbt_assert0(process, "Invalid parameters");
+  xbt_assert(process, "Invalid parameters");
 
   smx_req_t req = SIMIX_req_mine();
 
@@ -436,6 +445,11 @@ int SIMIX_req_process_count(void)
  */
 void* SIMIX_req_process_get_data(smx_process_t process)
 {
+  if (process == SIMIX_process_self()) {
+    /* avoid a request if this function is called by the process itself */
+    return SIMIX_process_self_get_data();
+  }
+
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_PROCESS_GET_DATA;
@@ -453,12 +467,19 @@ void* SIMIX_req_process_get_data(smx_process_t process)
  */
 void SIMIX_req_process_set_data(smx_process_t process, void *data)
 {
-  smx_req_t req = SIMIX_req_mine();
+  if (process == SIMIX_process_self()) {
+    /* avoid a request if this function is called by the process itself */
+    SIMIX_process_self_set_data(data);
+  }
+  else {
 
-  req->call = REQ_PROCESS_SET_DATA;
-  req->process_set_data.process = process;
-  req->process_set_data.data = data;
-  SIMIX_request_push();
+    smx_req_t req = SIMIX_req_mine();
+
+    req->call = REQ_PROCESS_SET_DATA;
+    req->process_set_data.process = process;
+    req->process_set_data.data = data;
+    SIMIX_request_push();
+  }
 }
 
 /**
@@ -487,6 +508,11 @@ smx_host_t SIMIX_req_process_get_host(smx_process_t process)
  */
 const char* SIMIX_req_process_get_name(smx_process_t process)
 {
+  if (process == SIMIX_process_self()) {
+    /* avoid a request if this function is called by the process itself */
+    return process->name;
+  }
+
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_PROCESS_GET_NAME;
@@ -579,7 +605,7 @@ void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
 
 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
 {
-  xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
+  xbt_assert(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
 
   /* FIXME: this is a horrible lost of performance, so we hack it out by
    * skipping the request (for now). It won't work on distributed but
@@ -634,7 +660,7 @@ void SIMIX_req_comm_send(smx_rdv_t rdv, double task_size, double rate,
                          int (*match_fun)(void *, void *), void *data,
                          double timeout)
 {
-  xbt_assert0(rdv, "No rendez-vous point defined for send");
+  xbt_assert(rdv, "No rendez-vous point defined for send");
 
   if (MC_IS_ENABLED) {
     /* the model-checker wants two separate requests */
@@ -664,7 +690,7 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
                               int (*match_fun)(void *, void *), void *data,
                               int detached)
 {
-  xbt_assert0(rdv, "No rendez-vous point defined for isend");
+  xbt_assert(rdv, "No rendez-vous point defined for isend");
 
   smx_req_t req = SIMIX_req_mine();
 
@@ -685,7 +711,7 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
 void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
                          int (*match_fun)(void *, void *), void *data, double timeout)
 {
-  xbt_assert0(rdv, "No rendez-vous point defined for recv");
+  xbt_assert(rdv, "No rendez-vous point defined for recv");
 
   if (MC_IS_ENABLED) {
     /* the model-checker wants two separate requests */
@@ -711,7 +737,7 @@ void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
                                   int (*match_fun)(void *, void *), void *data)
 {
-  xbt_assert0(rdv, "No rendez-vous point defined for irecv");
+  xbt_assert(rdv, "No rendez-vous point defined for irecv");
 
   smx_req_t req = SIMIX_req_mine();
 
@@ -728,7 +754,7 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
 
 void SIMIX_req_comm_destroy(smx_action_t comm)
 {
-  xbt_assert0(comm, "Invalid parameter");
+  xbt_assert(comm, "Invalid parameter");
 
   /* FIXME remove this request type: comms are auto-destroyed now,
    * but what happens with unfinished comms? */