A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug fix raised by Fabien Janvier. Returns a sensible value when asking whether there...
[simgrid.git]
/
src
/
surf
/
surf_timer.c
diff --git
a/src/surf/surf_timer.c
b/src/surf/surf_timer.c
index
9f4d72d
..
c86ddfe
100644
(file)
--- a/
src/surf/surf_timer.c
+++ b/
src/surf/surf_timer.c
@@
-8,10
+8,14
@@
#include "xbt/ex.h"
#include "surf_timer_private.h"
#include "xbt/ex.h"
#include "surf_timer_private.h"
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_timer, surf,
+ "Logging specific to SURF (timer)");
+
surf_timer_resource_t surf_timer_resource = NULL;
static tmgr_trace_t empty_trace = NULL;
static xbt_swag_t command_pending = NULL;
static xbt_swag_t command_to_run = NULL;
surf_timer_resource_t surf_timer_resource = NULL;
static tmgr_trace_t empty_trace = NULL;
static xbt_swag_t command_pending = NULL;
static xbt_swag_t command_to_run = NULL;
+static xbt_heap_t timer_heap = NULL;
static void timer_free(void *timer)
{
static void timer_free(void *timer)
{
@@
-93,11
+97,19
@@
static void action_change_state(surf_action_t action,
static double share_resources(double now)
{
static double share_resources(double now)
{
- return -1.0;
+ if (xbt_heap_size(timer_heap))
+ return (xbt_heap_maxkey(timer_heap));
+ else
+ return -1.0;
}
static void update_actions_state(double now, double delta)
{
}
static void update_actions_state(double now, double delta)
{
+ if(xbt_heap_size(timer_heap)) {
+ if(xbt_heap_maxkey(timer_heap)<=now+delta) {
+ xbt_heap_pop(timer_heap);
+ }
+ }
return;
}
return;
}
@@
-121,6
+133,7
@@
static void set(double date, void *function, void *arg)
command = command_new(function, arg);
tmgr_history_add_trace(history, empty_trace, date, 0, command);
command = command_new(function, arg);
tmgr_history_add_trace(history, empty_trace, date, 0, command);
+ xbt_heap_push(timer_heap, NULL , date);
}
}
@@
-156,6
+169,9
@@
static int action_is_suspended(surf_action_t action)
static void finalize(void)
{
static void finalize(void)
{
+ xbt_heap_free(timer_heap);
+ timer_heap = NULL;
+
tmgr_trace_free(empty_trace);
empty_trace = NULL;
tmgr_trace_free(empty_trace);
empty_trace = NULL;
@@
-232,6
+248,7
@@
static void surf_timer_resource_init_internal(void)
}
empty_trace = tmgr_empty_trace_new();
}
empty_trace = tmgr_empty_trace_new();
+ timer_heap = xbt_heap_new(8, NULL);
xbt_assert0(maxmin_system, "surf_init has to be called first!");
}
xbt_assert0(maxmin_system, "surf_init has to be called first!");
}