From 439b21daa6b4ae15a9ae7d581e966aa4511fbd20 Mon Sep 17 00:00:00 2001 From: Takahiro Hirofuchi Date: Fri, 15 Feb 2013 12:51:53 +0100 Subject: [PATCH] refine code around model types and objects The model_type member of an action object is renamed model_obj. This change makes it clear that this member points to a surf model objet, not the type of a model. The model type member is added to a surf model object. This allows us to know what type a model object is and what extension field is accessible. --- src/include/surf/surf.h | 28 ++++++++++++- src/simix/smx_io.c | 2 +- src/simix/smx_network.c | 6 +-- src/simix/smx_new_api.c | 2 +- src/simix/smx_process.c | 2 +- src/simix/smx_synchro.c | 2 +- src/surf/cpu_cas01.c | 1 + src/surf/cpu_ti.c | 3 +- src/surf/network.c | 1 + src/surf/network_gtnets.c | 1 + src/surf/network_ns3.c | 1 + src/surf/new_model.c | 1 + src/surf/storage.c | 1 + src/surf/surf_action.c | 30 +++++++------- src/surf/vm_workstation.c | 1 + src/surf/workstation.c | 69 ++++++++++++++++---------------- src/surf/workstation_ptask_L07.c | 1 + testsuite/surf/surf_usage.c | 10 ++--- 18 files changed, 98 insertions(+), 64 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 41aa0274ee..51435bd032 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -107,7 +107,12 @@ typedef struct surf_action { * 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 @@ -289,6 +294,23 @@ typedef struct surf_vm_workstation_model_extension_public { 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 * @@ -299,7 +321,9 @@ typedef struct surf_model { 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); diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index f261620d80..dfb8554c20 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -356,7 +356,7 @@ void SIMIX_io_destroy(smx_action_t action) { 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); } diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 48c05f3029..2e4b1b14d1 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -337,17 +337,17 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t 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; } } diff --git a/src/simix/smx_new_api.c b/src/simix/smx_new_api.c index acafb0e3a9..5f7fcc6a3f 100644 --- a/src/simix/smx_new_api.c +++ b/src/simix/smx_new_api.c @@ -93,7 +93,7 @@ void SIMIX_new_api_destroy(smx_action_t action) { 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); } diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index ff48a3537e..a845ba2fd0 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -747,7 +747,7 @@ void SIMIX_process_sleep_destroy(smx_action_t 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); } diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.c index 414b927cfa..4a3d094f25 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.c @@ -70,7 +70,7 @@ void SIMIX_synchro_destroy(smx_action_t 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(); diff --git a/src/surf/cpu_cas01.c b/src/surf/cpu_cas01.c index bc48ba5af2..0a98541cc6 100644 --- a/src/surf/cpu_cas01.c +++ b/src/surf/cpu_cas01.c @@ -363,6 +363,7 @@ static void surf_cpu_model_init_internal(surf_model_t cpu_model) 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; diff --git a/src/surf/cpu_ti.c b/src/surf/cpu_ti.c index 3436e80e94..8849fd065b 100644 --- a/src/surf/cpu_ti.c +++ b/src/surf/cpu_ti.c @@ -691,7 +691,7 @@ static void cpu_ti_action_set_priority(surf_action_t action, 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, @@ -784,6 +784,7 @@ static void surf_cpu_ti_model_init_internal(surf_model_t cpu_model) 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; diff --git a/src/surf/network.c b/src/surf/network.c index aca670c660..23660190af 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -763,6 +763,7 @@ static void surf_network_model_init_internal(void) 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; diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index d557573c20..0de24aae76 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -410,6 +410,7 @@ static void surf_network_model_init_internal(void) 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; diff --git a/src/surf/network_ns3.c b/src/surf/network_ns3.c index dd48b107f9..8ec660dacd 100644 --- a/src/surf/network_ns3.c +++ b/src/surf/network_ns3.c @@ -342,6 +342,7 @@ void surf_network_model_init_NS3() 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; diff --git a/src/surf/new_model.c b/src/surf/new_model.c index 76ed586b8f..dce13e2b5a 100644 --- a/src/surf/new_model.c +++ b/src/surf/new_model.c @@ -148,6 +148,7 @@ static void surf_new_model_init_internal(void) 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; diff --git a/src/surf/storage.c b/src/surf/storage.c index 12f8c56b0f..ecfcccba50 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -495,6 +495,7 @@ static void surf_storage_model_init_internal(void) 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; diff --git a/src/surf/surf_action.c b/src/surf/surf_action.c index 59e775ff4b..0e582d2164 100644 --- a/src/surf/surf_action.c +++ b/src/surf/surf_action.c @@ -74,7 +74,7 @@ void *surf_action_new(size_t size, double cost, surf_model_t model, 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 @@ -91,7 +91,7 @@ void *surf_action_new(size_t size, double cost, surf_model_t model, 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; @@ -124,7 +124,7 @@ XBT_INLINE void surf_action_free(surf_action_t * action) 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); @@ -187,7 +187,7 @@ void surf_action_lmm_heap_remove(xbt_heap_t heap, surf_action_lmm_t action) 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); @@ -198,7 +198,7 @@ void surf_action_cancel(surf_action_t action) 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); @@ -221,7 +221,7 @@ int surf_action_unref(surf_action_t action) 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, @@ -236,7 +236,7 @@ void surf_action_suspend(surf_action_t action) 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, @@ -256,7 +256,7 @@ int surf_action_is_suspended(surf_action_t action) 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 @@ -266,7 +266,7 @@ void surf_action_set_max_duration(surf_action_t action, double duration) 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, @@ -291,7 +291,7 @@ void surf_action_set_category(surf_action_t action, 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) { @@ -316,7 +316,7 @@ void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) 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, @@ -360,7 +360,7 @@ void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) 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()); @@ -377,7 +377,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo 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, @@ -409,7 +409,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo } #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); @@ -446,7 +446,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo } } #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; diff --git a/src/surf/vm_workstation.c b/src/surf/vm_workstation.c index 826fe6df92..5ab57316ad 100644 --- a/src/surf/vm_workstation.c +++ b/src/surf/vm_workstation.c @@ -135,6 +135,7 @@ static void surf_vm_workstation_model_init_internal(void) 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; diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 24eadc7759..f627c89baa 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -52,13 +52,13 @@ static int ws_parallel_action_free(surf_action_t action) 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; @@ -67,11 +67,11 @@ static int ws_action_unref(surf_action_t action) 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; @@ -81,11 +81,11 @@ static void ws_action_cancel(surf_action_t action) 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; @@ -124,30 +124,30 @@ static surf_action_t ws_action_sleep(void *workstation, double duration) 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; } @@ -155,20 +155,20 @@ static int ws_action_is_suspended(surf_action_t action) 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; } @@ -176,10 +176,10 @@ static void ws_action_set_priority(surf_action_t action, double priority) #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; } @@ -188,7 +188,7 @@ static void ws_action_set_category(surf_action_t action, const char *category) #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; @@ -197,10 +197,10 @@ static int ws_get_latency_limited(surf_action_t action) 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; } @@ -389,6 +389,7 @@ static void surf_workstation_model_init_internal(void) // 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; diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 17a53b16d2..9c89c30544 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -856,6 +856,7 @@ static void ptask_model_init_internal(void) 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; diff --git a/testsuite/surf/surf_usage.c b/testsuite/surf/surf_usage.c index 37be59e375..851043d677 100644 --- a/testsuite/surf/surf_usage.c +++ b/testsuite/surf/surf_usage.c @@ -73,7 +73,7 @@ void test(char *platform) /* 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 */ @@ -103,25 +103,25 @@ void test(char *platform) 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) || -- 2.20.1