]> AND Public Git Repository - simgrid.git/blobdiff - src/surf/cpu_interface.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / surf / cpu_interface.cpp
index 730f12e67a3b65e19a10e1d2fe781201106fe3f5..cd3173e5221c26e98c368e285d7fded0e7bae7b0 100644 (file)
@@ -16,9 +16,11 @@ CpuPtr getActionCpu(CpuActionPtr action) {
                                         (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 *
@@ -44,8 +46,6 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
     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);
@@ -115,8 +115,6 @@ void CpuModel::updateActionsStateFull(double now, double delta)
       action->finish();
       action->setState(SURF_ACTION_DONE);
     }
-    surf_callback_emit(updateCpuActionCallbacks, action);
-    //action->updateEnergy();
   }
 
   return;
@@ -126,6 +124,10 @@ void CpuModel::updateActionsStateFull(double now, double delta)
  * Resource *
  ************/
 
+Cpu::Cpu(){
+  surf_callback_emit(cpuCreatedCallbacks, this);
+}
+
 Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
                 int core, double powerPeak, double powerScale)
  : Resource(model, name, props)
@@ -134,7 +136,9 @@ Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
  , m_powerScale(powerScale)
  , 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,
                 lmm_constraint_t constraint, int core, double powerPeak, double powerScale)
@@ -143,7 +147,7 @@ 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);
@@ -164,7 +168,7 @@ Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
 }
 
 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]);
@@ -191,6 +195,11 @@ int Cpu::getCore()
   return m_core;
 }
 
+void Cpu::setState(e_surf_resource_state_t state)
+{
+  Resource::setState(state);
+  surf_callback_emit(cpuStateChangedCallbacks, this);
+}
 /**********
  * Action *
  **********/
@@ -301,6 +310,10 @@ void CpuAction::setAffinity(CpuPtr cpu, unsigned long mask)
   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);
+}