1 /* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 package app.centralizedmutex;
8 import org.simgrid.msg.Msg;
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.Task;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.MsgException;
14 public class Node extends Process {
15 public Node(Host host, String name, String[]args) {
16 super(host,name,args);
18 public void request(double csTime) throws MsgException {
19 RequestTask req = new RequestTask(getName());
20 Msg.info("Send a request to the coordinator");
21 req.send("coordinator");
22 Msg.info("Wait for a grant from the coordinator");
23 GrantTask.receive(getName());
24 Task compute = new Task("CS", csTime, 0);
26 ReleaseTask release = new ReleaseTask();
27 release.send("coordinator");
30 public void main(String[] args) throws MsgException {
31 request(Double.parseDouble(args[1]));