X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/89edccc4eb98274e36279f5940ce8b4a0e887f4b..c3f81b26d8e8d696a2cc706d18388d8d681cc26c:/src/surf/maxmin.cpp diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 7a42307469..2ed593c3de 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2014. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ lmm_system_t lmm_system_new(int selective_update) l->selective_update_active = selective_update; l->visited_counter = 1; - XBT_DEBUG("Setting selective_update_active flag to %d\n", + XBT_DEBUG("Setting selective_update_active flag to %d", l->selective_update_active); xbt_swag_init(&(l->variable_set), @@ -431,6 +431,31 @@ lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, return NULL; } +//if we modify the swag between calls, normal version may loop forever +//this safe version ensures that we browse the swag elements only once +lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, + lmm_constraint_t cnst, + lmm_element_t * elem, + lmm_element_t * nextelem, + int * numelem) +{ + if (!(*elem)){ + *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->element_set)); + *numelem = xbt_swag_size(&(cnst->element_set))-1; + }else{ + *elem = *nextelem; + if(*numelem>0){ + (*numelem) --; + }else + return NULL; + } + if (*elem){ + *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->element_set.offset); + return (*elem)->variable; + }else + return NULL; +} + void *lmm_constraint_id(lmm_constraint_t cnst) { return cnst->id; @@ -651,7 +676,7 @@ void lmm_solve(lmm_system_t sys) cnst->usage = elem->value / elem->variable->weight; make_elem_active(elem); - ActionPtr action = static_cast(elem->variable->id); + Action *action = static_cast(elem->variable->id); if (sys->keep_track && !action->is_linked()) sys->keep_track->push_back(*action); }