From ebf8c46c16a40fde708f840334c9e28e10060d4e Mon Sep 17 00:00:00 2001 From: suter Date: Wed, 3 Jul 2013 15:45:23 +0200 Subject: [PATCH] add MSG_host_get_process_list() function. --- ChangeLog | 1 + include/msg/msg.h | 1 + include/simgrid/simix.h | 1 + src/msg/msg_host.c | 19 ++++++++++++++++++- src/simix/smx_host.c | 10 ++++++++++ src/simix/smx_host_private.h | 2 ++ src/simix/smx_smurf_private.h | 1 + src/simix/smx_user.c | 11 +++++++++++ 8 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a47f3a3e9c..98b7afe6b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ SimGrid (3.10) NOT RELEASED; urgency=low * Dramatically change the way files are handled. API and internals changed, but this part of MSG was not considered as production grade either. * Add explicit synchronization facilities through semaphores + * Add a new function MSG_host_get_process_list() SMPI: * SMPI is now included directly in the libsimgrid as the windows diff --git a/include/msg/msg.h b/include/msg/msg.h index 7b4748d134..d96ac022e0 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -101,6 +101,7 @@ XBT_PUBLIC(int) MSG_get_host_msgload(msg_host_t host); /* int MSG_get_msgload(void); This function lacks specification; discard it */ XBT_PUBLIC(double) MSG_get_host_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(int) MSG_host_is_avail(msg_host_t h); XBT_PUBLIC(void) __MSG_host_destroy(msg_host_priv_t host); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 26983b7000..034b6d4af3 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -294,6 +294,7 @@ XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name); XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host); XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host); XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host); +XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(smx_host_t host); XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host); XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host); /* Two possible states, 1 - CPU ON and 0 CPU OFF */ diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 5e60908d00..019f4f5c13 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -204,7 +204,10 @@ double MSG_get_host_speed(msg_host_t h) /** \ingroup m_host_management - * \brief Return the number of core. + * \brief Return the number of cores. + * + * \param host a host + * \return the number of cores */ int MSG_host_get_core_number(msg_host_t h) { @@ -213,6 +216,20 @@ int MSG_host_get_core_number(msg_host_t h) return (simcall_host_get_core(h)); } +/** \ingroup m_host_management + * \brief Return the list of processes attached to an host. + * + * \param host a host + * \return a swag with the attached processes + */ +xbt_swag_t MSG_host_get_process_list(msg_host_t h) +{ + xbt_assert((h != NULL), "Invalid parameters"); + + return (simcall_host_get_process_list(h)); +} + + /** \ingroup m_host_management * \brief Returns the value of a given host property * diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 72da17a23c..70b8fd58aa 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -158,6 +158,16 @@ int SIMIX_host_get_core(smx_host_t host){ get_core(host); } +xbt_swag_t SIMIX_pre_host_get_process_list(smx_simcall_t simcall, smx_host_t host){ + return SIMIX_host_get_process_list(host); +} + +xbt_swag_t SIMIX_host_get_process_list(smx_host_t host){ + xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)"); + smx_host_priv_t host_priv = SIMIX_host_priv(host); + + return host_priv->process_list; +} double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){ diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index adb53b8cef..089360ee4d 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -39,6 +39,7 @@ void SIMIX_host_restart_processes(smx_host_t host); void SIMIX_host_autorestart(smx_host_t host); xbt_dict_t SIMIX_host_get_properties(smx_host_t host); int SIMIX_host_get_core(smx_host_t host); +xbt_swag_t SIMIX_host_get_process_list(smx_host_t host); double SIMIX_host_get_speed(smx_host_t host); double SIMIX_host_get_available_speed(smx_host_t host); int SIMIX_host_get_state(smx_host_t host); @@ -61,6 +62,7 @@ const char* SIMIX_pre_host_self_get_name(smx_simcall_t); const char* SIMIX_pre_host_get_name(smx_simcall_t, smx_host_t); xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t, smx_host_t); int SIMIX_pre_host_get_core(smx_simcall_t, smx_host_t); +xbt_swag_t SIMIX_pre_host_get_process_list(smx_simcall_t, smx_host_t host); double SIMIX_pre_host_get_speed(smx_simcall_t, smx_host_t); double SIMIX_pre_host_get_available_speed(smx_simcall_t, smx_host_t); int SIMIX_pre_host_get_state(smx_simcall_t, smx_host_t); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 49063b90b3..268ed6dc2a 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -263,6 +263,7 @@ ACTION(SIMCALL_HOST_GET_BY_NAME, host_get_by_name, WITH_ANSWER, TSPEC(result, sm ACTION(SIMCALL_HOST_GET_NAME, host_get_name, WITH_ANSWER, TSTRING(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_PROPERTIES, host_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_CORE, host_get_core, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \ +ACTION(SIMCALL_HOST_GET_PROCESS_LIST, host_get_process_list, WITH_ANSWER, TSPEC(result, xbt_swag_t), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_SPEED, host_get_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_AVAILABLE_SPEED, host_get_available_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_STATE, host_get_state, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 611617fee1..46a2e86fcd 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -94,6 +94,17 @@ int simcall_host_get_core(smx_host_t host) return simcall_BODY_host_get_core(host); } +/** + * \ingroup simix_host_management + * \brief Returns the list of processes attached to the host. + * + * \param host A SIMIX host + * \return the swag of attached processes + */ +xbt_swag_t simcall_host_get_process_list(smx_host_t host) +{ + return simcall_BODY_host_get_process_list(host); +} /** -- 2.20.1