X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4871b54f42ce85370d6acdbcb7e42bf75a63b389..f99abf5a401827fc377d1fc7b5ec7a59c2a36de1:/src/surf/surf_interface.hpp diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 0e001a9e15..e9cda2590d 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -9,12 +9,26 @@ #include #include #include +#include #include "surf/trace_mgr.h" #include "xbt/lib.h" #include "surf/surf_routing.h" #include "simgrid/platf_interface.h" #include "surf/surf.h" #include "surf/surf_private.h" +#include "internal_config.h" + +#ifdef LIBSIGC +#include +#define surf_callback(arg1, ...) sigc::signal +#define surf_callback_connect(callback, fun_ptr) callback.connect(sigc::ptr_fun(fun_ptr)) +#define surf_callback_emit(callback, ...) callback.emit(__VA_ARGS__) +#else +#include +#define surf_callback(arg1, ...) boost::signals2::signal +#define surf_callback_connect(callback, fun_ptr) callback.connect(fun_ptr) +#define surf_callback_emit(callback, ...) callback(__VA_ARGS__) +#endif extern tmgr_history_t history; #define NO_MAX_DURATION -1.0 @@ -44,13 +58,9 @@ extern int sg_gtnets_jitter_seed; #endif extern xbt_dynar_t surf_path; -#ifdef __cplusplus extern "C" { -#endif XBT_PUBLIC(double) surf_get_clock(void); -#ifdef __cplusplus } -#endif extern double sg_sender_gap; XBT_PUBLIC(int) SURF_CPU_LEVEL; //Surf cpu level @@ -71,8 +81,15 @@ typedef boost::function ResourceCallback; typedef Action* ActionPtr; typedef boost::function ActionCallback; -//class ActionLmm; -typedef ActionLmm* ActionLmmPtr; +typedef boost::intrusive::list ActionList; +typedef ActionList* ActionListPtr; +typedef boost::intrusive::list_base_hook<> actionHook; + +struct lmmTag; +typedef boost::intrusive::list > > > ActionLmmList; +typedef ActionLmmList* ActionLmmListPtr; +typedef boost::intrusive::list_base_hook > actionLmmHook; + enum heap_action_type{ LATENCY = 100, @@ -92,31 +109,55 @@ XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail; XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth; XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency; - /********* * Model * *********/ XBT_PUBLIC_DATA(xbt_dynar_t) model_list; class Model { + const char *p_name; + + ActionListPtr p_readyActionSet; /**< Actions in state SURF_ACTION_READY */ + ActionListPtr p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */ + ActionListPtr p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */ + ActionListPtr p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */ + + ResourceCallback m_resOnCB, m_resOffCB; + ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB; + +protected: + ActionLmmListPtr p_modifiedSet; + + lmm_system_t p_maxminSystem; + e_UM_t p_updateMechanism; + int m_selectiveUpdate; + xbt_heap_t p_actionHeap; + public: - Model(string name); + Model(const char *name); virtual ~Model(); - //ResourcePtr createResource(string name); + const char *getName() {return p_name;} + virtual ActionListPtr getReadyActionSet() {return p_readyActionSet;} + virtual ActionListPtr getRunningActionSet() {return p_runningActionSet;} + virtual ActionListPtr getFailedActionSet() {return p_failedActionSet;} + virtual ActionListPtr getDoneActionSet() {return p_doneActionSet;} + virtual ActionLmmListPtr getModifiedSet() {return p_modifiedSet;} + lmm_system_t getMaxminSystem() {return p_maxminSystem;} + e_UM_t getUpdateMechanism() {return p_updateMechanism;} + xbt_heap_t getActionHeap() {return p_actionHeap;} + ActionPtr createAction(double _cost, bool _failed); virtual double shareResources(double now); virtual double shareResourcesLazy(double now); virtual double shareResourcesFull(double now); - double shareResourcesMaxMin(xbt_swag_t running_actions, + double shareResourcesMaxMin(ActionListPtr running_actions, lmm_system_t sys, void (*solve) (lmm_system_t)); 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;}; - void addTurnedOnCallback(ResourceCallback rc); void notifyResourceTurnedOn(ResourcePtr r); @@ -129,25 +170,6 @@ public: void notifyActionResume(ActionPtr a); void addActionSuspendCallback(ActionCallback ac); void notifyActionSuspend(ActionPtr a); - - lmm_system_t p_maxminSystem; - e_UM_t p_updateMechanism; - xbt_swag_t p_modifiedSet; - xbt_heap_t p_actionHeap; - int m_selectiveUpdate; - - xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */ - xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */ - xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */ - xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */ - string m_name; - -protected: - std::vector m_failedActions, m_runningActions; - -private: - ResourceCallback m_resOnCB, m_resOffCB; - ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB; }; /************ @@ -164,120 +186,130 @@ typedef struct { } s_surf_metric_t; class Resource { + void *p_resource; + const char *p_name; + ModelPtr p_model; + xbt_dict_t p_properties; + bool m_running; + +protected: + e_surf_resource_state_t m_stateCurrent; + public: Resource(); - Resource(ModelPtr model, const char *name, xbt_dict_t properties); + Resource(ModelPtr model, const char *name, xbt_dict_t props); + Resource(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint); + Resource(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit); + Resource(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit, lmm_constraint_t constraint); + virtual ~Resource() { - xbt_free((void*)m_name); - xbt_dict_free(&m_properties); + xbt_free((void*)p_name); + xbt_dict_free(&p_properties); }; - virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0; + ModelPtr getModel() {return p_model;}; + const char *getName() {return p_name;}; + virtual xbt_dict_t getProperties() {return p_properties;}; - //private + virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0; virtual bool isUsed()=0; - //FIXME:updateActionState(); - //FIXME:updateResourceState(); - //FIXME:finilize(); - bool isOn(); void turnOn(); void turnOff(); void setName(string name); - const char *getName(); - virtual xbt_dict_t getProperties(); - ModelPtr getModel() {return p_model;}; virtual e_surf_resource_state_t getState(); virtual void setState(e_surf_resource_state_t state); - void printModel() { std::cout << p_model->getName() << "<