From: navarro Date: Thu, 6 Sep 2012 14:06:51 +0000 (+0200) Subject: Add a simcall for as and router property X-Git-Tag: v3_8~146^2~83 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3a57ba0c4456d7138d2a823d1c53629c598286bf Add a simcall for as and router property --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index ff97a5d509..4066388515 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -458,5 +458,10 @@ XBT_PUBLIC(int) simcall_file_close(smx_file_t fp); XBT_PUBLIC(int) simcall_file_stat(smx_file_t fd, s_file_stat_t *buf); XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd); +/************************** AS router **********************************/ +XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name); +/************************** AS router simcalls ***************************/ +XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name); + SG_END_DECL() #endif /* _SIMIX_SIMIX_H */ diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index 13f4bf12b8..dac3b6e67a 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -834,8 +834,7 @@ const char *MSG_as_router_get_property_value(const char* asr, const char *name) */ xbt_dict_t MSG_as_router_get_properties(const char* asr) { - // FIXME do this function with a simcall - return xbt_lib_get_or_null(as_router_lib, asr, ROUTING_PROP_ASR_LEVEL); + return (simcall_asr_get_properties(asr)); } /** diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 57020ba970..6133fcfd2e 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -477,3 +477,9 @@ static void SIMIX_action_mallocator_reset_f(void* action) { memset(action, 0, sizeof(s_smx_action_t)); ((smx_action_t) action)->simcalls = fifo; } + +xbt_dict_t SIMIX_asr_get_properties(const char *name) +{ + return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL); +} + diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 7278076047..e8c8e2e812 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -536,6 +536,12 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_pre_file_unlink(simcall); break; + case SIMCALL_ASR_GET_PROPERTIES: + simcall->asr_get_properties.result = + SIMIX_asr_get_properties(simcall->asr_get_properties.name); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_NONE: THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s", SIMIX_process_get_name(simcall->issuer), diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index fb50e88656..1f879470eb 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -94,7 +94,8 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \ -SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK) +SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES) /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated @@ -580,6 +581,11 @@ typedef struct s_smx_simcall { int result; } file_unlink; + struct { + const char* name; + xbt_dict_t result; + } asr_get_properties; + }; } s_smx_simcall_t, *smx_simcall_t; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 3a7bd17afd..4a8a1eb131 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -85,6 +85,26 @@ xbt_dict_t simcall_host_get_properties(smx_host_t host) return simcall->host_get_properties.result; } +/** + * \ingroup simix_host_management + * \brief Returns a dict of the properties assigned to a router or AS. + * + * \param asr name of the router or AS + * \return The properties + */ +xbt_dict_t simcall_asr_get_properties(const char *name) +{ + smx_simcall_t simcall = SIMIX_simcall_mine(); + + simcall->call = SIMCALL_ASR_GET_PROPERTIES; + simcall->asr_get_properties.name = name; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->asr_get_properties.result = NULL; + SIMIX_simcall_push(simcall->issuer); + return simcall->asr_get_properties.result; +} + + /** * \ingroup simix_host_management * \brief Returns the speed of the processor.