1 import org.simgrid.msg.*;
2 import org.simgrid.msg.Process;
4 public class Daemon extends Process {
5 private Task currentTask;
6 public Daemon(VM vm, int load) {
7 super((Host)vm,"Daemon");
8 currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
10 public void main(String[] args) throws MsgException {
12 while(!Main.isEndOfTest()) {
13 // TODO the binding is not yet available
15 currentTask.execute();
16 } catch (HostFailureException e) {
18 } catch (TaskCancelledException e) {
19 System.out.println("task cancelled");
20 suspend(); // Suspend the process
22 currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0);
23 Msg.info(currentTask.getName());
27 public double getRemaining(){
28 return this.currentTask.getRemainingDuration();