Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new function MSG_process_yield()
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 26 Jan 2017 21:23:31 +0000 (22:23 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 26 Jan 2017 21:23:31 +0000 (22:23 +0100)
ChangeLog
include/simgrid/msg.h
src/msg/msg_process.cpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp

index 30e6efb..59e328e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@ SimGrid (3.15) UNRELEASED; urgency=low
    This was intended to help NS3 users, but that's not a netcard.
    That's a point in the routing algorithm, let's avoid do wrong simplifications.
 
+ MSG
+ - New function: MSG_process_yield()
+
  Java
  - Ensure that an actor can kill itself with Process::exit()
 
index e50c2a9..f7d217e 100644 (file)
@@ -296,6 +296,7 @@ XBT_PUBLIC(void) MSG_process_detach();
 XBT_PUBLIC(void) MSG_process_kill(msg_process_t process);
 XBT_PUBLIC(int) MSG_process_killall(int reset_PIDs);
 XBT_PUBLIC(msg_error_t) MSG_process_migrate(msg_process_t process, msg_host_t host);
+XBT_PUBLIC(void) MSG_process_yield();
 
 XBT_PUBLIC(void *) MSG_process_get_data(msg_process_t process);
 XBT_PUBLIC(msg_error_t) MSG_process_set_data(msg_process_t process,
index 14f9fc9..d02ae9c 100644 (file)
@@ -219,11 +219,6 @@ void MSG_process_detach()
  */
 void MSG_process_kill(msg_process_t process)
 {
-//  /* FIXME: why do we only cancel communication actions? is this useful? */
-//  simdata_process_t p_simdata = simcall_process_get_data(process);
-//  if (p_simdata->waiting_task && p_simdata->waiting_task->simdata->comm) {
-//    simcall_comm_cancel(p_simdata->waiting_task->simdata->comm);
-//  }
   simcall_process_kill(process);
 }
 
@@ -254,6 +249,12 @@ msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
   return MSG_OK;
 }
 
+/** Yield the current actor; let the other actors execute first */
+void MSG_process_yield()
+{
+  simgrid::simix::kernelImmediate([] { /* do nothing*/ });
+}
+
 /** \ingroup m_process_management
  * \brief Returns the user data of a process.
  *
index 9715c65..3356c16 100644 (file)
@@ -791,7 +791,7 @@ void SIMIX_process_sleep_destroy(smx_activity_t synchro)
  */
 void SIMIX_process_yield(smx_actor_t self)
 {
-  XBT_DEBUG("Yield process '%s'", self->name.c_str());
+  XBT_DEBUG("Yield actor '%s'", self->cname());
 
   /* Go into sleep and return control to maestro */
   self->context->suspend();
index e9fb2be..bd43700 100644 (file)
@@ -35,14 +35,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
 #include "popping_bodies.cpp"
 
-void simcall_call(smx_actor_t process)
+void simcall_call(smx_actor_t actor)
 {
-  if (process != simix_global->maestro_process) {
-    XBT_DEBUG("Yield process '%s' on simcall %s (%d)", process->name.c_str(),
-              SIMIX_simcall_name(process->simcall.call), (int)process->simcall.call);
-    SIMIX_process_yield(process);
+  if (actor != simix_global->maestro_process) {
+    XBT_DEBUG("Yield actor '%s' on simcall %s (%d)", actor->cname(), SIMIX_simcall_name(actor->simcall.call),
+              (int)actor->simcall.call);
+    SIMIX_process_yield(actor);
   } else {
-    SIMIX_simcall_handle(&process->simcall, 0);
+    SIMIX_simcall_handle(&actor->simcall, 0);
   }
 }