/** * \brief Cleans the MSG data of a process. * \param smx_proc a SIMIX process */ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) { simdata_process_t msg_proc; // get the MSG process from the SIMIX process if (smx_proc == SIMIX_process_self()) { /* avoid a SIMIX request if this function is called by the process itself */ msg_proc = SIMIX_process_self_get_data(smx_proc); SIMIX_process_self_set_data(smx_proc, NULL); } else { msg_proc = simcall_process_get_data(smx_proc); simcall_process_set_data(smx_proc, NULL); } #ifdef HAVE_TRACING TRACE_msg_process_end(smx_proc); #endif // free the data if a function was provided if (msg_proc->data && msg_global->process_data_cleanup) { msg_global->process_data_cleanup(msg_proc->data); } // remove the process from its virtual machine if (msg_proc->vm) { int pos = xbt_dynar_search(msg_proc->vm->processes,&smx_proc); xbt_dynar_remove_at(msg_proc->vm->processes,pos, NULL); } // free the MSG process xbt_free(msg_proc); }
/** @brief Returns a boolean indicating whether the element is part of the dynar * * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not * what you want. Check the documentation of xbt_dynar_search() for more info. */ int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem) { xbt_ex_t e; TRY { xbt_dynar_search(dynar, elem); } CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); return 0; } RETHROW; } return 1; }
double VMHL13Model::shareResources(double now) { /* TODO: udpate action's cost with the total cost of processes on the VM. */ /* 0. Make sure that we already calculated the resource share at the physical * machine layer. */ { _XBT_GNUC_UNUSED ModelPtr ws_model = surf_host_model; _XBT_GNUC_UNUSED ModelPtr vm_ws_model = surf_vm_model; _XBT_GNUC_UNUSED unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &ws_model); _XBT_GNUC_UNUSED unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, &vm_ws_model); xbt_assert((index_of_pm_ws_model < index_of_vm_ws_model), "Cannot assume surf_host_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. */ } /* 1. Now we know how many resource should be assigned to each virtual * machine. We update constraints of the virtual machine layer. * * * If we have two virtual machine (VM1 and VM2) on a physical machine (PM1). * X1 + X2 = C (Equation 1) * where * the resource share of VM1: X1 * the resource share of VM2: X2 * the capacity of PM1: C * * Then, if we have two process (P1 and P2) on VM1. * X1_1 + X1_2 = X1 (Equation 2) * where * the resource share of P1: X1_1 * the resource share of P2: X1_2 * the capacity of VM1: X1 * * Equation 1 was solved in the physical machine layer. * Equation 2 is solved in the virtual machine layer (here). * X1 must be passed to the virtual machine laye as a constraint value. * **/ /* iterate for all virtual machines */ for (VMModel::vm_list_t::iterator iter = VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) { VMPtr ws_vm = &*iter; CpuPtr cpu = ws_vm->p_cpu; xbt_assert(cpu, "cpu-less host"); double solved_value = get_solved_value(ws_vm->p_action); XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->getName(), ws_vm->p_subWs->getName()); // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution. // cpu_cas01->constraint->bound = solved_value; xbt_assert(cpu->getModel() == surf_cpu_model_vm); lmm_system_t vcpu_system = cpu->getModel()->getMaxminSystem(); lmm_update_constraint_bound(vcpu_system, cpu->getConstraint(), virt_overhead * solved_value); } /* 2. Calculate resource share at the virtual machine layer. */ adjustWeightOfDummyCpuActions(); double min_by_cpu = p_cpuModel->shareResources(now); double min_by_net = (strcmp(surf_network_model->getName(), "network NS3")) ? surf_network_model->shareResources(now) : -1; double min_by_sto = -1; if (p_cpuModel == surf_cpu_model_pm) min_by_sto = surf_storage_model->shareResources(now); XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f", this, surf_cpu_model_pm->getName(), min_by_cpu, surf_network_model->getName(), min_by_net, surf_storage_model->getName(), min_by_sto); double ret = max(max(min_by_cpu, min_by_net), min_by_sto); if (min_by_cpu >= 0.0 && min_by_cpu < ret) ret = min_by_cpu; if (min_by_net >= 0.0 && min_by_net < ret) ret = min_by_net; if (min_by_sto >= 0.0 && min_by_sto < ret) ret = min_by_sto; /* FIXME: 3. do we have to re-initialize our cpu_action object? */ #if 0 /* iterate for all virtual machines */ for (VMModel::vm_list_t::iterator iter = VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) { { #if 0 VM2013Ptr ws_vm2013 = static_cast<VM2013Ptr>(&*iter); 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, ws_vm2013->cpu_action->finish ); #endif #if 0 void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.getName); 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); ws_vm2013->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_sub_host, 0); #endif } } #endif return ret; }