* and fluctuates until the task is completed */
void *data; /**< for your convenience */
int refcount;
- surf_model_t model_type;
+
+ /* The previous name was model_type. For VM support, we have to distinguish a
+ * model type and its model object. Thus, we use model_obj here. The type of
+ * a model object is available through a macro. */
+ surf_model_t model_obj; /**< the surf model object */
+
#ifdef HAVE_TRACING
char *category; /**< tracing category for categorized resource utilization monitoring */
#endif
void (*destroy) (void *ind_vm_workstation); // will be vm_ws_destroy(), which destroies the vm-workstation-specific data
} s_surf_model_extension_vm_workstation_t;
+/** \ingroup SURF_models
+ * \brief Model types
+ *
+ * The type of the model object. For example, we will have two model objects
+ * of the surf cpu model. One is for physical machines, and the other is for
+ * virtual machines.
+ *
+ */
+typedef enum {
+ SURF_MODEL_TYPE_CPU = 0,
+ SURF_MODEL_TYPE_NETWORK,
+ SURF_MODEL_TYPE_STORAGE,
+ SURF_MODEL_TYPE_WORKSTATION,
+ SURF_MODEL_TYPE_VM_WORKSTATION,
+ SURF_MODEL_TYPE_NEW_MODEL
+} e_surf_model_type_t;
+
/** \ingroup SURF_models
* \brief Model datatype
*
const char *name; /**< Name of this model */
s_surf_action_state_t states; /**< Any living action on this model */
- e_surf_action_state_t(*action_state_get) (surf_action_t action);
+ e_surf_model_type_t type; /**< See e_surf_model_type_t */
+
+ e_surf_action_state_t(*action_state_get) (surf_action_t action);
/**< Return the state of an action */
void (*action_state_set) (surf_action_t action,
e_surf_action_state_t state);
{
XBT_DEBUG("Destroy action %p", action);
if (action->io.surf_io)
- action->io.surf_io->model_type->action_unref(action->io.surf_io);
+ action->io.surf_io->model_obj->action_unref(action->io.surf_io);
xbt_mallocator_release(simix_global->action_mallocator, action);
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
action->latency_limited = SIMIX_comm_is_latency_bounded(action);
#endif
- action->comm.surf_comm->model_type->action_unref(action->comm.surf_comm);
+ action->comm.surf_comm->model_obj->action_unref(action->comm.surf_comm);
action->comm.surf_comm = NULL;
}
if (action->comm.src_timeout){
- action->comm.src_timeout->model_type->action_unref(action->comm.src_timeout);
+ action->comm.src_timeout->model_obj->action_unref(action->comm.src_timeout);
action->comm.src_timeout = NULL;
}
if (action->comm.dst_timeout){
- action->comm.dst_timeout->model_type->action_unref(action->comm.dst_timeout);
+ action->comm.dst_timeout->model_obj->action_unref(action->comm.dst_timeout);
action->comm.dst_timeout = NULL;
}
}
{
XBT_DEBUG("Destroy action %p", action);
if (action->new_api.surf_new_api)
- action->new_api.surf_new_api->model_type->action_unref(action->new_api.surf_new_api);
+ action->new_api.surf_new_api->model_obj->action_unref(action->new_api.surf_new_api);
xbt_mallocator_release(simix_global->action_mallocator, action);
}
{
XBT_DEBUG("Destroy action %p", action);
if (action->sleep.surf_sleep)
- action->sleep.surf_sleep->model_type->action_unref(action->sleep.surf_sleep);
+ action->sleep.surf_sleep->model_obj->action_unref(action->sleep.surf_sleep);
xbt_mallocator_release(simix_global->action_mallocator, action);
}
{
XBT_IN("(%p)",action);
XBT_DEBUG("Destroying synchro %p", action);
- action->synchro.sleep->model_type->action_unref(action->synchro.sleep);
+ action->synchro.sleep->model_obj->action_unref(action->synchro.sleep);
xbt_free(action->name);
xbt_mallocator_release(simix_global->action_mallocator, action);
XBT_OUT();
xbt_swag_new(xbt_swag_offset(action, state_hookup));
cpu_model->name = "cpu";
+ cpu_model->type = SURF_MODEL_TYPE_CPU;
cpu_model->action_unref = surf_action_unref;
cpu_model->action_cancel = surf_action_cancel;
static double cpu_ti_action_get_remains(surf_action_t action)
{
- surf_model_t cpu_model = action->model_type;
+ surf_model_t cpu_model = action->model_obj;
XBT_IN("(%p)", action);
cpu_ti_update_remaining_amount(cpu_model, (cpu_ti_t) ((surf_action_cpu_ti_t) action)->cpu,
xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
cpu_model->name = "cpu_ti";
+ cpu_model->type = SURF_MODEL_TYPE_CPU;
cpu_model->action_unref = cpu_ti_action_unref;
cpu_model->action_cancel = cpu_ti_action_cancel;
set_update_mechanism();
surf_network_model->name = "network";
+ surf_network_model->type = SURF_MODEL_TYPE_NETWORK;
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 = surf_model_init();
surf_network_model->name = "network GTNetS";
+ surf_network_model->type = SURF_MODEL_TYPE_NETWORK;
surf_network_model->action_unref = action_unref;
surf_network_model->action_cancel = action_cancel;
surf_network_model->action_recycle = action_recycle;
surf_network_model = surf_model_init();
surf_network_model->name = "network NS3";
+ surf_network_model->type = SURF_MODEL_TYPE_NETWORK;
surf_network_model->extension.network.get_link_latency = ns3_get_link_latency;
surf_network_model->extension.network.get_link_bandwidth = ns3_get_link_bandwidth;
surf_network_model->extension.network.get_route = ns3_get_route;
xbt_swag_new(xbt_swag_offset(action, state_hookup));
surf_new_model->name = "New Model";
+ surf_new_model->type = SURF_MODEL_TYPE_NEW_MODEL;
surf_new_model->action_unref = new_model_action_unref;
surf_new_model->action_cancel = new_model_action_cancel;
surf_new_model->action_state_set = new_model_action_state_set;
xbt_swag_new(xbt_swag_offset(action, state_hookup));
surf_storage_model->name = "Storage";
+ surf_storage_model->type = SURF_MODEL_TYPE_STORAGE;
surf_storage_model->action_unref = storage_action_unref;
surf_storage_model->action_cancel = storage_action_cancel;
surf_storage_model->action_state_set = storage_action_state_set;
action->max_duration = NO_MAX_DURATION;
action->start = surf_get_clock();
action->finish = -1.0;
- action->model_type = model;
+ action->model_obj = model;
#ifdef HAVE_TRACING
action->category = NULL;
#endif
e_surf_action_state_t surf_action_state_get(surf_action_t action)
{
- surf_action_state_t action_state = &(action->model_type->states);
+ surf_action_state_t action_state = &(action->model_obj->states);
if (action->state_set == action_state->ready_action_set)
return SURF_ACTION_READY;
void surf_action_state_set(surf_action_t action,
e_surf_action_state_t state)
{
- surf_action_state_t action_state = &(action->model_type->states);
+ surf_action_state_t action_state = &(action->model_obj->states);
XBT_IN("(%p,%s)", action, surf_action_state_names[state]);
xbt_swag_remove(action, action->state_set);
void surf_action_cancel(surf_action_t action)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
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);
int surf_action_unref(surf_action_t action)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
action->refcount--;
if (!action->refcount) {
xbt_swag_remove(action, action->state_set);
void surf_action_suspend(surf_action_t action)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
XBT_IN("(%p)", action);
if (((surf_action_lmm_t) action)->suspended != 2) {
lmm_update_variable_weight(model->model_private->maxmin_system,
void surf_action_resume(surf_action_t action)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
XBT_IN("(%p)", action);
if (((surf_action_lmm_t) action)->suspended != 2) {
lmm_update_variable_weight(model->model_private->maxmin_system,
void surf_action_set_max_duration(surf_action_t action, double duration)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
XBT_IN("(%p,%g)", action, duration);
action->max_duration = duration;
if (model->model_private->update_mechanism == UM_LAZY) // remove action from the heap
void surf_action_set_priority(surf_action_t action, double priority)
{
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
XBT_IN("(%p,%g)", action, priority);
action->priority = priority;
lmm_update_variable_weight(model->model_private->maxmin_system,
void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now)
{
double delta = 0.0;
- surf_model_t model = action->generic_action.model_type;
+ surf_model_t model = action->generic_action.model_obj;
if(model == surf_network_model)
{
action->last_value * delta);
#ifdef HAVE_TRACING
- if (model == surf_cpu_model && TRACE_is_enabled()) {
+ if (model->type == SURF_MODEL_TYPE_CPU && TRACE_is_enabled()) {
surf_resource_t cpu =
lmm_constraint_id(lmm_get_cnst_from_var
(model->model_private->maxmin_system,
double surf_action_get_remains(surf_action_t action)
{
XBT_IN("(%p)", action);
- surf_model_t model = action->model_type;
+ surf_model_t model = action->model_obj;
/* update remains before return it */
if (model->model_private->update_mechanism == UM_LAZY) /* update remains before return it */
generic_update_action_remaining_lazy((surf_action_lmm_t)action, surf_get_clock());
XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
- if(model == surf_cpu_model){
+ if(model->type == SURF_MODEL_TYPE_CPU){
surf_resource_t cpu =
lmm_constraint_id(lmm_get_cnst_from_var
(model->model_private->maxmin_system,
}
#endif
- if(model == surf_cpu_model){
+ if(model->type == SURF_MODEL_TYPE_CPU){
action->generic_action.finish = surf_get_clock();
XBT_DEBUG("Action %p finished", action);
}
}
#ifdef HAVE_TRACING
- if (TRACE_is_enabled() && model == surf_cpu_model) {
+ if (TRACE_is_enabled() && model->type == SURF_MODEL_TYPE_CPU) {
//defining the last timestamp that we can safely dump to trace file
//without losing the event ascending order (considering all CPU's)
double smaller = -1;
surf_vm_workstation_model = surf_model_init();
surf_vm_workstation_model->name = "Virtual Workstation";
+ surf_vm_workstation_model->type = SURF_MODEL_TYPE_VM_WORKSTATION;
surf_vm_workstation_model->extension.vm_workstation.create = vm_ws_create;
surf_vm_workstation_model->extension.vm_workstation.set_state = vm_ws_set_state;
static int ws_action_unref(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
return surf_network_model->action_unref(action);
- else if (action->model_type == surf_cpu_model)
- return action->model_type->action_unref(action);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ return action->model_obj->action_unref(action);
// previously was: Adrien/Arnaud 6 feb
// surf_cpu_model->action_unref(action);
- else if (action->model_type == surf_workstation_model)
+ else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
return ws_parallel_action_free(action);
else
DIE_IMPOSSIBLE;
static void ws_action_cancel(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->action_cancel(action);
- else if (action->model_type == surf_cpu_model)
- action->model_type->action_cancel(action);
- else if (action->model_type == surf_workstation_model)
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->action_cancel(action);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
ws_parallel_action_cancel(action);
else
DIE_IMPOSSIBLE;
static void ws_action_state_set(surf_action_t action,
e_surf_action_state_t state)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->action_state_set(action, state);
- else if (action->model_type == surf_cpu_model)
- action->model_type->action_state_set(action, state);
- else if (action->model_type == surf_workstation_model)
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->action_state_set(action, state);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
surf_action_state_set(action, state);
else
DIE_IMPOSSIBLE;
static void ws_action_suspend(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->suspend(action);
- else if (action->model_type == surf_cpu_model)
- action->model_type->suspend(action);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->suspend(action);
else
DIE_IMPOSSIBLE;
}
static void ws_action_resume(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->resume(action);
- else if (action->model_type == surf_cpu_model)
- action->model_type->resume(action);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->resume(action);
else
DIE_IMPOSSIBLE;
}
static int ws_action_is_suspended(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
return surf_network_model->is_suspended(action);
- if (action->model_type == surf_cpu_model)
- return action->model_type->is_suspended(action);
+ if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ return action->model_obj->is_suspended(action);
DIE_IMPOSSIBLE;
return -1;
}
static void ws_action_set_max_duration(surf_action_t action,
double duration)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->set_max_duration(action, duration);
- else if (action->model_type == surf_cpu_model)
- action->model_type->set_max_duration(action, duration);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->set_max_duration(action, duration);
else
DIE_IMPOSSIBLE;
}
static void ws_action_set_priority(surf_action_t action, double priority)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->set_priority(action, priority);
- else if (action->model_type == surf_cpu_model)
- action->model_type->set_priority(action, priority);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->set_priority(action, priority);
else
DIE_IMPOSSIBLE;
}
#ifdef HAVE_TRACING
static void ws_action_set_category(surf_action_t action, const char *category)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
surf_network_model->set_category(action, category);
- else if (action->model_type == surf_cpu_model)
- action->model_type->set_category(action, category);
+ else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ action->model_obj->set_category(action, category);
else
DIE_IMPOSSIBLE;
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
static int ws_get_latency_limited(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
return surf_network_model->get_latency_limited(action);
else
return 0;
static double ws_action_get_remains(surf_action_t action)
{
- if (action->model_type == surf_network_model)
+ if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
return surf_network_model->get_remains(action);
- if (action->model_type == surf_cpu_model)
- return action->model_type->get_remains(action);
+ if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
+ return action->model_obj->get_remains(action);
DIE_IMPOSSIBLE;
return -1.0;
}
// TODO surf_workstation_model->extension.cpu=cpu_model_cas01(0);
surf_workstation_model->name = "Workstation";
+ surf_workstation_model->type = SURF_MODEL_TYPE_WORKSTATION;
surf_workstation_model->action_unref = ws_action_unref;
surf_workstation_model->action_cancel = ws_action_cancel;
surf_workstation_model->action_state_set = ws_action_state_set;
surf_workstation_model->set_priority = ptask_action_set_priority;
surf_workstation_model->get_remains = ptask_action_get_remains;
surf_workstation_model->name = "Workstation ptask_L07";
+ surf_workstation_model->type = SURF_MODEL_TYPE_WORKSTATION;
surf_workstation_model->model_private->resource_used =
ptask_resource_used;
/* Use whatever calling style you want... */
stateActionA = surf_cpu_model_pm->action_state_get(actionA); /* When you know actionA model type */
- stateActionB = actionB->model_type->action_state_get(actionB); /* If you're unsure about it's model type */
+ stateActionB = actionB->model_obj->action_state_get(actionB); /* If you're unsure about it's model type */
stateActionC = surf_cpu_model_pm->action_state_get(actionC); /* When you know actionA model type */
/* And just look at the state of these tasks */
while ((action =
xbt_swag_extract(surf_cpu_model_pm->states.failed_action_set))) {
XBT_DEBUG("\t * Failed : %p", action);
- action->model_type->action_unref(action);
+ action->model_obj->action_unref(action);
}
while ((action =
xbt_swag_extract(surf_cpu_model_pm->states.done_action_set))) {
XBT_DEBUG("\t * Done : %p", action);
- action->model_type->action_unref(action);
+ action->model_obj->action_unref(action);
}
XBT_DEBUG("\t Network actions");
while ((action =
xbt_swag_extract(surf_network_model->states.
failed_action_set))) {
XBT_DEBUG("\t * Failed : %p", action);
- action->model_type->action_unref(action);
+ action->model_obj->action_unref(action);
}
while ((action =
xbt_swag_extract(surf_network_model->states.
done_action_set))) {
XBT_DEBUG("\t * Done : %p", action);
- action->model_type->action_unref(action);
+ action->model_obj->action_unref(action);
}
} while ((xbt_swag_size(surf_network_model->states.running_action_set) ||