From 2fdff8d6a639190cfc5be5b33105dab51c3c0c6d Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 26 Jan 2017 22:23:31 +0100 Subject: [PATCH 1/1] new function MSG_process_yield() --- ChangeLog | 3 +++ include/simgrid/msg.h | 1 + src/msg/msg_process.cpp | 11 ++++++----- src/simix/ActorImpl.cpp | 2 +- src/simix/libsmx.cpp | 12 ++++++------ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30e6efb21f..59e328e1ef 100644 --- 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() diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index e50c2a994c..f7d217e8bc 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -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, diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 14f9fc9ea4..d02ae9c7ae 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -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. * diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 9715c65360..3356c16cae 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -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(); diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index e9fb2be7f4..bd4370014b 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -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); } } -- 2.20.1