From 77e63efea0d0c200b85f224c2faf9de94d98e83a Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Wed, 8 Aug 2012 17:58:02 +0200 Subject: [PATCH] add getter/setter functions in simix to access more cleanly the process associated to the mailbox for permanent receive mode --- include/simgrid/simix.h | 2 ++ src/msg/msg_mailbox.c | 2 +- src/msg/msg_private.h | 1 - src/simix/smx_network.c | 20 ++++++++++++++++++++ src/smpi/smpi_global.c | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 55a834b612..b3eff4dd42 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -365,6 +365,8 @@ XBT_PUBLIC(void) simcall_rdv_destroy(smx_rdv_t rvp); XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name); XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host); XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv); +XBT_PUBLIC(smx_process_t) SIMIX_rdv_get_receiver(smx_rdv_t rdv); +XBT_PUBLIC(void) SIMIX_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process); XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void); diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index d8509ed30b..14b1540c4d 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -59,7 +59,7 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) void MSG_mailbox_set_async(const char *alias){ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias); - mailbox->permanent_receiver=SIMIX_process_self(); + SIMIX_rdv_set_receiver(mailbox, SIMIX_process_self()); XBT_VERB("%s mailbox set to receive eagerly for process %p\n",alias, SIMIX_process_self()); } diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 4d84ce19b5..3c6c04db3a 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -16,7 +16,6 @@ #include "xbt/dict.h" #include "xbt/config.h" #include "instr/instr_private.h" -#include "simix/smx_private.h" SG_BEGIN_DECL() /**************** datatypes **********************************/ diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 7737e92e0a..0ce248a02c 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -104,6 +104,26 @@ smx_action_t SIMIX_rdv_get_head(smx_rdv_t rdv) return xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo)); } +/** + * \brief get the receiver (process associated to the mailbox) + * \param rdv The rendez-vous point + * \return process The receiving process (NULL if not set) + */ +smx_process_t SIMIX_rdv_get_receiver(smx_rdv_t rdv) +{ + return rdv->permanent_receiver; +} + +/** + * \brief set the receiver of the rendez vous point to allow eager sends + * \param rdv The rendez-vous point + * \param process The receiving process + */ +void SIMIX_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process) +{ + rdv->permanent_receiver=process; +} + /** * \brief Pushes a communication action into a rendez-vous point * \param rdv The rendez-vous point diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index cdbdc96c63..4560524357 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -67,7 +67,7 @@ void smpi_process_init(int *argc, char ***argv) (*argc)--; data->argc = argc; data->argv = argv; - data->mailbox_small->permanent_receiver=proc;// set the process attached to the mailbox + SIMIX_rdv_set_receiver(data->mailbox_small, proc);// set the process attached to the mailbox XBT_DEBUG("<%d> New process in the game: %p", index, proc); } } -- 2.20.1