X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9e68ca10e951fb61e944c99c7774b1e415ae9f6d..5148a41df673de64b6e939aaf0e605426151dae8:/src/surf/maxmin.c diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index 3d49f84d12..420695c010 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011. The SimGrid Team. +/* Copyright (c) 2004-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ void lmm_system_free(lmm_system_t sys) free(sys); } -XBT_INLINE void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var) +static XBT_INLINE void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var) { int i; int n; @@ -889,3 +889,30 @@ static void lmm_remove_all_modified_set(lmm_system_t sys) } xbt_swag_reset(&sys->modified_constraint_set); } + +/** + * Returns total resource load + * + * \param cnst the lmm_constraint_t associated to the resource + * + */ +double lmm_constraint_get_usage(lmm_constraint_t cnst) { + double usage = 0.0; + xbt_swag_t elem_list = &(cnst->element_set); + lmm_element_t elem = NULL; + + xbt_swag_foreach(elem, elem_list) { + /* 0-weighted elements (ie, sleep actions) are at the end of the swag and we don't want to consider them */ + if (elem->variable->weight <= 0) + break; + if ((elem->value > 0)) { + if (cnst->shared) + usage += elem->value * elem->variable->value; + else if (usage < elem->value * elem->variable->value) + usage = elem->value * elem->variable->value; + } + } + return usage; +} + +