typedef Cpu *surf_cpu_t;
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) {
xbt_lib_set(host_lib, host->key, SURF_CPU_LEVEL, cpu);
}
+void sg_host_surfcpu_register(sg_host_t host, surf_cpu_t cpu)
+{
+ surf_callback_emit(cpuCreatedCallbacks, cpu);
+ surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, cpu->getState());
+ sg_host_surfcpu_set(host, cpu);
+}
void sg_host_surfcpu_destroy(sg_host_t host) {
xbt_lib_unset(host_lib,host->key,SURF_CPU_LEVEL,1);
}
xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
- surf_callback_emit(cpuCreatedCallbacks, cpu);
- surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, state_initial);
- sg_host_surfcpu_set(host, cpu);
-
+ sg_host_surfcpu_register(host, cpu);
return cpu;
}
"Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
CpuTi *cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
core, stateInitial, stateTrace, cpuProperties);
- surf_callback_emit(cpuCreatedCallbacks, cpu);
- surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, stateInitial);
- sg_host_surfcpu_set(host, cpu);
+ sg_host_surfcpu_register(host, cpu);
return cpu;
}
CpuL07 *cpu = new CpuL07(this, name, cpu_properties,
power_initial, power_scale, power_trace,
core, state_initial, state_trace);
- surf_callback_emit(cpuCreatedCallbacks, cpu);
- surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, state_initial);
- sg_host_surfcpu_set(sg_host, cpu);
-
+ sg_host_surfcpu_register(sg_host, cpu);
return cpu;
}