Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initialize variable there too.
[simgrid.git] / src / surf / surf.hpp
index 996aa47..8dab3fd 100644 (file)
@@ -6,11 +6,9 @@
 #include <xbt.h>
 #include <string>
 #include <vector>
+#include <iostream>
 #include <memory>
-#include <boost/smart_ptr.hpp>
 #include <boost/function.hpp>
-#include <boost/functional/factory.hpp>
-#include <boost/bind.hpp>
 #include "surf/trace_mgr.h"
 #include "xbt/lib.h"
 #include "surf/surf_routing.h"
@@ -50,7 +48,6 @@ extern xbt_dynar_t surf_path;
 extern "C" {
 #endif
 XBT_PUBLIC(double) surf_get_clock(void);
-XBT_PUBLIC(void) surf_watched_hosts(void);
 #ifdef __cplusplus
 }
 #endif
@@ -109,15 +106,14 @@ public:
   ResourcePtr createResource(string name);
   ActionPtr createAction(double _cost, bool _failed);
   virtual double shareResources(double now);
-  double shareResourcesLazy(double now);
-  //double shareResourcesFull(double now);
+  virtual double shareResourcesLazy(double now);
+  virtual double shareResourcesFull(double now);
   double shareResourcesMaxMin(xbt_swag_t running_actions,
-                                      size_t offset,
                                       lmm_system_t sys,
                                       void (*solve) (lmm_system_t));
-  void updateActionsState(double now, double delta);
-  void updateActionsStateLazy(double now, double delta);
-  void updateActionsStateFull(double now, double delta);
+  virtual void updateActionsState(double now, double delta);
+  virtual void updateActionsStateLazy(double now, double delta);
+  virtual void updateActionsStateFull(double now, double delta);
 
   string getName() {return m_name;};
 
@@ -177,25 +173,26 @@ public:
 
   //private
   virtual bool isUsed()=0;
-  //TODOupdateActionState();
-  //TODOupdateResourceState();
-  //TODOfinilize();
+  //FIXME:updateActionState();
+  //FIXME:updateResourceState();
+  //FIXME:finilize();
 
   bool isOn();
   void turnOn();
   void turnOff();
   void setName(string name);
   const char *getName();
-  xbt_dict_t getProperties();
+  virtual xbt_dict_t getProperties();
 
   ModelPtr getModel() {return p_model;};
-  e_surf_resource_state_t getState();
+  virtual e_surf_resource_state_t getState();
+  virtual void setState(e_surf_resource_state_t state);
   void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
   void *p_resource;
-  e_surf_resource_state_t m_stateCurrent;
   const char *m_name;
   xbt_dict_t m_properties;
   ModelPtr p_model;
+  e_surf_resource_state_t p_stateCurrent;
 
 protected:
 
@@ -205,7 +202,7 @@ private:
 
 class ResourceLmm: virtual public Resource {
 public:
-  ResourceLmm() {};
+  ResourceLmm() { p_power.event = NULL; };
   ResourceLmm(surf_model_t model, const char *name, xbt_dict_t props,
                            lmm_system_t system,
                            double constraint_value,
@@ -215,7 +212,6 @@ public:
                            double metric_peak,
                            tmgr_trace_t metric_trace);
   lmm_constraint_t p_constraint;
-  e_surf_resource_state_t p_stateCurrent;
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
 };
@@ -231,8 +227,9 @@ public:
   virtual ~Action();
   
   s_xbt_swag_hookup_t p_stateHookup;
+
   e_surf_action_state_t getState(); /**< get the state*/
-  void setState(e_surf_action_state_t state); /**< Change state*/
+  virtual void setState(e_surf_action_state_t state); /**< Change state*/
   double getStartTime(); /**< Return the start time of an action */
   double getFinishTime(); /**< Return the finish time of an action */
   void setData(void* data);
@@ -250,7 +247,7 @@ public:
 #ifdef HAVE_TRACING
   void setCategory(const char *category); /**< Set the category of an action */
 #endif
-  double getRemains();     /**< Get the remains of an action */
+  virtual double getRemains();     /**< Get the remains of an action */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   int getLatencyLimited();     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
@@ -258,6 +255,7 @@ public:
   xbt_swag_t p_stateSet;
 
   double m_priority; /**< priority (1.0 by default) */
+  double m_bound;              /**< the capping of the CPU use  */
   bool m_failed;
   double m_start; /**< start time  */
   double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
@@ -286,7 +284,6 @@ private:
   void updateResourceState(void *id, tmgr_trace_event_t event_type,
                                  double value, double time);
 
-  lmm_system_t p_maxminSystem;
   xbt_swag_t p_modifiedSet;
   xbt_heap_t p_actionHeap;
   int m_selectiveUpdate;
@@ -297,16 +294,26 @@ void surf_action_lmm_update_index_heap(void *action, int i);
 
 class ActionLmm: virtual public Action {
 public:
-  ActionLmm() : m_suspended(false) {};
-  ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {};
-
-  void updateRemainingLazy(double now) {};//FIXME:
+  ActionLmm() : m_suspended(false) {
+       p_actionListHookup.prev = 0;
+       p_actionListHookup.next = 0;
+        m_lastUpdate = 0;
+        m_lastValue = 0;
+  };
+  ActionLmm(ModelPtr /*model*/, double /*cost*/, bool /*failed*/) : m_suspended(false) {
+       p_actionListHookup.prev = 0;
+       p_actionListHookup.next = 0;
+        m_lastUpdate = 0;
+        m_lastValue = 0;
+  };
+
+  virtual void updateRemainingLazy(double now);
   void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
   void heapRemove(xbt_heap_t heap);
   double getRemains();     /**< Get the remains of an action */
   void updateIndexHeap(int i);
 
-  int unref();
+  virtual int unref();
   void cancel();
   void suspend();
   void resume();
@@ -316,7 +323,6 @@ public:
   void gapRemove();
 
   lmm_variable_t p_variable;
-  //bool m_suspended;
   s_xbt_swag_hookup_t p_actionListHookup;
   int m_indexHeap;
   double m_lastUpdate;