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.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;
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);
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);
29 ReleaseTask release = new ReleaseTask();
30 release.send("coordinator");
33 public void main(String[] args) throws MsgException {
34 request(Double.parseDouble(args[1]));