// ========== SURF CPU ============
XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host);
XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu);
-XBT_PUBLIC(void) sg_host_surfcpu_register(sg_host_t host, surf_cpu_t cpu);
XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host);
// ========== RoutingEdge ============
void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
host->set_facet(simgrid::surf::Cpu::LEVEL, cpu);
}
-void sg_host_surfcpu_register(sg_host_t host, surf_cpu_t cpu)
-{
- surf_callback_emit(simgrid::surf::cpuCreatedCallbacks, cpu);
- surf_callback_emit(simgrid::surf::cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, cpu->getState());
- sg_host_surfcpu_set(host, cpu);
-}
void sg_host_surfcpu_destroy(sg_host_t host) {
host->set_facet<simgrid::surf::Cpu>(nullptr);
}
surf_callback_emit(cpuStateChangedCallbacks, this, old, state);
}
+void Cpu::plug(simgrid::Host* host)
+{
+ if (this->m_host != nullptr)
+ xbt_die("Aleady plugged into host %s", host->id().c_str());
+ host->set_facet(this);
+ this->m_host = host;
+ simgrid::surf::cpuCreatedCallbacks(this);
+ simgrid::surf::cpuStateChangedCallbacks(this,
+ SURF_RESOURCE_ON, this->getState());
+}
+
/**********
* Action *
**********/
virtual int getPstate()=0;
void setState(e_surf_resource_state_t state);
+ void plug(simgrid::Host* host);
void addTraces(void);
int m_core = 1; /* Amount of cores */
double m_speedPeak; /*< CPU speed peak, ie max value */
double m_speedScale; /*< Percentage of CPU available according to the trace, in [O,1] */
+ simgrid::Host* m_host = nullptr;
/* Note (hypervisor): */
lmm_constraint_t *p_constraintCore=NULL;
void **p_constraintCoreId=NULL;
+
};
/**********
if (current_routing)
net = routing_add_host(current_routing, host);
+ sg_host_t h = simgrid::Host::by_name_or_create(host->id);
simgrid::surf::Cpu *cpu = surf_cpu_model_pm->createCpu(
host->id,
host->speed_peak,
host->initial_state,
host->state_trace,
host->properties);
- sg_host_surfcpu_register(sg_host_by_name(host->id), cpu);
+ cpu->plug(h);
surf_host_model->createHost(host->id, net, cpu);
if (TRACE_is_enabled() && TRACE_needs_platform())
SURF_RESOURCE_ON, // host->initial_state,
NULL, // host->state_trace,
NULL); // host->properties,
- sg_host_surfcpu_register(host, p_cpu);
+ p_cpu->plug(host);
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */