X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c96b8ddfe1c923257f43ee40334ceb820226694c..dadfefc9f3cc6cf0fc28a9025307f9f08dc4ac96:/src/surf/storage_n11.cpp diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index e23abc2c8a..fd4a72fc6b 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -9,9 +9,6 @@ #include /*ceil*/ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage); -static int storage_selective_update = 0; -static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = nullptr; - /************* * CallBacks * *************/ @@ -64,20 +61,10 @@ namespace simgrid { namespace surf { StorageN11Model::StorageN11Model() : StorageModel() { - Action *action = nullptr; - - XBT_DEBUG("surf_storage_model_init_internal"); - - storage_running_action_set_that_does_not_need_being_checked = xbt_swag_new(xbt_swag_offset(*action, stateHookup_)); - if (!maxminSystem_) { - maxminSystem_ = lmm_system_new(storage_selective_update); - } + maxminSystem_ = lmm_system_new(true /* lazy update */); } -StorageN11Model::~StorageN11Model(){ - xbt_swag_free(storage_running_action_set_that_does_not_need_being_checked); - storage_running_action_set_that_does_not_need_being_checked = nullptr; -} +StorageN11Model::~StorageN11Model() = default; #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area Storage *StorageN11Model::createStorage(const char* id, const char* type_id, @@ -110,17 +97,13 @@ Storage *StorageN11Model::createStorage(const char* id, const char* type_id, return storage; } -double StorageN11Model::next_occuring_event(double /*now*/) +double StorageN11Model::nextOccuringEvent(double now) { - XBT_DEBUG("storage_share_resources"); + double min_completion = StorageModel::nextOccuringEventFull(now); - double min_completion = shareResourcesMaxMin(getRunningActionSet(), maxminSystem_, lmm_solve); - - double rate; - // Foreach disk for(auto storage: p_storageList) { - rate = 0; - // Foreach write action on disk + double rate = 0; + // Foreach write action on that disk for (auto write_action: storage->writeActions_) { rate += lmm_variable_getvalue(write_action->getVariable()); } @@ -133,20 +116,19 @@ double StorageN11Model::next_occuring_event(double /*now*/) void StorageN11Model::updateActionsState(double /*now*/, double delta) { - StorageAction *action = nullptr; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + + StorageAction *action = static_cast(&*it); if(action->m_type == WRITE){ // Update the disk usage // Update the file size // For each action of type write - double current_progress = - delta * lmm_variable_getvalue(action->getVariable()); + double current_progress = delta * lmm_variable_getvalue(action->getVariable()); long int incr = current_progress; XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld", @@ -174,22 +156,19 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta); - if (action->getMaxDuration() != NO_MAX_DURATION) + if (action->getMaxDuration() > NO_MAX_DURATION) action->updateMaxDuration(delta); if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 && action->p_storage->usedSize_ == action->p_storage->size_) { action->finish(); action->setState(Action::State::failed); - } else if ((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) { - action->finish(); - action->setState(Action::State::done); - } else if ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)) { + } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) || + ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) { action->finish(); action->setState(Action::State::done); } } - return; } /************ @@ -336,7 +315,6 @@ int StorageN11Action::unref() void StorageN11Action::cancel() { setState(Action::State::failed); - return; } void StorageN11Action::suspend()