XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
m_core = core;
- m_stateCurrent = stateInitial;
+ setState(stateInitial);
if (powerTrace)
p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
- if(m_stateCurrent == SURF_RESOURCE_OFF)
+ if(getState() == SURF_RESOURCE_OFF)
xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
} else {
lmm_constraint_t cnst = getConstraint();
- m_stateCurrent = SURF_RESOURCE_OFF;
+ setState(SURF_RESOURCE_OFF);
while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->getMaxminSystem(), cnst, &elem))) {
ActionPtr action = static_cast<ActionPtr>(lmm_variable_id(var));
{
XBT_IN("(%s,%g)", getName(), size);
- CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, size, m_stateCurrent != SURF_RESOURCE_ON,
+ CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, size, getState() != SURF_RESOURCE_ON,
m_powerScale * m_powerPeak, getConstraint());
XBT_OUT();
duration = MAX(duration, MAXMIN_PRECISION);
XBT_IN("(%s,%g)", getName(), duration);
- CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, 1.0, m_stateCurrent != SURF_RESOURCE_ON,
+ CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, 1.0, getState() != SURF_RESOURCE_ON,
m_powerScale * m_powerPeak, getConstraint());
(action->getModel()->getMaxminSystem(),
action->getVariable(), 0)));
}
-surf_callback(void, CpuPtr) createCpuCallbacks;
-surf_callback(void, CpuPtr) deleteCpuCallbacks;
-surf_callback(void, CpuActionPtr) updateCpuActionCallbacks;
+
+surf_callback(void, CpuPtr) cpuCreatedCallbacks;
+surf_callback(void, CpuPtr) cpuDestructedCallbacks;
+surf_callback(void, CpuPtr) cpuStateChangedCallbacks;
+surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks;
/*********
* Model *
action->finish();
XBT_CDEBUG(surf_kernel, "Action %p finished", action);
- surf_callback_emit(updateCpuActionCallbacks, action);
-
/* set the remains to 0 due to precision problems when updating the remaining amount */
action->setRemains(0);
action->setState(SURF_ACTION_DONE);
action->finish();
action->setState(SURF_ACTION_DONE);
}
- surf_callback_emit(updateCpuActionCallbacks, action);
- //action->updateEnergy();
}
return;
************/
Cpu::Cpu(){
- surf_callback_emit(createCpuCallbacks, this);
+ surf_callback_emit(cpuCreatedCallbacks, this);
}
Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
, p_constraintCore(NULL)
, p_constraintCoreId(NULL)
{
- surf_callback_emit(createCpuCallbacks, this);
+ surf_callback_emit(cpuCreatedCallbacks, this);
}
Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
, m_powerPeak(powerPeak)
, m_powerScale(powerScale)
{
- surf_callback_emit(createCpuCallbacks, this);
+ surf_callback_emit(cpuCreatedCallbacks, this);
/* At now, we assume that a VM does not have a multicore CPU. */
if (core > 1)
xbt_assert(model == surf_cpu_model_pm);
}
Cpu::~Cpu(){
- surf_callback_emit(deleteCpuCallbacks, this);
+ surf_callback_emit(cpuDestructedCallbacks, this);
if (p_constraintCoreId){
for (int i = 0; i < m_core; i++) {
xbt_free(p_constraintCoreId[i]);
return m_core;
}
+void Cpu::setState(e_surf_resource_state_t state)
+{
+ Resource::setState(state);
+ surf_callback_emit(cpuStateChangedCallbacks, this);
+}
/**********
* Action *
**********/
if (cpu->getModel()->getUpdateMechanism() == UM_LAZY) {
/* FIXME (hypervisor): Do we need to do something for the LAZY mode? */
}
-
XBT_OUT();
}
+
+void CpuAction::setState(e_surf_action_state_t state){
+ Action::setState(state);
+ surf_callback_emit(cpuActionStateChangedCallbacks, this);
+}
* @brief Callbacks handler which emit the callbacks after Cpu creation *
* @detail Callback functions have the following signature: `void(CpuPtr)`
*/
-extern surf_callback(void, CpuPtr) createCpuCallbacks;
+extern surf_callback(void, CpuPtr) cpuCreatedCallbacks;
/** @ingroup SURF_callbacks
* @brief Callbacks handler which emit the callbacks after Cpu destruction *
* @detail Callback functions have the following signature: `void(CpuPtr)`
*/
-extern surf_callback(void, CpuPtr) deleteCpuCallbacks;
+extern surf_callback(void, CpuPtr) cpuDestructedCallbacks;
/** @ingroup SURF_callbacks
- * @brief Callbacks handler which emit the callbacks after CpuAction update *
+ * @brief Callbacks handler which emit the callbacks after Cpu State changed *
* @detail Callback functions have the following signature: `void(CpuActionPtr)`
*/
-extern surf_callback(void, CpuActionPtr) updateCpuActionCallbacks;
+extern surf_callback(void, CpuPtr) cpuStateChangedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after CpuAction State changed *
+ * @detail Callback functions have the following signature: `void(CpuActionPtr)`
+ */
+extern surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks;
/*********
* Model *
*/
CpuPtr createResource(string name);
+ void setState(e_surf_resource_state_t state);
void updateActionsStateLazy(double now, double delta);
void updateActionsStateFull(double now, double delta);
int core, double powerPeak, double powerScale);
/**
- * @brieaf Cpu destructor
+ * @brief Cpu destructor
*/
~Cpu();
virtual void setPowerPeakAt(int pstate_index)=0;
+ void setState(e_surf_resource_state_t state);
+
void addTraces(void);
int m_core;
double m_powerPeak; /*< CPU power peak */
*/
virtual void setBound(double bound);
+ void setState(e_surf_action_state_t state);
+
void updateRemainingLazy(double now);
double m_bound;
};
: Cpu(model, name, properties, core, 0, powerScale)
{
p_powerEvent = NULL;
- m_stateCurrent = stateInitial;
+ setState(stateInitial);
m_powerScale = powerScale;
m_core = core;
tmgr_trace_t empty_trace;
} else if (event_type == p_stateEvent) {
if (value > 0) {
- if(m_stateCurrent == SURF_RESOURCE_OFF)
+ if(getState() == SURF_RESOURCE_OFF)
xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
} else {
- m_stateCurrent = SURF_RESOURCE_OFF;
+ setState(SURF_RESOURCE_OFF);
/* put all action running on cpu to failed */
xbt_swag_foreach(_action, p_actionSet) {
CpuActionPtr CpuTi::execute(double size)
{
XBT_IN("(%s,%g)", getName(), size);
- CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), size, m_stateCurrent != SURF_RESOURCE_ON, this);
+ CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), size, getState() != SURF_RESOURCE_ON, this);
xbt_swag_insert(action, p_actionSet);
duration = MAX(duration, MAXMIN_PRECISION);
XBT_IN("(%s,%g)", getName(), duration);
- CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), 1.0, m_stateCurrent != SURF_RESOURCE_ON, this);
+ CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), 1.0, getState() != SURF_RESOURCE_ON, this);
action->m_maxDuration = duration;
action->m_suspended = 2;
e_surf_link_sharing_policy_t policy)
: NetworkLink(model, name, props, lmm_constraint_new(system, this, constraint_value), history, state_trace)
{
- m_stateCurrent = state_init;
+ setState(state_init);
p_power.scale = 1.0;
p_power.peak = metric_peak;
p_latEvent = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
else {
lmm_constraint_t cnst = getConstraint();
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- m_stateCurrent = SURF_RESOURCE_OFF;
+ setState(SURF_RESOURCE_OFF);
while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) {
ActionPtr action = (ActionPtr) lmm_variable_id(var);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
"Logging specific to the SURF network module");
+/*************
+ * Callbacks *
+ *************/
+
+surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks;
+surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks;
+surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks;
+surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks;
+
+/*********
+ * Model *
+ *********/
+
NetworkModelPtr surf_network_model = NULL;
xbt_dynar_t NetworkModel::getRoute(RoutingEdgePtr src, RoutingEdgePtr dst)
return rate;
}
+/************
+ * Resource *
+ ************/
+
NetworkLink::NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props)
: Resource(model, name, props)
, p_latEvent(NULL)
-{}
+{
+ surf_callback_emit(networkLinkCreatedCallbacks, this);
+}
NetworkLink::NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props,
lmm_constraint_t constraint,
: Resource(model, name, props, constraint),
p_latEvent(NULL)
{
+ surf_callback_emit(networkLinkCreatedCallbacks, this);
if (state_trace)
p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
}
+NetworkLink::~NetworkLink()
+{
+ surf_callback_emit(networkLinkDestructedCallbacks, this);
+}
+
bool NetworkLink::isUsed()
{
return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
return lmm_constraint_is_shared(getConstraint());
}
+void NetworkLink::setState(e_surf_resource_state_t state){
+ Resource::setState(state);
+ surf_callback_emit(networkLinkStateChangedCallbacks, this);
+}
+
+/**********
+ * Action *
+ **********/
+
+void NetworkAction::setState(e_surf_action_state_t state){
+ Action::setState(state);
+ surf_callback_emit(networkActionStateChangedCallbacks, this);
+}
+
#endif /* NETWORK_INTERFACE_CPP_ */
class NetworkAction;
typedef NetworkAction *NetworkActionPtr;
+/*************
+ * Callbacks *
+ *************/
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after NetworkLink creation *
+ * @detail Callback functions have the following signature: `void(NetworkLinkPtr)`
+ */
+extern surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after NetworkLink destruction *
+ * @detail Callback functions have the following signature: `void(NetworkLinkPtr)`
+ */
+extern surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after NetworkLink State changed *
+ * @detail Callback functions have the following signature: `void(NetworkLinkActionPtr)`
+ */
+extern surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after NetworkAction State changed *
+ * @detail Callback functions have the following signature: `void(NetworkActionPtr)`
+ */
+extern surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks;
+
/*********
* Tools *
*********/
tmgr_history_t history,
tmgr_trace_t state_trace);
+ /**
+ * @brief NetworkLink destructor
+ */
+ ~NetworkLink();
+
/**
* @brief Get the bandwidth in bytes per second of current NetworkLink
*
*/
bool isUsed();
+ void setState(e_surf_resource_state_t state);
+
/* Using this object with the public part of
model does not make sense */
double m_latCurrent;
NetworkAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
: Action(model, cost, failed, var) {};
+ void setState(e_surf_action_state_t state);
+
double m_latency;
double m_latCurrent;
double m_weight;
std::map<CpuPtr, CpuEnergyPtr> *surf_energy=NULL;
-static void createCpuCallback(CpuPtr cpu){
+static void energyCpuCreatedCallback(CpuPtr cpu){
(*surf_energy)[cpu] = new CpuEnergy(cpu);
}
-static void deleteCpuCallback(CpuPtr cpu){
+static void energyCpuDestructedCallback(CpuPtr cpu){
std::map<CpuPtr, CpuEnergyPtr>::iterator cpuIt = surf_energy->find(cpu);
xbt_assert(cpuIt != surf_energy->end(), "The cpu is not in surf_energy.");
XBT_INFO("Total energy (Joules) of host %s: %f", cpu->getName(), cpuIt->second->getConsumedEnergy());
surf_energy->erase(cpuIt);
}
-static void updateActionEnergyCallback(CpuActionPtr action){
+static void energyCpuActionStateChangedCallback(CpuActionPtr action){
CpuPtr cpu = getActionCpu(action);
CpuEnergyPtr cpu_energy = (*surf_energy)[cpu];
void sg_energy_plugin_init() {
if (surf_energy == NULL) {
surf_energy = new std::map<CpuPtr, CpuEnergyPtr>();
- surf_callback_connect(createCpuCallbacks, createCpuCallback);
- surf_callback_connect(deleteCpuCallbacks, deleteCpuCallback);
- surf_callback_connect(updateCpuActionCallbacks, updateActionEnergyCallback);
+ surf_callback_connect(cpuCreatedCallbacks, energyCpuCreatedCallback);
+ surf_callback_connect(cpuDestructedCallbacks, energyCpuDestructedCallback);
+ surf_callback_connect(cpuActionStateChangedCallbacks, energyCpuActionStateChangedCallback);
+
}
}
xbt_dynar_t mount_list = NULL;
StorageModelPtr surf_storage_model = NULL;
+/*************
+ * Callbacks *
+ *************/
+
+surf_callback(void, StoragePtr) storageCreatedCallbacks;
+surf_callback(void, StoragePtr) storageDestructedCallbacks;
+surf_callback(void, StoragePtr) storageStateChangedCallbacks;
+surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks;
+
/*********
* Model *
*********/
, p_typeId(xbt_strdup(type_id))
, p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL))
{
+ surf_callback_emit(storageCreatedCallbacks, this);
p_content = parseContent(content_name);
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
}
Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props,
, m_size(size), m_usedSize(0)
, p_typeId(xbt_strdup(type_id))
, p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL)) {
+ surf_callback_emit(storageCreatedCallbacks, this);
p_content = parseContent(content_name);
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
}
Storage::~Storage(){
+ surf_callback_emit(storageDestructedCallbacks, this);
xbt_dict_free(&p_content);
xbt_dynar_free(&p_writeActions);
free(p_typeId);
THROW_UNIMPLEMENTED;
}
+void Storage::setState(e_surf_resource_state_t state)
+{
+ Resource::setState(state);
+ surf_callback_emit(storageStateChangedCallbacks, this);
+}
+
xbt_dict_t Storage::getContent()
{
/* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
return m_size;
}
-
-
/**********
* Action *
**********/
, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) {
}
+void StorageAction::setState(e_surf_action_state_t state){
+ Action::setState(state);
+ surf_callback_emit(storageActionStateChangedCallbacks, this);
+}
class StorageAction;
typedef StorageAction *StorageActionPtr;
+/*************
+ * Callbacks *
+ *************/
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Storage creation *
+ * @detail Callback functions have the following signature: `void(StoragePtr)`
+ */
+extern surf_callback(void, StoragePtr) storageCreatedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Storage destruction *
+ * @detail Callback functions have the following signature: `void(StoragePtr)`
+ */
+extern surf_callback(void, StoragePtr) storageDestructedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Storage State changed *
+ * @detail Callback functions have the following signature: `void(StorageActionPtr)`
+ */
+extern surf_callback(void, StoragePtr) storageStateChangedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after StorageAction State changed *
+ * @detail Callback functions have the following signature: `void(StorageActionPtr)`
+ */
+extern surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks;
+
/*********
* Model *
*********/
*/
void updateState(tmgr_trace_event_t event_type, double value, double date);
+ void setState(e_surf_resource_state_t state);
+
xbt_dict_t p_content;
char* p_contentType;
sg_size_t m_size;
StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
StoragePtr storage, e_surf_action_storage_type_t type);
+ void setState(e_surf_action_state_t state);
+
e_surf_action_storage_type_t m_type;
StoragePtr p_storage;
surf_file_t p_file;
StorageActionPtr StorageN11::ls(const char* path)
{
- StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, LS);
action->p_lsDict = NULL;
xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
file->mount = xbt_strdup(mount);
file->current_position = 0;
- StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN);
action->p_file = file;
return action;
}
free(fd->name);
free(fd->mount);
xbt_free(fd);
- StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, CLOSE);
return action;
}
else
fd->current_position += size;
- StorageActionPtr action = new StorageN11Action(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
+ StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, READ);
return action;
}
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
- StorageActionPtr action = new StorageN11Action(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+ StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
fd->current_position += size;
// If the storage is full
*/
virtual void setState(e_surf_resource_state_t state);
-protected:
- e_surf_resource_state_t m_stateCurrent;
-
private:
const char *p_name;
xbt_dict_t p_properties;
ModelPtr p_model;
void *p_resource;
bool m_running;
+ e_surf_resource_state_t m_stateCurrent;
/* LMM */
public:
*
* @param state The new state of the current Action
*/
- virtual void setState(e_surf_action_state_t state); /**< Change state*/
+ virtual void setState(e_surf_action_state_t state);
/**
* @brief Get the bound of the current Action
WorkstationVMModelPtr surf_vm_workstation_model = NULL;
+/*************
+ * Callbacks *
+ *************/
+
+surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
+surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
+surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
+
/*********
* Model *
*********/
* Resource *
************/
+WorkstationVM::WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
+ RoutingEdgePtr netElm, CpuPtr cpu)
+: Workstation(model, name, props, NULL, netElm, cpu)
+{
+ surf_callback_emit(workstationVMCreatedCallbacks, this);
+}
+
/*
* A physical host does not disapper in the current SimGrid code, but a VM may
* disapper during a simulation.
*/
WorkstationVM::~WorkstationVM()
{
+ surf_callback_emit(workstationVMDestructedCallbacks, this);
+}
+
+void WorkstationVM::setState(e_surf_resource_state_t state){
+ Resource::setState(state);
+ surf_callback_emit(workstationVMStateChangedCallbacks, this);
}
/*
class WorkstationVMLmm;
typedef WorkstationVMLmm *WorkstationVMLmmPtr;
+/*************
+ * Callbacks *
+ *************/
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after WorkstationVM creation *
+ * @detail Callback functions have the following signature: `void(WorkstationVMPtr)`
+ */
+extern surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after WorkstationVM destruction *
+ * @detail Callback functions have the following signature: `void(WorkstationVMPtr)`
+ */
+extern surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after WorkstationVM State changed *
+ * @detail Callback functions have the following signature: `void(WorkstationVMActionPtr)`
+ */
+extern surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
+
/*********
* Model *
*********/
*/
virtual void createResource(const char *name, void *ind_phys_workstation)=0;
-
void adjustWeightOfDummyCpuActions() {};
};
* @param cpu The Cpu associated to this Workstation
*/
WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
- RoutingEdgePtr netElm, CpuPtr cpu)
- : Workstation(model, name, props, NULL, netElm, cpu) {}
+ RoutingEdgePtr netElm, CpuPtr cpu);
/**
- * @brief WdorkstationVM estructor
+ * @brief WdorkstationVM destructor
*/
~WorkstationVM();
+ void setState(e_surf_resource_state_t state);
+
/**
* @brief Suspend the VM
*/
WorkstationModelPtr surf_workstation_model = NULL;
+/*************
+ * Callbacks *
+ *************/
+
+surf_callback(void, WorkstationPtr) workstationCreatedCallbacks;
+surf_callback(void, WorkstationPtr) workstationDestructedCallbacks;
+surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks;
+surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks;
+
/*********
* Model *
*********/
WorkstationModel::~WorkstationModel() {
}
-
-
/* Each VM has a dummy CPU action on the PM layer. This CPU action works as the
* constraint (capacity) of the VM in the PM layer. If the VM does not have any
* active task, the dummy CPU action must be deactivated, so that the VM does
/************
* Resource *
************/
+Workstation::Workstation()
+{
+ surf_callback_emit(workstationCreatedCallbacks, this);
+}
+
Workstation::Workstation(ModelPtr model, const char *name, xbt_dict_t props,
xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
: Resource(model, name, props)
, p_storage(storage), p_netElm(netElm), p_cpu(cpu)
-{}
+{
+ surf_callback_emit(workstationCreatedCallbacks, this);
+}
Workstation::Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
: Resource(model, name, props, constraint)
, p_storage(storage), p_netElm(netElm), p_cpu(cpu)
-{}
+{
+ surf_callback_emit(workstationCreatedCallbacks, this);
+}
+
+Workstation::~Workstation(){
+ surf_callback_emit(workstationDestructedCallbacks, this);
+}
+
+void Workstation::setState(e_surf_resource_state_t state){
+ Resource::setState(state);
+ surf_callback_emit(workstationStateChangedCallbacks, this);
+}
int Workstation::getCore(){
return p_cpu->getCore();
/**********
* Action *
**********/
+
+void WorkstationAction::setState(e_surf_action_state_t state){
+ Action::setState(state);
+ surf_callback_emit(workstationActionStateChangedCallbacks, this);
+}
class WorkstationAction;
typedef WorkstationAction *WorkstationActionPtr;
+/*************
+ * Callbacks *
+ *************/
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Workstation creation *
+ * @detail Callback functions have the following signature: `void(WorkstationPtr)`
+ */
+extern surf_callback(void, WorkstationPtr) workstationCreatedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Workstation destruction *
+ * @detail Callback functions have the following signature: `void(WorkstationPtr)`
+ */
+extern surf_callback(void, WorkstationPtr) workstationDestructedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after Workstation State changed *
+ * @detail Callback functions have the following signature: `void(WorkstationActionPtr)`
+ */
+extern surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks;
+
+/** @ingroup SURF_callbacks
+ * @brief Callbacks handler which emit the callbacks after WorkstationAction State changed *
+ * @detail Callback functions have the following signature: `void(WorkstationActionPtr)`
+ */
+extern surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks;
+
/*********
* Tools *
*********/
public:
/**
* @brief Workstation consrtuctor
- * @details [long description]
*/
- Workstation(){};
+ Workstation();
/**
* @brief Workstation constructor
Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+ /**
+ * @brief Workstation destructor
+ */
+ ~ Workstation();
+
+ void setState(e_surf_resource_state_t state);
+
/**
* @brief Get the properties of the currenrt Workstation
*
WorkstationAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
: Action(model, cost, failed, var) {}
+ void setState(e_surf_action_state_t state);
};
if (power_trace)
p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(this));
- m_stateCurrent = state_initial;
+ setState(state_initial);
if (state_trace)
p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
}
if (bw_trace)
p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(this));
- m_stateCurrent = state_initial;
+ setState(state_initial);
m_latCurrent = lat_initial;
if (lat_trace)
p_power.event = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
else
- m_stateCurrent = SURF_RESOURCE_OFF;
+ setState(SURF_RESOURCE_OFF);
if (tmgr_trace_event_free(event_type))
p_stateEvent = NULL;
} else {
p_latEvent = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- m_stateCurrent = SURF_RESOURCE_ON;
+ setState(SURF_RESOURCE_ON);
else
- m_stateCurrent = SURF_RESOURCE_OFF;
+ setState(SURF_RESOURCE_OFF);
if (tmgr_trace_event_free(event_type))
p_stateEvent = NULL;
} else {
return p_cpu->getState();
}
-e_surf_resource_state_t CpuL07::getState()
-{
- return m_stateCurrent;
-}
-
double CpuL07::getSpeed(double load)
{
return load * p_power.scale;
bool isUsed();
//bool isUsed() {DIE_IMPOSSIBLE;};
void updateState(tmgr_trace_event_t event_type, double value, double date);
- e_surf_resource_state_t getState();
double getSpeed(double load);
double getAvailableSpeed();
CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};