Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
75cc6662069677fb337597f849845945cc683994
[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.Msg;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.Process;
15
16 public class Node extends Process {
17
18         public void request(double CStime) throws MsgException {
19                 RequestTask req = new RequestTask(this.name);
20            Msg.info("Send a request to the coordinator");
21                 req.send("coordinator");
22            Msg.info("Wait for a grant from the coordinator");
23                 Task.receive(this.name); // FIXME: ensure that this is a grant
24                 Task compute = new Task("CS", CStime, 0);
25                 compute.execute();
26                 ReleaseTask release = new ReleaseTask();
27                 release.send("coordinator");
28         }
29         
30         public void main(String[] args) throws MsgException {
31                 request(Double.parseDouble(args[1]));
32         }
33 }