/** @Brief Specify that we use that action */
XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
+
/** @brief Creates a new action.
*
* @param size The size is the one of the subtype you want to create
((cpu_Cas01_t) resource)->constraint);
}
-static int cpu_action_unref(surf_action_t action)
-{
- action->refcount--;
- if (!action->refcount) {
- xbt_swag_remove(action, action->state_set);
- if (((surf_action_lmm_t) action)->variable)
- lmm_variable_free(surf_cpu_model->model_private->maxmin_system,
- ((surf_action_lmm_t) action)->variable);
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
- /* remove from heap */
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- xbt_swag_remove(action, surf_cpu_model->model_private->modified_set);
- }
-#ifdef HAVE_TRACING
- xbt_free(action->category);
-#endif
- surf_action_free(&action);
- return 1;
- }
- return 0;
-}
-
-static void cpu_action_cancel(surf_action_t action)
-{
- surf_action_state_set(action, SURF_ACTION_FAILED);
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
- xbt_swag_remove(action, surf_cpu_model->model_private->modified_set);
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- }
- return;
-}
-
-static void cpu_action_state_set(surf_action_t action,
- e_surf_action_state_t state)
-{
-/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
-/* if(((surf_action_lmm_t)action)->variable) { */
-/* lmm_variable_disable(surf_cpu_model->maxmin_system, ((surf_action_lmm_t)action)->variable); */
-/* ((surf_action_lmm_t)action)->variable = NULL; */
-/* } */
-
- surf_action_state_set(action, state);
- return;
-}
-
static void cpu_update_action_remaining_lazy(surf_action_cpu_Cas01_t action, double now)
{
double delta = 0.0;
#endif
/* set the remains to 0 due to precision problems when updating the remaining amount */
GENERIC_ACTION(action).remains = 0;
- cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+ surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action); //FIXME: strange call since action was already popped
}
#ifdef HAVE_TRACING
(lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) >
0)) {
GENERIC_ACTION(action).finish = surf_get_clock();
- cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+ surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
} else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
(GENERIC_ACTION(action).max_duration <= 0)) {
GENERIC_ACTION(action).finish = surf_get_clock();
- cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+ surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
}
}
surf_action_state_get(action) ==
SURF_ACTION_NOT_IN_THE_SYSTEM) {
action->finish = date;
- cpu_action_state_set(action, SURF_ACTION_FAILED);
+ surf_action_state_set(action, SURF_ACTION_FAILED);
}
}
}
return (surf_action_t) action;
}
-static void cpu_action_suspend(surf_action_t action)
-{
- XBT_IN("(%p)", action);
- if (((surf_action_lmm_t) action)->suspended != 2) {
- lmm_update_variable_weight(surf_cpu_model->model_private->maxmin_system,
- ((surf_action_lmm_t) action)->variable,
- 0.0);
- ((surf_action_lmm_t) action)->suspended = 1;
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY)
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- }
- XBT_OUT();
-}
-
-static void cpu_action_resume(surf_action_t action)
-{
-
- XBT_IN("(%p)", action);
- if (((surf_action_lmm_t) action)->suspended != 2) {
- lmm_update_variable_weight(surf_cpu_model->model_private->maxmin_system,
- ((surf_action_lmm_t) action)->variable,
- action->priority);
- ((surf_action_lmm_t) action)->suspended = 0;
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY)
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- }
- XBT_OUT();
-}
-
-static int cpu_action_is_suspended(surf_action_t action)
-{
- return (((surf_action_lmm_t) action)->suspended == 1);
-}
-
-static void cpu_action_set_max_duration(surf_action_t action,
- double duration)
-{
- XBT_IN("(%p,%g)", action, duration);
-
- action->max_duration = duration;
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY)
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- XBT_OUT();
-}
-
-static void cpu_action_set_priority(surf_action_t action, double priority)
-{
- XBT_IN("(%p,%g)", action, priority);
- action->priority = priority;
- lmm_update_variable_weight(surf_cpu_model->model_private->maxmin_system,
- ((surf_action_lmm_t) action)->variable,
- priority);
-
- if (surf_cpu_model->model_private->update_mechanism == UM_LAZY)
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
- XBT_OUT();
-}
-
-#ifdef HAVE_TRACING
-static void cpu_action_set_category(surf_action_t action,
- const char *category)
-{
- XBT_IN("(%p,%s)", action, category);
- action->category = xbt_strdup(category);
- XBT_OUT();
-}
-#endif
-
static double cpu_action_get_remains(surf_action_t action)
{
XBT_IN("(%p)", action);
surf_cpu_model->name = "cpu";
- surf_cpu_model->action_unref = cpu_action_unref;
- surf_cpu_model->action_cancel = cpu_action_cancel;
- surf_cpu_model->action_state_set = cpu_action_state_set;
+ surf_cpu_model->action_unref = surf_action_unref;
+ surf_cpu_model->action_cancel = surf_action_cancel;
+ surf_cpu_model->action_state_set = surf_action_state_set;
surf_cpu_model->model_private->resource_used = cpu_resource_used;
cpu_update_resource_state;
surf_cpu_model->model_private->finalize = cpu_finalize;
- surf_cpu_model->suspend = cpu_action_suspend;
- surf_cpu_model->resume = cpu_action_resume;
- surf_cpu_model->is_suspended = cpu_action_is_suspended;
- surf_cpu_model->set_max_duration = cpu_action_set_max_duration;
- surf_cpu_model->set_priority = cpu_action_set_priority;
+ surf_cpu_model->suspend = surf_action_suspend;
+ surf_cpu_model->resume = surf_action_resume;
+ surf_cpu_model->is_suspended = surf_action_is_suspended;
+ surf_cpu_model->set_max_duration = surf_action_set_max_duration;
+ surf_cpu_model->set_priority = surf_action_set_priority;
#ifdef HAVE_TRACING
- surf_cpu_model->set_category = cpu_action_set_category;
+ surf_cpu_model->set_category = surf_action_set_category;
#endif
surf_cpu_model->get_remains = cpu_action_get_remains;
xbt_dict_t gap_lookup = NULL;
-static int net_action_is_suspended(surf_action_t action);
static void net_update_action_remaining_lazy(surf_action_network_CM02_t action, double now);
/******************************************************************************/
constraint);
}
-static int net_action_unref(surf_action_t action)
-{
- action->refcount--;
- if (!action->refcount) {
- xbt_swag_remove(action, action->state_set);
- if (((surf_action_lmm_t)action)->variable) {
- lmm_variable_free(surf_network_model->model_private->maxmin_system,
- ((surf_action_lmm_t) action)->variable);
- }
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) { // remove action from the heap
- surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t) action);
- xbt_swag_remove(action, surf_network_model->model_private->modified_set);
- }
-#ifdef HAVE_TRACING
- if (action->category) xbt_free (action->category);
-#endif
- surf_action_free(&action);
- return 1;
- }
- return 0;
-}
-
-
-
-static void net_action_cancel(surf_action_t action)
-{
- XBT_DEBUG("cancel action %p", action);
- surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) { // remove action from the heap
- xbt_swag_remove(action, surf_network_model->model_private->modified_set);
- surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t) action);
- }
-}
-
void net_action_recycle(surf_action_t action)
{
return;
lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
}
-static void net_action_suspend(surf_action_t action)
-{
- ((surf_action_network_CM02_t) action)->generic_lmm_action.suspended = 1;
- lmm_update_variable_weight(surf_network_model->model_private->maxmin_system,
- ((surf_action_network_CM02_t)
- action)->generic_lmm_action.variable, 0.0);
-
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) // remove action from the heap
- surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-}
-
-static void net_action_resume(surf_action_t action)
-{
- if (((surf_action_network_CM02_t) action)->generic_lmm_action.suspended) {
- lmm_update_variable_weight(surf_network_model->model_private->maxmin_system,
- ((surf_action_network_CM02_t)
- action)->generic_lmm_action.variable,
- ((surf_action_network_CM02_t)
- action)->weight);
- ((surf_action_network_CM02_t) action)->generic_lmm_action.suspended = 0;
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) // remove action from the heap
- surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
- }
-}
-
-static int net_action_is_suspended(surf_action_t action)
-{
- return ((surf_action_network_CM02_t) action)->generic_lmm_action.suspended;
-}
-
-void net_action_set_max_duration(surf_action_t action, double duration)
-{
- action->max_duration = duration;
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) // remove action from the heap
- surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-}
-
-#ifdef HAVE_TRACING
-static void net_action_set_category(surf_action_t action,
- const char *category)
-{
- action->category = xbt_strdup(category);
-}
-#endif
-
static void net_finalize(void)
{
lmm_system_free(surf_network_model->model_private->maxmin_system);
set_update_mechanism();
surf_network_model->name = "network";
- surf_network_model->action_unref = net_action_unref;
- surf_network_model->action_cancel = net_action_cancel;
+ surf_network_model->action_unref = surf_action_unref;
+ surf_network_model->action_cancel = surf_action_cancel;
surf_network_model->action_recycle = net_action_recycle;
+
surf_network_model->get_remains = net_action_get_remains;
+
#ifdef HAVE_LATENCY_BOUND_TRACKING
surf_network_model->get_latency_limited = net_get_link_latency_limited;
#endif
#ifdef HAVE_TRACING
- surf_network_model->set_category = net_action_set_category;
+ surf_network_model->set_category = surf_action_set_category;
#endif
surf_network_model->model_private->resource_used = net_resource_used;
net_update_resource_state;
surf_network_model->model_private->finalize = net_finalize;
- surf_network_model->suspend = net_action_suspend;
- surf_network_model->resume = net_action_resume;
- surf_network_model->is_suspended = net_action_is_suspended;
- surf_cpu_model->set_max_duration = net_action_set_max_duration;
+ surf_network_model->suspend = surf_action_suspend;
+ surf_network_model->resume = surf_action_resume;
+ surf_network_model->is_suspended = surf_action_is_suspended;
+ surf_cpu_model->set_max_duration = surf_action_set_max_duration;
surf_network_model->extension.network.communicate = net_communicate;
surf_network_model->extension.network.get_route = net_get_route;
surf_network_model->suspend = netcste_action_suspend;
surf_network_model->resume = netcste_action_resume;
surf_network_model->is_suspended = netcste_action_is_suspended;
- surf_cpu_model->set_max_duration = net_action_set_max_duration;
+ surf_cpu_model->set_max_duration = surf_action_set_max_duration;
surf_network_model->extension.network.communicate = netcste_communicate;
surf_network_model->extension.network.get_link_bandwidth =
return min;
}
+void generic_update_action_remaining_lazy( surf_action_t action, double now)
+{
+ // TODO merge for cpu and net
+}
+
static XBT_INLINE void routing_asr_host_free(void *p)
{
sg_routing_edge_t elm = p;
xbt_heap_remove(heap, action->index_heap);
}
}
+
+void surf_action_cancel(surf_action_t action)
+{
+ surf_model_t model = action->model_type;
+ surf_action_state_set(action, SURF_ACTION_FAILED);
+ if (model->model_private->update_mechanism == UM_LAZY) {
+ xbt_swag_remove(action, model->model_private->modified_set);
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ }
+ return;
+}
+
+int surf_action_unref(surf_action_t action)
+{
+ surf_model_t model = action->model_type;
+ action->refcount--;
+ if (!action->refcount) {
+ xbt_swag_remove(action, action->state_set);
+ if (((surf_action_lmm_t) action)->variable)
+ lmm_variable_free(model->model_private->maxmin_system,
+ ((surf_action_lmm_t) action)->variable);
+ if (model->model_private->update_mechanism == UM_LAZY) {
+ /* remove from heap */
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ xbt_swag_remove(action, model->model_private->modified_set);
+ }
+#ifdef HAVE_TRACING
+ xbt_free(action->category);
+#endif
+ surf_action_free(&action);
+ return 1;
+ }
+ return 0;
+}
+
+void surf_action_suspend(surf_action_t action)
+{
+ surf_model_t model = action->model_type;
+ XBT_IN("(%p)", action);
+ if (((surf_action_lmm_t) action)->suspended != 2) {
+ lmm_update_variable_weight(model->model_private->maxmin_system,
+ ((surf_action_lmm_t) action)->variable,
+ 0.0);
+ ((surf_action_lmm_t) action)->suspended = 1;
+ if (model->model_private->update_mechanism == UM_LAZY)
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ }
+ XBT_OUT();
+}
+
+void surf_action_resume(surf_action_t action)
+{
+ surf_model_t model = action->model_type;
+ XBT_IN("(%p)", action);
+ if (((surf_action_lmm_t) action)->suspended != 2) {
+ lmm_update_variable_weight(model->model_private->maxmin_system,
+ ((surf_action_lmm_t) action)->variable,
+ action->priority);
+ ((surf_action_lmm_t) action)->suspended = 0;
+ if (model->model_private->update_mechanism == UM_LAZY)
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ }
+ XBT_OUT();
+}
+
+int surf_action_is_suspended(surf_action_t action)
+{
+ return (((surf_action_lmm_t) action)->suspended == 1);
+}
+
+void surf_action_set_max_duration(surf_action_t action, double duration)
+{
+ surf_model_t model = action->model_type;
+ XBT_IN("(%p,%g)", action, duration);
+ action->max_duration = duration;
+ if (model->model_private->update_mechanism == UM_LAZY) // remove action from the heap
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ XBT_OUT();
+}
+
+void surf_action_set_priority(surf_action_t action, double priority)
+{
+ surf_model_t model = action->model_type;
+ XBT_IN("(%p,%g)", action, priority);
+ action->priority = priority;
+ lmm_update_variable_weight(model->model_private->maxmin_system,
+ ((surf_action_lmm_t) action)->variable,
+ priority);
+
+ if (model->model_private->update_mechanism == UM_LAZY)
+ surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+ XBT_OUT();
+}
+
+#ifdef HAVE_TRACING
+void surf_action_set_category(surf_action_t action,
+ const char *category)
+{
+ XBT_IN("(%p,%s)", action, category);
+ action->category = xbt_strdup(category);
+ XBT_OUT();
+}
+#endif
+
+double surf_action_get_remains(surf_action_t action)
+{
+ XBT_IN("(%p)", action);
+ surf_model_t model = action->model_type;
+ /* update remains before return it */
+ if (model->model_private->update_mechanism == UM_LAZY) /* update remains before return it */
+ generic_update_action_remaining_lazy(action, surf_get_clock());
+ XBT_OUT();
+ return action->remains;
+}
size_t offset,
lmm_system_t sys,
void (*solve) (lmm_system_t));
+void generic_update_action_remaining_lazy( surf_action_t action, double now);
/* Generic functions common to all models */
void surf_action_init(void);
double key, enum heap_action_type hat);
void surf_action_lmm_heap_remove(xbt_heap_t heap,surf_action_lmm_t action);
+void surf_action_cancel(surf_action_t action);
+int surf_action_unref(surf_action_t action);
+void surf_action_suspend(surf_action_t action);
+void surf_action_resume(surf_action_t action);
+int surf_action_is_suspended(surf_action_t action);
+void surf_action_set_max_duration(surf_action_t action, double duration);
+void surf_action_set_priority(surf_action_t action, double priority);
+#ifdef HAVE_TRACING
+void surf_action_set_category(surf_action_t action,
+ const char *category);
+#endif
+double surf_action_get_remains(surf_action_t action);
FILE *surf_fopen(const char *name, const char *mode);
#ifdef HAVE_LATENCY_BOUND_TRACKING
int net_get_link_latency_limited(surf_action_t action);
#endif
-void net_action_set_max_duration(surf_action_t action, double duration);
+
/*
* Returns the initial path. On Windows the initial path is
* the current directory for the current process in the other