Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a straightforward implementation of start_time and kill_time. This change the...
[simgrid.git] / examples / mutualExclusion / centralized / Node.java
1 /*
2  * $Id$
3  *
4  * Copyright 2010. The SimGrid Team. All rights reserved. 
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. 
8  */
9 package mutualExclusion.centralized;
10
11 import org.simgrid.msg.Host;
12 import org.simgrid.msg.Msg;
13 import org.simgrid.msg.MsgException;
14 import org.simgrid.msg.Task;
15 import org.simgrid.msg.Process;
16
17 public class Node extends Process {
18         public Node(Host host, String name, String[]args, double startTime, double killTime) {
19                 super(host,name,args,startTime,killTime);
20         }
21         public void request(double CStime) throws MsgException {
22                 RequestTask req = new RequestTask(this.name);
23            Msg.info("Send a request to the coordinator");
24                 req.send("coordinator");
25            Msg.info("Wait for a grant from the coordinator");
26                 Task.receive(this.name); // FIXME: ensure that this is a grant
27                 Task compute = new Task("CS", CStime, 0);
28                 compute.execute();
29                 ReleaseTask release = new ReleaseTask();
30                 release.send("coordinator");
31         }
32         
33         public void main(String[] args) throws MsgException {
34                 request(Double.parseDouble(args[1]));
35         }
36 }