From de4f4741cf1811ceeedc821d7a90a0fea332525b Mon Sep 17 00:00:00 2001 From: velho Date: Wed, 25 Jun 2008 15:08:25 +0000 Subject: [PATCH] Minimize forking effort in network_model. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5821 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/network_gtnets.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index 778c3f392a..d1c58ebc33 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -9,6 +9,9 @@ #include "gtnets/gtnets_interface.h" #include "xbt/str.h" + +static double time_to_next_flow_completion=-1; + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf, "Logging specific to the SURF network module"); @@ -346,7 +349,11 @@ static double share_resources(double now) if (!xbt_swag_size(running_actions)) return -1.0; - return gtnets_get_time_to_next_flow_completion(); + xbt_assert0(time_to_next_flow_completion, "Time to next flow completion not initialized!\n"); + + time_to_next_flow_completion = gtnets_get_time_to_next_flow_completion(); + + return time_to_next_flow_completion; } /* delta: by how many time units the simulation must advance */ @@ -363,9 +370,6 @@ static void update_actions_state(double now, double delta) xbt_swag_t running_actions = surf_network_model->common_public->states.running_action_set; - double time_to_next_flow_completion = - gtnets_get_time_to_next_flow_completion(); - /* If there are no renning flows, just return */ if (time_to_next_flow_completion < 0.0) { return; -- 2.20.1