3 import org.simgrid.surf.*;
4 import org.simgrid.msg.Msg;
6 import java.util.ArrayList;
8 public class CpuConstantModel extends CpuModel {
10 private List<CpuConstant> cpus = new ArrayList<CpuConstant>();
11 private List<CpuConstantAction> actions = new ArrayList<CpuConstantAction>();
13 public CpuConstantModel() {
14 super("Cpu Constant");
15 Msg.info("Initialize Cpu Constant Model");
18 public Cpu createResource(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) {
19 Msg.info("Create Resource Name: "+name);
20 CpuConstant res = new CpuConstant(this, name, cpu_properties, actions, 1, 1000, 1000);
22 Surf.setCpu(name, res);
26 public void setState(ResourceState state) {
30 public double shareResources(double now) {
31 Msg.info("shareResource of "+cpus.size()+" cpu and "+actions.size()+" actions");
35 public void updateActionsState(double now, double delta) {
36 Msg.info("updateActionState of "+cpus.size()+" cpu and "+actions.size()+" actions");
39 public void addTraces() {
42 public class CpuConstant extends Cpu {
43 private List<CpuConstantAction> actions;
45 public CpuConstant(CpuConstantModel model, String name, XbtDict props,
46 List<CpuConstantAction> actions,
47 int core, double powerPeak, double powerScale) {
48 super(model, name, props, core, powerPeak, powerScale);
49 this.actions = actions;
52 public CpuAction execute(double size) {
53 CpuConstantAction res = new CpuConstantAction(getModel(), size, false);
54 Msg.info("Execute action of size "+size);
59 public CpuAction sleep(double duration) {
60 CpuConstantAction res = new CpuConstantAction(getModel(), duration, false);
61 Msg.info("Sleep action of duration "+duration);
66 public ResourceState getState(){
67 return ResourceState.SURF_RESOURCE_ON;
71 public class CpuConstantAction extends CpuAction {
72 public CpuConstantAction(Model model, double cost, boolean failed) {
73 super(model, cost, failed);