+ speed_.scale = speedIntegratedTrace_->getPowerScale(surf_get_clock());
+ return Cpu::getAvailableSpeed();
+}
+
+/** @brief Update the remaining amount of actions */
+void CpuTi::updateRemainingAmount(double now)
+{
+
+ /* already updated */
+ if (lastUpdate_ >= now)
+ return;
+
+ /* compute the integration area */
+ double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak;
+ XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
+
+ for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) {
+ CpuTiAction *action = &*it;
+ /* action not running, skip it */
+ if (action->getStateSet() != getModel()->getRunningActionSet())
+ continue;
+
+ /* bogus priority, skip it */
+ if (action->getPriority() <= 0)
+ continue;
+
+ /* action suspended, skip it */
+ if (action->suspended_ != 0)
+ continue;
+
+ /* action don't need update */
+ if (action->getStartTime() >= now)
+ continue;
+
+ /* skip action that are finishing now */
+ if (action->finishTime_ >= 0 && action->finishTime_ <= now)
+ continue;
+
+ /* update remaining */
+ action->updateRemains(area_total / (sumPriority_ * action->getPriority()));
+ XBT_DEBUG("Update remaining action(%p) remaining %f", action, action->remains_);
+ }
+ lastUpdate_ = now;
+}
+
+CpuAction *CpuTi::execution_start(double size)
+{
+ XBT_IN("(%s,%g)", getName(), size);
+ CpuTiAction *action = new CpuTiAction(static_cast<CpuTiModel*>(getModel()), size, isOff(), this);
+
+ actionSet_->push_back(*action);
+
+ XBT_OUT();
+ return action;
+}
+
+
+CpuAction *CpuTi::sleep(double duration)
+{
+ if (duration > 0)
+ duration = MAX(duration, sg_surf_precision);
+
+ XBT_IN("(%s,%g)", getName(), duration);
+ CpuTiAction *action = new CpuTiAction(static_cast<CpuTiModel*>(getModel()), 1.0, isOff(), this);
+
+ action->maxDuration_ = duration;
+ action->suspended_ = 2;
+ if (duration == NO_MAX_DURATION) {
+ /* Move to the *end* of the corresponding action set. This convention
+ is used to speed up update_resource_state */
+ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
+ action->stateSet_ = static_cast<CpuTiModel*>(getModel())->runningActionSetThatDoesNotNeedBeingChecked_;
+ action->getStateSet()->push_back(*action);
+ }
+
+ actionSet_->push_back(*action);
+
+ XBT_OUT();
+ return action;
+}
+
+void CpuTi::modified(bool modified){
+ CpuTiList *modifiedCpu = static_cast<CpuTiModel*>(getModel())->modifiedCpu_;
+ if (modified) {
+ if (!cpu_ti_hook.is_linked()) {
+ modifiedCpu->push_back(*this);
+ }
+ } else {
+ if (cpu_ti_hook.is_linked()) {
+ modifiedCpu->erase(modifiedCpu->iterator_to(*this));
+ }
+ }