* a native process. Even if this attribute is public you must never
* access to it. It is set automatically during the build of the object.
*/
- private long bind;
+ private long bind = 0;
/** Indicates if the process is started */
boolean started;
/**
*/
private double killTime = -1;
- private String name;
+ private String name = null;
private int pid = -1;
private int ppid = -1;
private Host host = null;
- /** The arguments of the method function of the process. */
- public ArrayList<String> args;
+ /** The arguments of the method function of the process. */
+ private ArrayList<String> args = new ArrayList<>();
/** Default constructor */
protected Process() {
this.id = nextProcessId++;
- this.name = null;
- this.bind = 0;
- this.args = new ArrayList<>();
}
-
/**
* Constructs a new process from the name of a host and his name. The method
* function of the process doesn't have argument.
*
*/
public Process(Host host, String name, String[]args, double startTime, double killTime) {
- this();
- this.host = host;
- if (host == null)
- throw new NullPointerException("Process name cannot be NULL");
- if (name == null)
- throw new NullPointerException("Process name cannot be NULL");
- this.name = name;
-
- this.args = new ArrayList<>();
- if (null != args)
- this.args.addAll(Arrays.asList(args));
-
+ this(host, name, args);
this.startTime = startTime;
this.killTime = killTime;
}
* SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues.
*/
public native void kill();
+ public static void kill(Process p) {
+ p.kill();
+ }
/** Suspends the process. See {@link #resume()} to resume it afterward */
public native void suspend();
*/
public native void migrate(Host host);
/**
- * Makes the current process sleep until millis millisecondes have elapsed.
+ * Makes the current process sleep until millis milliseconds have elapsed.
* You should note that unlike "waitFor" which takes seconds, this method takes milliseconds.
* FIXME: Not optimal, maybe we should have two native functions.
* @param millis the length of time to sleep in milliseconds.
* milliseconds and nanoseconds.
* Overloads Thread.sleep.
* @param millis the length of time to sleep in milliseconds.
- * @param nanos additionnal nanoseconds to sleep.
+ * @param nanos additional nanoseconds to sleep.
*/
public static native void sleep(long millis, int nanos) throws HostFailureException;
/**
}
this.main(args);
- } catch(MsgException e) {
+ }
+ catch(MsgException e) {
e.printStackTrace();
Msg.info("Unexpected behavior. Stopping now");
System.exit(1);
}
catch(ProcessKilledError pk) {
+ /* The process was killed before its end. With a kill() or something. */
}
- exit();
}
/**
*/
public abstract void main(String[]args) throws MsgException;
- public native void exit();
+ /** Stops the execution of the current actor */
+ public void exit() {
+ this.kill();
+ }
/**
* Class initializer, to initialize various JNI stuff
*/
*
* @return The count of the running processes
*/
- public native static int getCount();
+ public static native int getCount();
}