Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Finalize properties on AS.
[simgrid.git] / src / simdag / sd_workstation.c
index 4c6be1a..1be8d28 100644 (file)
@@ -7,6 +7,7 @@
 #include "private.h"
 #include "simdag/simdag.h"
 #include "xbt/dict.h"
+#include "xbt/lib.h"
 #include "xbt/sysdep.h"
 #include "surf/surf.h"
 #include "surf/surf_resource.h"
@@ -157,6 +158,7 @@ xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
 
 }
 
+
 /** @brief Displays debugging informations about a workstation */
 void SD_workstation_dump(SD_workstation_t ws)
 {
@@ -181,8 +183,7 @@ void SD_workstation_dump(SD_workstation_t ws)
     else
       XBT_INFO("    no task running");
       break;
-  default:
-      XBT_INFO("  - (unknown access mode)");
+  default: break;
   }
   props = SD_workstation_get_properties(ws);
   
@@ -434,6 +435,10 @@ void SD_workstation_set_access_mode(SD_workstation_t workstation,
                                     e_SD_workstation_access_mode_t
                                     access_mode)
 {
+  xbt_assert(access_mode != SD_WORKSTATION_SEQUENTIAL_ACCESS ||
+             access_mode != SD_WORKSTATION_SHARED_ACCESS,
+             "Trying to set an invalid access mode");
+
   if (access_mode == workstation->access_mode) {
     return;                     // nothing is changed
   }
@@ -448,16 +453,16 @@ void SD_workstation_set_access_mode(SD_workstation_t workstation,
   }
 }
 
-/* Returns whether a task can start now on a workstation.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   int __SD_workstation_can_start(SD_workstation_t workstation, SD_task_t task) {
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   SD_CHECK_INIT_DONE();
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   xbt_assert(workstation != NULL && task != NULL, "Invalid parameter");
+/* Returns whether a task can start now on a workstation*/
+/*
+  int __SD_workstation_can_start(SD_workstation_t workstation, SD_task_t task) {
+  SD_CHECK_INIT_DONE();
+  xbt_assert(workstation != NULL && task != NULL, "Invalid parameter");
 
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   return !__SD_workstation_is_busy(workstation) &&
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   (xbt_fifo_size(workstation->task_fifo) == 0) || xbt_fifo_get_first_item(workstation->task_fifo) == task);
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   }
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
+  return !__SD_workstation_is_busy(workstation) &&
+  (xbt_fifo_size(workstation->task_fifo) == 0) || xbt_fifo_get_first_item(workstation->task_fifo) == task);
+  }
+*/
 
 /* Returns whether a workstation is busy. A workstation is busy is it is
  * in sequential mode and a task is running on it or the fifo is not empty.
@@ -509,3 +514,29 @@ SD_task_t SD_workstation_get_current_task(SD_workstation_t workstation)
 
   return (workstation->current_task);
 }
+
+/**
+ * \brief Returns a #xbt_dict_t consisting of the list of properties assigned to the AS
+ * or router
+ *
+ * \param AS, router name
+ * \return the xbt_dict_t properties of the AS
+ */
+xbt_dict_t SD_as_router_get_properties(const char *asr)
+{
+  return get_as_router_properties(asr);
+}
+/**
+ * \brief Returns a #xbt_dict_t consisting of the list of properties assigned to the AS
+ * or router
+ *
+ * \param AS, router name
+ * \param The name of a properties
+ * \return value of the properties
+ */
+const char* SD_as_router_get_property_value(const char *asr, const char *name)
+{
+  xbt_dict_t dict = get_as_router_properties(asr);
+  if(!dict) return NULL;
+  return xbt_dict_get_or_null(dict,name);
+}