Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change MSG_host_get_storage_list function + update simdag-io example
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Thu, 26 Sep 2013 14:50:09 +0000 (16:50 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Thu, 26 Sep 2013 14:50:09 +0000 (16:50 +0200)
12 files changed:
examples/simdag/io/sd_io.c
include/msg/msg.h
include/simdag/simdag.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_host.c
src/simdag/sd_workstation.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/workstation.c

index c64fe6a..5d30703 100644 (file)
@@ -14,11 +14,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_io,
                              "Logging specific to this SimDag example");
 int main(int argc, char **argv)
 {
-  unsigned int ctr, ctr2;
+  unsigned int ctr;
   const SD_workstation_t *workstations;
   int total_nworkstations;
-  xbt_dynar_t current_storage_list;
+  xbt_dict_t current_storage_list;
   char *mount_name;
+  char *storage_name;
+  xbt_dict_cursor_t cursor = NULL;
 
   SD_init(&argc, argv);
   /* Set the workstation model to default, as storage is not supported by the
@@ -31,10 +33,10 @@ int main(int argc, char **argv)
 
   for (ctr=0; ctr<total_nworkstations;ctr++){
     current_storage_list = SD_workstation_get_storage_list(workstations[ctr]);
-    xbt_dynar_foreach(current_storage_list, ctr2, mount_name)
+    xbt_dict_foreach(current_storage_list,cursor,mount_name,storage_name)
       XBT_INFO("Workstation '%s' mounts '%s'",
          SD_workstation_get_name(workstations[ctr]), mount_name);
-    xbt_dynar_free_container(&current_storage_list);
+    xbt_dict_free(&current_storage_list);
   }
   SD_exit();
   return 0;
index 5916660..a595340 100644 (file)
@@ -142,7 +142,7 @@ XBT_PUBLIC(void) MSG_create_environment(const char *file);
 XBT_PUBLIC(msg_host_t) MSG_get_host_by_name(const char *name);
 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void);
 XBT_PUBLIC(int) MSG_get_host_number(void);
-XBT_PUBLIC(xbt_dynar_t) MSG_host_get_storage_list(msg_host_t host);
+XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_list(msg_host_t host);
 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_storage_content(msg_host_t host);
 /************************** Process handling *********************************/
 XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name,
index 49d062e..d78288f 100644 (file)
@@ -105,7 +105,7 @@ XBT_PUBLIC(double) SD_route_get_communication_time(SD_workstation_t src,
 
 XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task(SD_workstation_t
                                                       workstation);
-XBT_PUBLIC(xbt_dynar_t)
+XBT_PUBLIC(xbt_dict_t)
     SD_workstation_get_storage_list(SD_workstation_t workstation);
 /** @} */
 
index 6b46fb6..4d41c7c 100644 (file)
@@ -263,7 +263,7 @@ XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
 XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
-XBT_PUBLIC(xbt_dynar_t) SIMIX_host_get_storage_list(smx_host_t host);
+XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_storage_list(smx_host_t host);
 /********************************* Process ************************************/
 XBT_PUBLIC(int) SIMIX_process_count(void);
 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
@@ -334,7 +334,7 @@ XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
-XBT_PUBLIC(xbt_dynar_t) simcall_host_get_storage_list(smx_host_t host);
+XBT_PUBLIC(xbt_dict_t) simcall_host_get_storage_list(smx_host_t host);
 
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
index 428a63b..b1afac9 100644 (file)
@@ -293,7 +293,7 @@ typedef struct surf_workstation_model_extension_public {
 
   size_t (*get_free_size) (void *workstation,const char* name);
   size_t (*get_used_size) (void *workstation,const char* name);
-  xbt_dynar_t (*get_storage_list) (void *workstation);
+  xbt_dict_t (*get_storage_list) (void *workstation);
 
 } s_surf_model_extension_workstation_t;
 
index 29b5908..f6e96e2 100644 (file)
@@ -339,11 +339,11 @@ double MSG_get_host_consumed_energy(msg_host_t host) {
 }
 
 /** \ingroup m_host_management
- * \brief Return the list of mounted storages on an host.
+ * \brief Return the list of mount point names on an host.
  * \param host a host
- * \return a dynar containing all storages mounted on the host
+ * \return a dict containing all mount point on the host (mount_name => msg_storage_t)
  */
-xbt_dynar_t MSG_host_get_storage_list(msg_host_t host)
+xbt_dict_t MSG_host_get_storage_list(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters");
   return (simcall_host_get_storage_list(host));
@@ -358,14 +358,16 @@ xbt_dynar_t MSG_host_get_storage_content(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters");
   xbt_dynar_t contents = xbt_dynar_new(sizeof(void *),NULL);
-  msg_storage_t storage;
-  char* storage_name;
-  unsigned int i;
-  xbt_dynar_t storage_list = simcall_host_get_storage_list(host);
-  xbt_dynar_foreach(storage_list, i, storage_name){
-       storage = xbt_lib_get_elm_or_null(storage_lib,storage_name);
-       xbt_dict_t content = simcall_storage_get_content(storage);
-       xbt_dynar_push(contents, &content);
-  }
+//  msg_storage_t storage;
+//  char* storage_name;
+//  unsigned int i;
+//  xbt_dynar_t storage_list = simcall_host_get_storage_list(host);
+//  xbt_dynar_foreach(storage_list, i, storage_name){
+//     storage = xbt_lib_get_elm_or_null(storage_lib,storage_name);
+//
+//     XBT_INFO("STORAGE NAME: %s", storage_name);
+//     xbt_dict_t content = simcall_storage_get_content(storage);
+//     xbt_dynar_push(contents, &content);
+//  }
   return contents;
 }
index f035d13..574c99c 100644 (file)
@@ -482,7 +482,7 @@ void SD_workstation_set_access_mode(SD_workstation_t workstation,
  * \param workstation a workstation
  * \return a dynar containing all mounted storages on the workstation
  */
-xbt_dynar_t SD_workstation_get_storage_list(SD_workstation_t workstation){
+xbt_dict_t SD_workstation_get_storage_list(SD_workstation_t workstation){
   return surf_workstation_model->extension.workstation.get_storage_list(workstation);
 }
 
index 5b7b0e9..5ef2bd9 100644 (file)
@@ -626,10 +626,10 @@ void SIMIX_set_category(smx_action_t action, const char *category)
 }
 #endif
 
-xbt_dynar_t SIMIX_pre_host_get_storage_list(smx_simcall_t simcall, smx_host_t host){
+xbt_dict_t SIMIX_pre_host_get_storage_list(smx_simcall_t simcall, smx_host_t host){
   return SIMIX_host_get_storage_list(host);
 }
-xbt_dynar_t SIMIX_host_get_storage_list(smx_host_t host){
+xbt_dict_t SIMIX_host_get_storage_list(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.get_storage_list(host);
index c5099bd..f91d19d 100644 (file)
@@ -60,7 +60,7 @@ double SIMIX_host_execution_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action);
 void SIMIX_host_execution_set_priority(smx_action_t action, double priority);
 void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action);
-xbt_dynar_t SIMIX_host_get_storage_list(smx_host_t host);
+xbt_dict_t SIMIX_host_get_storage_list(smx_host_t host);
 
 // pre prototypes
 smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t, const char*);
@@ -93,7 +93,7 @@ void SIMIX_host_execution_suspend(smx_action_t action);
 void SIMIX_host_execution_resume(smx_action_t action);
 
 void SIMIX_post_host_execute(smx_action_t action);
-xbt_dynar_t SIMIX_pre_host_get_storage_list(smx_simcall_t, smx_host_t);
+xbt_dict_t SIMIX_pre_host_get_storage_list(smx_simcall_t, smx_host_t);
 #ifdef HAVE_TRACING
 void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action,
                            const char *category);
index 084a6bb..0b57815 100644 (file)
@@ -282,7 +282,7 @@ ACTION(SIMCALL_HOST_EXECUTION_GET_REMAINS, host_execution_get_remains, WITH_ANSW
 ACTION(SIMCALL_HOST_EXECUTION_GET_STATE, host_execution_get_state, WITH_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(priority)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
-ACTION(SIMCALL_HOST_GET_STORAGE_LIST, host_get_storage_list, WITH_ANSWER, TSPEC(result, xbt_dynar_t), TSPEC(host, smx_host_t)) sep \
+ACTION(SIMCALL_HOST_GET_STORAGE_LIST, host_get_storage_list, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(host, smx_host_t)) sep \
 ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
 ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result), TINT(reset_pid)) sep \
index 4b873f9..75e467b 100644 (file)
@@ -1293,9 +1293,9 @@ size_t simcall_storage_get_used_size (const char* name){
  * \ingroup simix_storage_management
  * \brief Returns the list of storages mounted on an host.
  * \param host A SIMIX host
- * \return a dynar containing all storages mounted on the host
+ * \return a dict containing all storages mounted on the host
  */
-xbt_dynar_t simcall_host_get_storage_list(smx_host_t host)
+xbt_dict_t simcall_host_get_storage_list(smx_host_t host)
 {
   return simcall_BODY_host_get_storage_list(host);
 }
index 86f6619..e328332 100644 (file)
@@ -365,18 +365,20 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* mount)
   return st;
 }
 
-static xbt_dynar_t ws_get_storage_list(void *workstation)
+static xbt_dict_t ws_get_storage_list(void *workstation)
 {
   s_mount_t mnt;
   unsigned int i;
-  xbt_dynar_t storage_list = xbt_dynar_new(sizeof(char*), NULL);
+  xbt_dict_t storage_list = xbt_dict_new();
+  char *storage_name = NULL;
 
   workstation_CLM03_t ws = (workstation_CLM03_t) surf_workstation_resource_priv(workstation);
   xbt_dynar_t storages = ws->storage;
 
   xbt_dynar_foreach(storages,i,mnt)
   {
-    xbt_dynar_push(storage_list, &mnt.name);
+       storage_name = ((storage_t)mnt.storage)->generic_resource.name;
+    xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
   }
   return storage_list;
 }