From 248ef080d26ba69c3ce967cf6593190f50ff8677 Mon Sep 17 00:00:00 2001 From: navarro Date: Tue, 29 May 2012 11:31:49 +0200 Subject: [PATCH 1/1] Add MSG_process_set_kill_time --- include/msg/msg.h | 1 + include/simgrid/simix.h | 1 + src/msg/msg_process.c | 14 ++++++++++++++ src/simix/smx_user.c | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/include/msg/msg.h b/include/msg/msg.h index d28939b70e..ec6b404996 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -125,6 +125,7 @@ XBT_PUBLIC(int) MSG_process_self_PID(void); XBT_PUBLIC(int) MSG_process_self_PPID(void); XBT_PUBLIC(m_process_t) MSG_process_self(void); XBT_PUBLIC(xbt_dynar_t) MSG_processes_as_dynar(void); +XBT_PUBLIC(MSG_error_t) MSG_process_set_kill_time(m_process_t process, double kill_time); /*property handlers*/ XBT_PUBLIC(xbt_dict_t) MSG_process_get_properties(m_process_t process); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index b99a048420..0bdfbab887 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -332,6 +332,7 @@ XBT_PUBLIC(smx_host_t) simcall_process_get_host(smx_process_t process); XBT_PUBLIC(const char *) simcall_process_get_name(smx_process_t process); XBT_PUBLIC(int) simcall_process_is_suspended(smx_process_t process); XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_process_t host); +XBT_PUBLIC(void) simcall_process_set_kill_time(smx_process_t process, double kill_time); /* Sleep control */ XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration); diff --git a/src/msg/msg_process.c b/src/msg/msg_process.c index 6e9a904896..853875cfba 100644 --- a/src/msg/msg_process.c +++ b/src/msg/msg_process.c @@ -315,6 +315,20 @@ xbt_dynar_t MSG_processes_as_dynar(void) { return SIMIX_processes_as_dynar(); } +/** \ingroup m_process_management + * \brief Set the kill time of a process. + * + * \param process a process + * \param kill_time a double + */ +MSG_error_t MSG_process_set_kill_time(m_process_t process, double kill_time) +{ + xbt_assert(process != NULL, "Invalid parameter"); + + simcall_process_set_kill_time(process,kill_time); + return MSG_OK; +} + /** \ingroup m_process_management * \brief Returns the process ID of \a process. * diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 455b98d52a..05932e93bc 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -521,6 +521,24 @@ void simcall_process_set_data(smx_process_t process, void *data) } } +/** \ingroup m_process_management + * \brief Set the kill time of a process. + * + * \param process a process + * \param kill_time a double + */ +void simcall_process_set_kill_time(smx_process_t process, double kill_time) +{ + + if (kill_time > SIMIX_get_clock()) { + if (simix_global->kill_process_function) { + XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name, + process->smx_host->name); + SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); + } + } +} + /** * \brief Return the location on which an agent is running. * -- 2.20.1