Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Extend simcall_host_execute() for CPU affinity
[simgrid.git] / src / surf / vm_workstation.c
index 2310a77..da37c53 100644 (file)
@@ -194,6 +194,17 @@ static void vm_ws_destroy(void *ind_vm_workstation)
    * free other objects than lmm_constraint. */
   surf_model_t cpu_model = cpu->generic_resource.model;
   lmm_constraint_free(cpu_model->model_private->maxmin_system, cpu->constraint);
+  {
+    unsigned long i;
+    for (i = 0; i < cpu->core; i++) {
+      void *cnst_id = cpu->constraint_core[i]->id;
+      lmm_constraint_free(cpu_model->model_private->maxmin_system, cpu->constraint_core[i]);
+      xbt_free(cnst_id);
+    }
+
+    xbt_free(cpu->constraint_core);
+  }
+
   surf_resource_free(cpu);
 
   /* Free the network resource of the VM. */
@@ -258,32 +269,13 @@ static void vm_ws_restore(void *ind_vm_ws)
   vm_ws->current_state = SURF_VM_STATE_RUNNING;
 }
 
-
 static double get_solved_value(surf_action_t cpu_action)
 {
-  int found = 0;
-  /* 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) {
-    XBT_DEBUG("var id %p id_int %d double %f", var->id, var->id_int, var->value);
-    if (var->id == cpu_action) {
-      found = 1;
-      break;
-    }
-  }
-
-  if (found)
-    return var->value;
+  lmm_variable_t var = ((surf_action_lmm_t) cpu_action)->variable;
 
-  XBT_CRITICAL("bug: cannot found the solved variable of the action %p", cpu_action);
-  DIE_IMPOSSIBLE;
-  return -1; /* NOT REACHED */
+  return var->value;
 }
 
-
-
 /* In the real world, processes on the guest operating system will be somewhat
  * degraded due to virtualization overhead. The total CPU share that these
  * processes get is smaller than that of the VM process gets on a host
@@ -369,7 +361,7 @@ static double vm_ws_share_resources(surf_model_t workstation_model, double now)
 
 
   /* FIXME: 3. do we have to re-initialize our cpu_action object? */
-#if 1
+#if 0
   /* iterate for all hosts including virtual machines */
   xbt_lib_foreach(host_lib, cursor, key, ind_host) {
     workstation_CLM03_t ws_clm03 = ind_host[SURF_WKS_LEVEL];
@@ -487,6 +479,7 @@ static void surf_vm_workstation_model_init_internal(void)
 //   model->set_max_duration = ws_action_set_max_duration;
   model->set_priority     = ws_action_set_priority;
   model->set_bound        = ws_action_set_bound;
+  model->set_affinity     = ws_action_set_affinity;
 // #ifdef HAVE_TRACING
 //   model->set_category     = ws_action_set_category;
 // #endif