4 * Copyright 2010. The SimGrid Team. All rights reserved.
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.
9 package mutualExclusion.centralized;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.Process;
16 public class Node extends Process {
17 public Node(String hostname, String name) throws HostNotFoundException {
18 super(hostname, name);
20 public void request(double CStime) throws MsgException {
21 RequestTask req = new RequestTask(this.name);
22 Msg.info("Send a request to the coordinator");
23 req.send("coordinator");
24 Msg.info("Wait for a grant from the coordinator");
25 Task.receive(this.name); // FIXME: ensure that this is a grant
26 Task compute = new Task("CS", CStime, 0);
28 ReleaseTask release = new ReleaseTask();
29 release.send("coordinator");
32 public void main(String[] args) throws MsgException {
33 request(Double.parseDouble(args[1]));