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
tracing option to trace uncategorized resource utilization
[simgrid.git]
/
src
/
surf
/
surf_model_timer.c
diff --git
a/src/surf/surf_model_timer.c
b/src/surf/surf_model_timer.c
index
c5762ce
..
4cf18e1
100644
(file)
--- a/
src/surf/surf_model_timer.c
+++ b/
src/surf/surf_model_timer.c
@@
-1,6
+1,5
@@
-/* $Id$ */
-
-/* Copyright (c) 2005 Arnaud Legrand. All rights reserved. */
+/* Copyright (c) 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
@@
-12,11
+11,16
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_timer, surf,
"Logging specific to SURF (timer)");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_timer, surf,
"Logging specific to SURF (timer)");
+typedef struct surf_action_timer {
+ s_surf_action_t generic_action;
+} s_surf_action_timer_t, *surf_action_timer_t;
+
typedef struct command {
typedef struct command {
- s_surf_resource_t generic_resource; /* Must remain first, since we add this to a trace */
+ s_surf_resource_t generic_resource;
/* Must remain first, since we add this to a trace */
void *function;
void *args;
s_xbt_swag_hookup_t command_set_hookup;
void *function;
void *args;
s_xbt_swag_hookup_t command_set_hookup;
+ surf_action_timer_t action;
} s_command_t, *command_t;
} s_command_t, *command_t;
@@
-34,6
+38,9
@@
static command_t command_new(void *fun, void *args)
command->function = fun;
command->args = args;
xbt_swag_insert(command, command_pending);
command->function = fun;
command->args = args;
xbt_swag_insert(command, command_pending);
+ command->action =
+ surf_action_new(sizeof(s_surf_action_timer_t), 0, surf_timer_model,
+ 0);
return command;
}
return command;
}
@@
-44,7
+51,10
@@
static void command_free(command_t command)
} else if (xbt_swag_belongs(command, command_pending)) {
xbt_swag_remove(command, command_pending);
}
} else if (xbt_swag_belongs(command, command_pending)) {
xbt_swag_remove(command, command_pending);
}
- surf_resource_free((surf_resource_t)command);
+ xbt_swag_remove(command->action,
+ surf_timer_model->states.running_action_set);
+ xbt_free(command->action);
+ surf_resource_free((surf_resource_t) command);
return;
}
return;
}
@@
-62,7
+72,7
@@
static int resource_used(void *resource_id)
}
static void timer_action_state_set(surf_action_t action,
}
static void timer_action_state_set(surf_action_t action,
- e_surf_action_state_t state)
+
e_surf_action_state_t state)
{
DIE_IMPOSSIBLE;
return;
{
DIE_IMPOSSIBLE;
return;
@@
-70,19
+80,18
@@
static void timer_action_state_set(surf_action_t action,
static double share_resources(double now)
{
static double share_resources(double now)
{
- if (xbt_heap_size(timer_heap))
+ if (xbt_heap_size(timer_heap)) {
+ DEBUG1("Share resoure returning %lf", xbt_heap_maxkey(timer_heap));
return (xbt_heap_maxkey(timer_heap));
return (xbt_heap_maxkey(timer_heap));
- else
+
}
else
return -1.0;
}
static void update_actions_state(double now, double delta)
{
return -1.0;
}
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);
- }
- }
+ while ((xbt_heap_size(timer_heap)) > 0
+ && (xbt_heap_maxkey(timer_heap) <= now + delta))
+ xbt_heap_pop(timer_heap);
return;
}
return;
}
@@
-95,6
+104,9
@@
static void update_resource_state(void *id,
/* Move this command to the list of commands to execute */
xbt_swag_remove(command, command_pending);
xbt_swag_insert(command, command_to_run);
/* Move this command to the list of commands to execute */
xbt_swag_remove(command, command_pending);
xbt_swag_insert(command, command_to_run);
+ tmgr_trace_event_free(event_type);
+
+ DEBUG1("Insert command on date %lf", date);
return;
}
return;
}
@@
-107,6
+119,8
@@
static void set(double date, void *function, void *arg)
tmgr_history_add_trace(history, empty_trace, date, 0, command);
xbt_heap_push(timer_heap, NULL, date);
tmgr_history_add_trace(history, empty_trace, date, 0, command);
xbt_heap_push(timer_heap, NULL, date);
+
+ DEBUG1("Putting value %lf on heap", date);
}
}
@@
-118,6
+132,7
@@
static int get(void **function, void **arg)
if (command) {
*function = command->function;
*arg = command->args;
if (command) {
*function = command->function;
*arg = command->args;
+ command_free(command);
return 1;
} else {
return 0;
return 1;
} else {
return 0;
@@
-140,7
+155,7
@@
static int action_is_suspended(surf_action_t action)
return 0;
}
return 0;
}
-static void finalize(void)
+static void
timer_
finalize(void)
{
xbt_heap_free(timer_heap);
timer_heap = NULL;
{
xbt_heap_free(timer_heap);
timer_heap = NULL;
@@
-165,10
+180,10
@@
static void surf_timer_model_init_internal(void)
surf_timer_model->model_private->resource_used = resource_used;
surf_timer_model->model_private->share_resources = share_resources;
surf_timer_model->model_private->update_actions_state =
surf_timer_model->model_private->resource_used = resource_used;
surf_timer_model->model_private->share_resources = share_resources;
surf_timer_model->model_private->update_actions_state =
- update_actions_state;
+
update_actions_state;
surf_timer_model->model_private->update_resource_state =
surf_timer_model->model_private->update_resource_state =
- update_resource_state;
- surf_timer_model->model_private->finalize = finalize;
+
update_resource_state;
+ surf_timer_model->model_private->finalize =
timer_
finalize;
surf_timer_model->suspend = action_suspend;
surf_timer_model->resume = action_resume;
surf_timer_model->suspend = action_suspend;
surf_timer_model->resume = action_resume;
@@
-179,8
+194,10
@@
static void surf_timer_model_init_internal(void)
{
s_command_t var;
{
s_command_t var;
- command_pending = xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
- command_to_run = xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
+ command_pending =
+ xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
+ command_to_run =
+ xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
}
empty_trace = tmgr_empty_trace_new();
}
empty_trace = tmgr_empty_trace_new();