Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make msg_process_t point onto s4u::Actor*
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 13 Mar 2017 02:02:32 +0000 (03:02 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 13 Mar 2017 02:15:47 +0000 (03:15 +0100)
One day, all msg_blah_t will point to s4u::Blah*.

(I'm glad it worked: that's the second time I attempt this improvement!)

Other changes on the way:
- change the prototype of MSG_host_get_process_list():
  it was returning the internal list, but this one contains smx_actor_t,
  not msg_process_t as we can handle from the public interface
- convert a C test in teshsuite to C++ (even if I could have avoided this)

15 files changed:
include/simgrid/msg.h
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.h
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_process.cpp
src/msg/instr_msg_process.cpp
src/msg/msg_gos.cpp
src/msg/msg_host.cpp
src/msg/msg_process.cpp
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.hpp
teshsuite/msg/CMakeLists.txt
teshsuite/msg/host_on_off/host_on_off.c
teshsuite/msg/pid/pid.c
teshsuite/msg/process/process.cpp [moved from teshsuite/msg/process/process.c with 80% similarity]

index 8bf566d..0c0a6bb 100644 (file)
@@ -134,7 +134,7 @@ typedef struct msg_comm *msg_comm_t;
     structure, but always use the provided API to interact with
     processes.
  */
     structure, but always use the provided API to interact with
     processes.
  */
-typedef smx_actor_t msg_process_t;
+typedef s4u_Actor* msg_process_t;
 
 /** @brief Return code of most MSG functions
     @ingroup msg_simulation
 
 /** @brief Return code of most MSG functions
     @ingroup msg_simulation
@@ -241,7 +241,7 @@ XBT_PUBLIC(void) MSG_host_off(msg_host_t host);
 XBT_PUBLIC(msg_host_t) MSG_host_self();
 XBT_PUBLIC(double) MSG_host_get_speed(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
 XBT_PUBLIC(msg_host_t) MSG_host_self();
 XBT_PUBLIC(double) MSG_host_get_speed(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
-XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
+XBT_PUBLIC(void) MSG_host_get_process_list(msg_host_t h, xbt_dynar_t whereto);
 XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
 
 XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
 
index 9b28492..c7acc5b 100644 (file)
@@ -244,7 +244,6 @@ public:
   /** Ask kindly to all actors to die. Only the issuer will survive. */
   static void killAll();
 
   /** Ask kindly to all actors to die. Only the issuer will survive. */
   static void killAll();
 
-protected:
   /** Returns the internal implementation of this actor */
   simix::ActorImpl* getImpl();
 };
   /** Returns the internal implementation of this actor */
   simix::ActorImpl* getImpl();
 };
index 69c50e7..6a3abc9 100644 (file)
@@ -39,9 +39,9 @@ namespace context {
 }
 }
 
 }
 }
 
-typedef simgrid::kernel::context::Context *smx_context_t;
-typedef simgrid::simix::ActorImpl *smx_actor_t;
-typedef simgrid::simix::Mutex   *smx_mutex_t;
+typedef simgrid::kernel::context::Contextsmx_context_t;
+typedef simgrid::simix::ActorImplsmx_actor_t;
+typedef simgrid::simix::Mutexsmx_mutex_t;
 typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
 
 #else
 typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
 
 #else
index bd23d38..56ba7ab 100644 (file)
@@ -329,7 +329,7 @@ void java_main_jprocess(jobject jprocess)
   JNIEnv *env = get_current_thread_env();
   simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
   context->jprocess = jprocess;
   JNIEnv *env = get_current_thread_env();
   simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
   context->jprocess = jprocess;
-  smx_actor_t process = SIMIX_process_self();
+  msg_process_t process = MSG_process_self();
   jprocess_bind(context->jprocess, process, env);
 
   // Adrien, ugly path, just to bypass creation of context at low levels (i.e such as for the VM migration for instance)
   jprocess_bind(context->jprocess, process, env);
 
   // Adrien, ugly path, just to bypass creation of context at low levels (i.e such as for the VM migration for instance)
index 3181faf..4d0b4b6 100644 (file)
@@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject
 
   /* Actually build the MSG process */
   process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int {
 
   /* Actually build the MSG process */
   process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int {
-              smx_actor_t process = SIMIX_process_self();
+              msg_process_t process = MSG_process_self();
               // This is the jprocess passed as environment.
               // It would be simpler if we could use a closure.
               jobject jprocess = (jobject) MSG_process_get_data(process);
               // This is the jprocess passed as environment.
               // It would be simpler if we could use a closure.
               jobject jprocess = (jobject) MSG_process_get_data(process);
index 6243a29..8bb5b20 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
 
 char *instr_process_id (msg_process_t proc, char *str, int len)
 {
 
 char *instr_process_id (msg_process_t proc, char *str, int len)
 {
-  return instr_process_id_2 (proc->name.c_str(), proc->pid, str, len);//MSG_process_get_name(proc), MSG_process_get_PID(proc), str, len);
+  return instr_process_id_2 (proc->cname(), proc->pid(), str, len);
 }
 
 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len)
 }
 
 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len)
@@ -82,7 +82,7 @@ void TRACE_msg_process_kill(smx_process_exit_status_t status, msg_process_t proc
 {
   if (TRACE_msg_process_is_enabled() && status==SMX_EXIT_FAILURE){
     //kill means that this process no longer exists, let's destroy it
 {
   if (TRACE_msg_process_is_enabled() && status==SMX_EXIT_FAILURE){
     //kill means that this process no longer exists, let's destroy it
-    TRACE_msg_process_destroy(process->name.c_str(), process->pid);
+    TRACE_msg_process_destroy(process->cname(), process->pid());
   }
 }
 
   }
 }
 
index bab4a4d..288732a 100644 (file)
@@ -269,7 +269,7 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d
 
   /* Try to receive it by calling SIMIX network layer */
   try {
 
   /* Try to receive it by calling SIMIX network layer */
   try {
-    simcall_comm_recv(MSG_process_self(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
+    simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
     XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
     (*task)->simdata->setNotUsed();
   }
     XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
     (*task)->simdata->setNotUsed();
   }
@@ -302,7 +302,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al
                                                      void *match_data, void_f_pvoid_t cleanup, int detached)
 {
   simdata_task_t t_simdata = nullptr;
                                                      void *match_data, void_f_pvoid_t cleanup, int detached)
 {
   simdata_task_t t_simdata = nullptr;
-  msg_process_t myself = SIMIX_process_self();
+  msg_process_t myself = MSG_process_self();
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(alias);
   int call_end = TRACE_msg_task_put_start(task);
 
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(alias);
   int call_end = TRACE_msg_task_put_start(task);
 
@@ -315,7 +315,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al
   msg_global->sent_msg++;
 
   /* Send it by calling SIMIX network layer */
   msg_global->sent_msg++;
 
   /* Send it by calling SIMIX network layer */
-  smx_activity_t act = simcall_comm_isend(myself, mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate,
+  smx_activity_t act = simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate,
                                          task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached);
   t_simdata->comm = static_cast<simgrid::kernel::activity::Comm*>(act);
 
                                          task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached);
   t_simdata->comm = static_cast<simgrid::kernel::activity::Comm*>(act);
 
@@ -469,7 +469,7 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rat
   comm->task_sent = nullptr;
   comm->task_received = task;
   comm->status = MSG_OK;
   comm->task_sent = nullptr;
   comm->task_received = task;
   comm->status = MSG_OK;
-  comm->s_comm = simcall_comm_irecv(MSG_process_self(), mbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, rate);
+  comm->s_comm = simcall_comm_irecv(SIMIX_process_self(), mbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, rate);
 
   return comm;
 }
 
   return comm;
 }
@@ -715,7 +715,7 @@ void MSG_comm_copy_data_from_SIMIX(smx_activity_t synchro, void* buff, size_t bu
   // notify the user callback if any
   if (msg_global->task_copy_callback) {
     msg_task_t task = static_cast<msg_task_t>(buff);
   // notify the user callback if any
   if (msg_global->task_copy_callback) {
     msg_task_t task = static_cast<msg_task_t>(buff);
-    msg_global->task_copy_callback(task, comm->src_proc, comm->dst_proc);
+    msg_global->task_copy_callback(task, comm->src_proc->ciface(), comm->dst_proc->ciface());
   }
 }
 
   }
 }
 
index 3d68513..968ae5d 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/storage.hpp"
 #include "src/msg/msg_private.h"
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/storage.hpp"
 #include "src/msg/msg_private.h"
+#include "src/simix/ActorImpl.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
 
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
 
@@ -139,12 +140,16 @@ int MSG_host_get_core_number(msg_host_t host) {
  * \brief Return the list of processes attached to an host.
  *
  * \param host a host
  * \brief Return the list of processes attached to an host.
  *
  * \param host a host
- * \return a swag with the attached processes
+ * \param whereto a dynar in which we should push processes living on that host
  */
  */
-xbt_swag_t MSG_host_get_process_list(msg_host_t host)
+void MSG_host_get_process_list(msg_host_t host, xbt_dynar_t whereto)
 {
   xbt_assert((host != nullptr), "Invalid parameters");
 {
   xbt_assert((host != nullptr), "Invalid parameters");
-  return host->processes();
+  smx_actor_t actor = NULL;
+  xbt_swag_foreach(actor, host->processes()) {
+    msg_process_t p = actor->ciface();
+    xbt_dynar_push(whereto, &p);
+  }
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
index eeb3719..cf9d6cc 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2017. 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. */
 
 /* 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. */
@@ -55,7 +54,7 @@ smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::function<void()
                                           xbt_dict_t properties, smx_actor_t parent_process)
 {
   msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
                                           xbt_dict_t properties, smx_actor_t parent_process)
 {
   msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
-  return p;
+  return p ? p->getImpl() : nullptr;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -138,7 +137,7 @@ msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<vo
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
   simgrid::MsgActorExt* msgExt = new simgrid::MsgActorExt(data);
 
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
   simgrid::MsgActorExt* msgExt = new simgrid::MsgActorExt(data);
 
-  msg_process_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
+  smx_actor_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
 
   if (!process) { /* Undo everything */
     delete msgExt;
 
   if (!process) { /* Undo everything */
     delete msgExt;
@@ -146,7 +145,7 @@ msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<vo
   }
 
   simcall_process_on_exit(process, (int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process);
   }
 
   simcall_process_on_exit(process, (int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process);
-  return process;
+  return process->ciface();
 }
 
 SG_BEGIN_DECL()
 }
 
 SG_BEGIN_DECL()
@@ -163,12 +162,11 @@ msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host,
   xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
   xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
-  msg_process_t process =
-      SIMIX_process_attach(name, new simgrid::MsgActorExt(data), host->cname(), properties, nullptr);
+  smx_actor_t process = SIMIX_process_attach(name, new simgrid::MsgActorExt(data), host->cname(), properties, nullptr);
   if (!process)
     xbt_die("Could not attach");
   simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
   if (!process)
     xbt_die("Could not attach");
   simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
-  return process;
+  return process->ciface();
 }
 
 /** Detach a process attached with `MSG_process_attach()`
 }
 
 /** Detach a process attached with `MSG_process_attach()`
@@ -189,7 +187,7 @@ void MSG_process_detach()
  */
 void MSG_process_kill(msg_process_t process)
 {
  */
 void MSG_process_kill(msg_process_t process)
 {
-  simcall_process_kill(process);
+  simcall_process_kill(process->getImpl());
 }
 
 /**
 }
 
 /**
@@ -199,7 +197,7 @@ void MSG_process_kill(msg_process_t process)
 * \param timeout wait until the process is over, or the timeout occurs
 */
 msg_error_t MSG_process_join(msg_process_t process, double timeout){
 * \param timeout wait until the process is over, or the timeout occurs
 */
 msg_error_t MSG_process_join(msg_process_t process, double timeout){
-  simcall_process_join(process, timeout);
+  simcall_process_join(process->getImpl(), timeout);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -212,7 +210,7 @@ msg_error_t MSG_process_join(msg_process_t process, double timeout){
 msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
 {
   TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
 msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
 {
   TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
-  simcall_process_set_host(process, host);
+  simcall_process_set_host(process->getImpl(), host);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -232,7 +230,7 @@ void* MSG_process_get_data(msg_process_t process)
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
-  simgrid::MsgActorExt* msgExt = (simgrid::MsgActorExt*)process->data;
+  simgrid::MsgActorExt* msgExt = (simgrid::MsgActorExt*)process->getImpl()->data;
   if (msgExt)
     return msgExt->data;
   else
   if (msgExt)
     return msgExt->data;
   else
@@ -248,7 +246,7 @@ msg_error_t MSG_process_set_data(msg_process_t process, void *data)
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
-  static_cast<simgrid::MsgActorExt*>(process->data)->data = data;
+  static_cast<simgrid::MsgActorExt*>(process->getImpl()->data)->data = data;
 
   return MSG_OK;
 }
 
   return MSG_OK;
 }
@@ -269,9 +267,9 @@ XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) {
 msg_host_t MSG_process_get_host(msg_process_t process)
 {
   if (process == nullptr) {
 msg_host_t MSG_process_get_host(msg_process_t process)
 {
   if (process == nullptr) {
-    return MSG_process_self()->host;
+    return SIMIX_process_self()->host;
   } else {
   } else {
-    return process->host;
+    return process->getImpl()->host;
   }
 }
 
   }
 }
 
@@ -285,7 +283,7 @@ msg_host_t MSG_process_get_host(msg_process_t process)
  */
 msg_process_t MSG_process_from_PID(int PID)
 {
  */
 msg_process_t MSG_process_from_PID(int PID)
 {
-  return SIMIX_process_from_PID(PID);
+  return SIMIX_process_from_PID(PID)->ciface();
 }
 
 /** @brief returns a list of all currently existing processes */
 }
 
 /** @brief returns a list of all currently existing processes */
@@ -307,7 +305,7 @@ int MSG_process_get_number()
  */
 msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time)
 {
  */
 msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time)
 {
-  simcall_process_set_kill_time(process,kill_time);
+  simcall_process_set_kill_time(process->getImpl(), kill_time);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -320,9 +318,9 @@ int MSG_process_get_PID(msg_process_t process)
 {
   /* Do not raise an exception here: this function is called by the logs
    * and the exceptions, so it would be called back again and again */
 {
   /* Do not raise an exception here: this function is called by the logs
    * and the exceptions, so it would be called back again and again */
-  if (process == nullptr)
+  if (process == nullptr || process->getImpl() == nullptr)
     return 0;
     return 0;
-  return process->pid;
+  return process->getImpl()->pid;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -333,7 +331,7 @@ int MSG_process_get_PID(msg_process_t process)
  */
 int MSG_process_get_PPID(msg_process_t process)
 {
  */
 int MSG_process_get_PPID(msg_process_t process)
 {
-  return process->ppid;
+  return process->getImpl()->ppid;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -343,7 +341,7 @@ int MSG_process_get_PPID(msg_process_t process)
  */
 const char *MSG_process_get_name(msg_process_t process)
 {
  */
 const char *MSG_process_get_name(msg_process_t process)
 {
-  return process->name.c_str();
+  return process->cname();
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -366,7 +364,7 @@ const char *MSG_process_get_property_value(msg_process_t process, const char *na
 xbt_dict_t MSG_process_get_properties(msg_process_t process)
 {
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
 xbt_dict_t MSG_process_get_properties(msg_process_t process)
 {
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  return simcall_process_get_properties(process);
+  return simcall_process_get_properties(process->getImpl());
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -376,7 +374,8 @@ xbt_dict_t MSG_process_get_properties(msg_process_t process)
  */
 int MSG_process_self_PID()
 {
  */
 int MSG_process_self_PID()
 {
-  return MSG_process_get_PID(MSG_process_self());
+  smx_actor_t self = SIMIX_process_self();
+  return self == nullptr ? 0 : self->pid;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -396,7 +395,7 @@ int MSG_process_self_PPID()
  */
 msg_process_t MSG_process_self()
 {
  */
 msg_process_t MSG_process_self()
 {
-  return SIMIX_process_self();
+  return SIMIX_process_self()->ciface();
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -409,7 +408,7 @@ msg_error_t MSG_process_suspend(msg_process_t process)
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
 
   TRACE_msg_process_suspend(process);
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
 
   TRACE_msg_process_suspend(process);
-  simcall_process_suspend(process);
+  simcall_process_suspend(process->getImpl());
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -423,7 +422,7 @@ msg_error_t MSG_process_resume(msg_process_t process)
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
 
   TRACE_msg_process_resume(process);
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
 
   TRACE_msg_process_resume(process);
-  simcall_process_resume(process);
+  simcall_process_resume(process->getImpl());
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -434,12 +433,11 @@ msg_error_t MSG_process_resume(msg_process_t process)
  */
 int MSG_process_is_suspended(msg_process_t process)
 {
  */
 int MSG_process_is_suspended(msg_process_t process)
 {
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  return simcall_process_is_suspended(process);
+  return simcall_process_is_suspended(process->getImpl());
 }
 
 smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
 }
 
 smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
-  return SIMIX_process_get_context(process);
+  return SIMIX_process_get_context(process->getImpl());
 }
 /**
  * \ingroup m_process_management
 }
 /**
  * \ingroup m_process_management
@@ -448,7 +446,7 @@ smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
  * You should use them to free the data used by your process.
  */
 void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) {
  * You should use them to free the data used by your process.
  */
 void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) {
-  simcall_process_on_exit(MSG_process_self(),fun,data);
+  simcall_process_on_exit(SIMIX_process_self(), fun, data);
 }
 /**
  * \ingroup m_process_management
 }
 /**
  * \ingroup m_process_management
@@ -456,14 +454,14 @@ void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) {
  * If the flag is set to 1, the process will be automatically restarted when its host comes back up.
  */
 XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart) {
  * If the flag is set to 1, the process will be automatically restarted when its host comes back up.
  */
 XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart) {
-  simcall_process_auto_restart_set(process,auto_restart);
+  simcall_process_auto_restart_set(process->getImpl(), auto_restart);
 }
 /**
  * \ingroup m_process_management
  * \brief Restarts a process from the beginning.
  */
 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
 }
 /**
  * \ingroup m_process_management
  * \brief Restarts a process from the beginning.
  */
 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
-  return simcall_process_restart(process);
+  return simcall_process_restart(process->getImpl())->ciface();
 }
 
 /** @ingroup m_process_management
 }
 
 /** @ingroup m_process_management
@@ -472,7 +470,7 @@ XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
 XBT_PUBLIC(void) MSG_process_daemonize(msg_process_t process)
 {
   simgrid::simix::kernelImmediate([process]() {
 XBT_PUBLIC(void) MSG_process_daemonize(msg_process_t process)
 {
   simgrid::simix::kernelImmediate([process]() {
-    process->daemonize();
+    process->getImpl()->daemonize();
   });
 }
 
   });
 }
 
index 426b850..f58240a 100644 (file)
@@ -87,7 +87,7 @@ double Actor::killTime()
 }
 
 void Actor::kill(int pid) {
 }
 
 void Actor::kill(int pid) {
-  msg_process_t process = SIMIX_process_from_PID(pid);
+  smx_actor_t process = SIMIX_process_from_PID(pid);
   if(process != nullptr) {
     simcall_process_kill(process);
   } else {
   if(process != nullptr) {
     simcall_process_kill(process);
   } else {
index 8bab69b..71b48e0 100644 (file)
@@ -84,6 +84,7 @@ public:
   ~ActorImpl();
 
   simgrid::s4u::ActorPtr iface() { return s4u::ActorPtr(&piface_); }
   ~ActorImpl();
 
   simgrid::s4u::ActorPtr iface() { return s4u::ActorPtr(&piface_); }
+  simgrid::s4u::Actor* ciface() { return &piface_; }
 
   void daemonize();
   bool isDaemon();
 
   void daemonize();
   bool isDaemon();
index ba63986..24df232 100644 (file)
@@ -1,5 +1,6 @@
+# C examples
 foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async pid
 foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async pid
-          process storage_client_server trace_integration)
+          storage_client_server trace_integration)
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -8,7 +9,8 @@ foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_proc
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
 endforeach()
 
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
 endforeach()
 
-foreach(x task_destroy_cancel)
+# CPP examples
+foreach(x process task_destroy_cancel)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
index fcb42c6..c7df906 100644 (file)
@@ -57,11 +57,15 @@ static int master(int argc, char *argv[])
     MSG_task_destroy(task);
 
   MSG_host_on(jupiter);
     MSG_task_destroy(task);
 
   MSG_host_on(jupiter);
-  xbt_swag_t jupi_processes = MSG_host_get_process_list(jupiter);
-  void *process;
-  xbt_swag_foreach(process, jupi_processes) {
+
+  xbt_dynar_t jupi_processes = xbt_dynar_new(sizeof(msg_process_t), NULL);
+  MSG_host_get_process_list(jupiter, jupi_processes);
+  msg_process_t process = NULL;
+  unsigned int cursor;
+  xbt_dynar_foreach (jupi_processes, cursor, process) {
     MSG_process_kill(process);
   }
     MSG_process_kill(process);
   }
+  xbt_dynar_free(&jupi_processes);
 
   task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL);
   XBT_INFO("Sending \"%s\"", task->name);
 
   task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL);
   XBT_INFO("Sending \"%s\"", task->name);
index 540aa6b..ebe6b3a 100644 (file)
@@ -43,10 +43,12 @@ static int killall(int argc, char *argv[]){
   return 0;
 }
 
   return 0;
 }
 
-int main(int argc, char *argv[])
+int main(int argc, charargv[])
 {
   MSG_init(&argc, argv);
 
 {
   MSG_init(&argc, argv);
 
+  xbt_assert(argc >= 2, "Usage: pid platform pid_to_kill");
+
   MSG_process_killall(atoi(argv[2]));
 
   MSG_create_environment(argv[1]);
   MSG_process_killall(atoi(argv[2]));
 
   MSG_create_environment(argv[1]);
similarity index 80%
rename from teshsuite/msg/process/process.c
rename to teshsuite/msg/process/process.cpp
index 57a7fdb..bebb77d 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2017. 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. */
 
 /* 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. */
@@ -8,11 +7,11 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
-static int slave(int argc, char *argv[])
+static int slave(int argc, charargv[])
 {
   MSG_process_sleep(.5);
   XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
 {
   MSG_process_sleep(.5);
   XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
-  while(1){
+  while (1) {
     XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
     MSG_process_sleep(1);
   }
     XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
     MSG_process_sleep(1);
   }
@@ -20,17 +19,22 @@ static int slave(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-static int master(int argc, char *argv[])
+static int master(int argc, charargv[])
 {
 {
-  xbt_swag_t process_list = MSG_host_get_process_list(MSG_host_self());
-  msg_process_t process = NULL;
   MSG_process_sleep(1);
   MSG_process_sleep(1);
-  xbt_swag_foreach(process, process_list) {
+  xbt_dynar_t process_list = xbt_dynar_new(sizeof(msg_process_t), nullptr);
+  MSG_host_get_process_list(MSG_host_self(), process_list);
+
+  msg_process_t process = NULL;
+  unsigned int cursor;
+  xbt_dynar_foreach (process_list, cursor, process) {
     XBT_INFO("Process(pid=%d, ppid=%d, name=%s)", MSG_process_get_PID(process), MSG_process_get_PPID(process),
              MSG_process_get_name(process));
     if (MSG_process_self_PID() != MSG_process_get_PID(process))
       MSG_process_kill(process);
   }
     XBT_INFO("Process(pid=%d, ppid=%d, name=%s)", MSG_process_get_PID(process), MSG_process_get_PPID(process),
              MSG_process_get_name(process));
     if (MSG_process_self_PID() != MSG_process_get_PID(process))
       MSG_process_kill(process);
   }
+  xbt_dynar_free(&process_list);
+
   process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   MSG_process_sleep(2);
 
   process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   MSG_process_sleep(2);
 
@@ -53,10 +57,8 @@ static int master(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-int main(int argc, char *argv[])
+int main(int argc, charargv[])
 {
 {
-  msg_error_t res;
-
   MSG_init(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\t Example: %s msg_platform.xml\n", argv[0], argv[0]);
 
   MSG_init(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\t Example: %s msg_platform.xml\n", argv[0], argv[0]);
 
@@ -65,7 +67,7 @@ int main(int argc, char *argv[])
   MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
   MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Tremblay"));
 
   MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
   MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Tremblay"));
 
-  res = MSG_main();
+  msg_error_t res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
 
   XBT_INFO("Simulation time %g", MSG_get_clock());