X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/446069ad8e6d4580649af853f64ebbd259737bbe..7fb4337fa68b21ac48b0160cc9461c5a87199598:/src/surf/surf_interface.cpp diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 31cf110b31..798c991f8b 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -476,52 +476,25 @@ double Model::next_occuring_event_full(double /*now*/) { return 0.0; } -double Model::shareResourcesMaxMin(ActionList *running_actions, - lmm_system_t sys, - void (*solve) (lmm_system_t)) +double shareResourcesMaxMin(ActionList *runningActions, lmm_system_t sys, void (*solve) (lmm_system_t)) { - Action *action = nullptr; - double min = -1; - double value = -1; - solve(sys); - ActionList::iterator it(running_actions->begin()), itend(running_actions->end()); - for(; it != itend ; ++it) { - action = &*it; - value = lmm_variable_getvalue(action->getVariable()); - if ((value > 0) || (action->getMaxDuration() >= 0)) - break; - } - - if (!action) - return -1.0; - - if (value > 0) { - if (action->getRemains() > 0) - min = action->getRemainsNoUpdate() / value; - else - min = 0.0; - if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) - min = action->getMaxDuration(); - } else - min = action->getMaxDuration(); - - - for (++it; it != itend; ++it) { - action = &*it; - value = lmm_variable_getvalue(action->getVariable()); + double min = -1; + for(auto it(runningActions->begin()), itend(runningActions->end()); it != itend ; ++it) { + Action *action = &*it; + double value = lmm_variable_getvalue(action->getVariable()); if (value > 0) { if (action->getRemains() > 0) value = action->getRemainsNoUpdate() / value; else value = 0.0; - if (value < min) { + if (min < 0 || value < min) { min = value; XBT_DEBUG("Updating min (value) with %p: %f", action, min); } } - if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) { + if ((action->getMaxDuration() >= 0) && (min<0 || action->getMaxDuration() < min)) { min = action->getMaxDuration(); XBT_DEBUG("Updating min (duration) with %p: %f", action, min); } @@ -534,11 +507,11 @@ double Model::shareResourcesMaxMin(ActionList *running_actions, void Model::updateActionsState(double now, double delta) { if (updateMechanism_ == UM_FULL) - updateActionsStateFull(now, delta); + updateActionsStateFull(now, delta); else if (updateMechanism_ == UM_LAZY) - updateActionsStateLazy(now, delta); + updateActionsStateLazy(now, delta); else - xbt_die("Invalid cpu update mechanism!"); + xbt_die("Invalid cpu update mechanism!"); } void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)