Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a simcall for as and router property
authornavarro <navarro@caraja.(none)>
Thu, 6 Sep 2012 14:06:51 +0000 (16:06 +0200)
committernavarro <navarro@caraja.(none)>
Thu, 6 Sep 2012 14:06:51 +0000 (16:06 +0200)
include/simgrid/simix.h
src/msg/msg_gos.c
src/simix/smx_global.c
src/simix/smx_smurf.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index ff97a5d..4066388 100644 (file)
@@ -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 */
index 13f4bf1..dac3b6e 100644 (file)
@@ -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));
 }
 
 /**
index 57020ba..6133fcf 100644 (file)
@@ -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);
+}
+
index 7278076..e8c8e2e 100644 (file)
@@ -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),
index fb50e88..1f87947 100644 (file)
@@ -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;
 
index 3a7bd17..4a8a1eb 100644 (file)
@@ -87,6 +87,26 @@ xbt_dict_t simcall_host_get_properties(smx_host_t host)
 
 /**
  * \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.
  *
  * The speed returned does not take into account the current load on the machine.