Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix super slow and meaning less code
[simgrid.git] / src / surf / vm_workstation.c
index 963ccb0..e2aefd7 100644 (file)
@@ -258,37 +258,19 @@ 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
  * operating system. */
-const double virt_overhead = 0.95;
+// const double virt_overhead = 0.95;
+const double virt_overhead = 1;
 
 static double vm_ws_share_resources(surf_model_t workstation_model, double now)
 {
@@ -368,7 +350,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];
@@ -380,10 +362,9 @@ static double vm_ws_share_resources(surf_model_t workstation_model, double now)
       continue;
 
     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
-    workstation_VM2013_t ws_vm2013 = (workstation_VM2013_t) ws_clm03;
     {
-      void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.name);
 #if 0
+      workstation_VM2013_t ws_vm2013 = (workstation_VM2013_t) ws_clm03;            
       XBT_INFO("cost %f remains %f start %f finish %f", ws_vm2013->cpu_action->cost,
           ws_vm2013->cpu_action->remains,
           ws_vm2013->cpu_action->start,
@@ -391,6 +372,7 @@ static double vm_ws_share_resources(surf_model_t workstation_model, double now)
           );
 #endif
 #if 0
+      void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.name);      
       surf_cpu_model_pm->action_unref(ws_vm2013->cpu_action);
       /* FIXME: this means busy loop? */
       // ws_vm2013->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_sub_host, GUESTOS_NOISE);
@@ -420,7 +402,7 @@ static void *vm_ws_get_pm(void *ind_vm_ws)
 
 
 /* Adding a task to a VM updates the VCPU task on its physical machine. */
-surf_action_t vm_ws_execute(void *workstation, double size)
+static surf_action_t vm_ws_execute(void *workstation, double size)
 {
   surf_resource_t ws = ((surf_resource_t) surf_workstation_resource_priv(workstation));
 
@@ -447,6 +429,19 @@ static void vm_ws_action_cancel(surf_action_t action)
 }
 
 
+/* Now we can set bound for each task by using MSG_task_set_bound. But, it does
+ * not work for the dummy CPU action of a VM. Here, we add the set_bound
+ * function for the dummy CPU action. */
+static void vm_ws_set_vm_bound(void *workstation, double bound)
+{
+  surf_resource_t ws = ((surf_resource_t) surf_workstation_resource_priv(workstation));
+  xbt_assert(ws->model->type == SURF_MODEL_TYPE_VM_WORKSTATION);
+  workstation_VM2013_t vm_ws = (workstation_VM2013_t) ws;
+
+  surf_action_set_bound(vm_ws->cpu_action, bound);
+}
+
+
 static void surf_vm_workstation_model_init_internal(void)
 {
   surf_model_t model = surf_model_init();
@@ -523,6 +518,7 @@ static void surf_vm_workstation_model_init_internal(void)
   model->extension.vm_workstation.save          = vm_ws_save;
   model->extension.vm_workstation.restore       = vm_ws_restore;
   model->extension.vm_workstation.get_pm        = vm_ws_get_pm;
+  model->extension.vm_workstation.set_vm_bound  = vm_ws_set_vm_bound;
 
   model->extension.workstation.set_params    = ws_set_params;
   model->extension.workstation.get_params    = ws_get_params;