Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
useless cosmetics hinted by qtcreator
[simgrid.git] / examples / java / app / centralizedmutex / Node.java
1 /* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 package app.centralizedmutex;
7
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;
13
14 public class Node extends Process {
15   public Node(Host host, String name, String[]args) {
16    super(host,name,args);
17   }
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);
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 }