From: Arnaud Giersch Date: Mon, 25 Feb 2019 13:39:22 +0000 (+0100) Subject: NO_MAX_DURATION is a special value, use (in)equality for testing. X-Git-Tag: v3_22~240 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/da06ff05b3164a8de84cfcfc427384c7791e5647 NO_MAX_DURATION is a special value, use (in)equality for testing. --- diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index b27d229ede..1e8998c727 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -73,7 +73,7 @@ double Model::next_occuring_event_lazy(double now) min = now + time_to_completion; // when the task will complete if nothing changes } - if ((action->get_max_duration() > NO_MAX_DURATION) && + if ((action->get_max_duration() != NO_MAX_DURATION) && (min <= -1 || action->get_start_time() + action->get_max_duration() < min)) { // when the task will complete anyway because of the deadline if any min = action->get_start_time() + action->get_max_duration(); diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index ab669d9683..a82c95663c 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -184,7 +184,7 @@ CpuAction* CpuCas01::sleep(double duration) // FIXME: sleep variables should not consume 1.0 in System::expand() action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; - if (duration < 0) // NO_MAX_DURATION + if (duration == NO_MAX_DURATION) action->set_state(simgrid::kernel::resource::Action::State::IGNORED); get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 0f5809fcef..4c8aa1dfe4 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -463,18 +463,18 @@ void CpuTi::update_actions_finish_time(double now) action.set_finish_time(speed_integrated_trace_->solve(now, total_area)); /* verify which event will happen before (max_duration or finish time) */ - if (action.get_max_duration() > NO_MAX_DURATION && + if (action.get_max_duration() != NO_MAX_DURATION && action.get_start_time() + action.get_max_duration() < action.get_finish_time()) min_finish = action.get_start_time() + action.get_max_duration(); else min_finish = action.get_finish_time(); } else { /* put the max duration time on heap */ - if (action.get_max_duration() > NO_MAX_DURATION) + if (action.get_max_duration() != NO_MAX_DURATION) min_finish = action.get_start_time() + action.get_max_duration(); } /* add in action heap */ - if (min_finish > NO_MAX_DURATION) + if (min_finish != NO_MAX_DURATION) get_model()->get_action_heap().update(&action, min_finish, kernel::resource::ActionHeap::Type::unset); else get_model()->get_action_heap().remove(&action); @@ -557,7 +557,7 @@ CpuAction *CpuTi::sleep(double duration) action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; - if (duration < 0) // NO_MAX_DURATION + if (duration == NO_MAX_DURATION) action->set_state(simgrid::kernel::resource::Action::State::IGNORED); action_set_.push_back(*action); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index f590295df9..e884c3bd00 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -199,11 +199,11 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta) } action.update_remains(action.get_variable()->get_value() * delta); - if (action.get_max_duration() > NO_MAX_DURATION) + if (action.get_max_duration() != NO_MAX_DURATION) action.update_max_duration(delta); if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) || - ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { + ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { action.finish(Action::State::FINISHED); } } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index f45d2f7b33..bd871ad1b1 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -110,7 +110,7 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) */ if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) || - ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { + ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { action.finish(kernel::resource::Action::State::FINISHED); } else { /* Need to check that none of the model has failed */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 71b99a901d..c91b47ba9e 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -77,7 +77,7 @@ void StorageN11Model::update_actions_state(double /*now*/, double delta) action.update_max_duration(delta); if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) || - ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { + ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { action.finish(kernel::resource::Action::State::FINISHED); } }