surf_network_model->suspend = surf_action_suspend;
surf_network_model->resume = surf_action_resume;
surf_network_model->is_suspended = surf_action_is_suspended;
+
+ xbt_assert(surf_cpu_model_pm);
+ xbt_assert(surf_cpu_model_vm);
surf_cpu_model_pm->set_max_duration = surf_action_set_max_duration;
surf_cpu_model_vm->set_max_duration = surf_action_set_max_duration;
surf_network_model->suspend = netcste_action_suspend;
surf_network_model->resume = netcste_action_resume;
surf_network_model->is_suspended = netcste_action_is_suspended;
+
+ xbt_assert(surf_cpu_model_pm);
+ xbt_assert(surf_cpu_model_vm);
surf_cpu_model_pm->set_max_duration = surf_action_set_max_duration;
surf_cpu_model_vm->set_max_duration = surf_action_set_max_duration;
/* this will call surf_resource_free() */
xbt_lib_unset(host_lib, name, SURF_WKS_LEVEL);
- xbt_free(vm_ws->ws.generic_resource.name);
- xbt_free(vm_ws);
+ /* NOTE: surf_resource_free() frees vm_ws->ws.generic_resource.name and
+ * vm_ws->ws. Do not free them here. */
}
static int vm_ws_get_state(void *ind_vm_ws){
}
-// TODO Please fix it (if found is wrong, nothing is returned)
static double get_solved_value(surf_action_t cpu_action)
{
int found = 0;
- lmm_system_t pm_system = surf_workstation_model->model_private->maxmin_system;
+ /* NOTE: Do not use surf_workstation_model's maxmin_system. It is not used. */
+ lmm_system_t pm_system = surf_cpu_model_pm->model_private->maxmin_system;
lmm_variable_t var = NULL;
xbt_swag_foreach(var, &pm_system->variable_set) {
return var->value;
XBT_CRITICAL("bug: cannot found the solved variable of the action %p", cpu_action);
+ DIE_IMPOSSIBLE;
+ return -1; /* NOT REACHED */
}
/* 0. Make sure that we already calculated the resource share at the physical
* machine layer. */
{
- unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, surf_workstation_model);
- unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, surf_vm_workstation_model);
+ unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &surf_workstation_model);
+ unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, &surf_vm_workstation_model);
xbt_assert((index_of_pm_ws_model < index_of_vm_ws_model), "Cannot assume surf_workstation_model comes before");
-
+
/* Another option is that we call sub_ws->share_resource() here. The
* share_resource() function has no side-effect. We can call it here to
* ensure that. */
model->name = "Virtual Workstation";
model->type = SURF_MODEL_TYPE_VM_WORKSTATION;
+ xbt_assert(surf_cpu_model_vm);
model->extension.workstation.cpu_model = surf_cpu_model_vm;
model->extension.vm_workstation.create = vm_ws_create;
/* For VM support, we have a surf cpu model object for each workstation model
* object. The physical workstation model object has the cpu model object of
* the physical machine layer. */
+ xbt_assert(surf_cpu_model_pm);
model->extension.workstation.cpu_model = surf_cpu_model_pm;
model->extension.workstation.execute = ws_execute;
void surf_workstation_model_init_current_default(void)
{
-
- surf_workstation_model_init_internal();
-
xbt_cfg_setdefault_int(_sg_cfg_set, "network/crosstraffic", 1);
surf_cpu_model_init_Cas01();
surf_network_model_init_LegrandVelho();
+ /* surf_cpu_mode_pm and surf_network_model must be initialized in advance. */
+ xbt_assert(surf_cpu_model_pm);
+ xbt_assert(surf_network_model);
+ surf_workstation_model_init_internal();
+
xbt_dynar_push(model_list, &surf_workstation_model);
xbt_dynar_push(model_list_invoke, &surf_workstation_model);
sg_platf_host_add_cb(workstation_new);
void surf_workstation_model_init_compound()
{
-
xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
xbt_assert(surf_network_model, "No network model defined yet!");
+
surf_workstation_model_init_internal();
xbt_dynar_push(model_list, &surf_workstation_model);
xbt_dynar_push(model_list_invoke, &surf_workstation_model);
xbt_dynar_t storage;
} s_workstation_CLM03_t, *workstation_CLM03_t;
-void __init_ws(workstation_CLM03_t ws, const char *id, int level);
+void __init_workstation_CLM03(workstation_CLM03_t ws, const char *id);
int ws_resource_used(void *resource_id);
double ws_share_resources(surf_model_t workstation_model, double now);