1 class org.simgrid.msg... java:import:: java.util ArrayList
3 .. java:import:: java.util Arrays
6 =============================
8 .. java:package:: org.simgrid.msg
11 .. java:type:: public abstract class Process implements Runnable
13 A process may be defined as a code, with some private data, executing in a location (host). All the process used by your simulation must be declared in the deployment file (XML format). To create your own process you must inherit your own process from this class and override the method "main()". For example if you want to use a process named Slave proceed as it : (1) import the class Process of the package simgrid.msg import simgrid.msg.Process; public class Slave extends simgrid.msg.Process { (2) Override the method function \verbatim public void main(String[] args) { System.out.println("Hello MSG"); } \endverbatim } The name of your process must be declared in the deployment file of your simulation. For the example, for the previous process Slave this file must contains a line : <process host="Maxims" function="Slave"/>, where Maxims is the host of the process Slave. All the process of your simulation are automatically launched and managed by Msg. A process use tasks to simulate communications or computations with another process. For more information see Task. For more information on host concept see Host.
20 .. java:field:: protected double startTime
23 Time at which the process should be created
30 .. java:constructor:: public Process(String hostname, String name) throws HostNotFoundException
33 Constructs a new process from the name of a host and his name. The method function of the process doesn't have argument.
35 :param hostname: Where to create the process.
36 :param name: The name of the process.
37 :throws HostNotFoundException: if no host with this name exists.
42 .. java:constructor:: public Process(String hostname, String name, String[] args) throws HostNotFoundException
45 Constructs a new process from the name of a host and his name. The arguments of the method function of the process are specified by the parameter args.
47 :param hostname: Where to create the process.
48 :param name: The name of the process.
49 :param args: The arguments of the main function of the process.
50 :throws HostNotFoundException: if no host with this name exists.
55 .. java:constructor:: public Process(Host host, String name)
58 Constructs a new process from a host and his name. The method function of the process doesn't have argument.
60 :param host: Where to create the process.
61 :param name: The name of the process.
66 .. java:constructor:: public Process(Host host, String name, String[] argsParam)
69 Constructs a new process from a host and his name, the arguments of here method function are specified by the parameter args.
71 :param host: Where to create the process.
72 :param name: The name of the process.
73 :param argsParam: The arguments of main method of the process.
78 .. java:constructor:: public Process(Host host, String name, String[] args, double startTime, double killTime)
81 Constructs a new process from a host and his name, the arguments of here method function are specified by the parameter args.
83 :param host: Where to create the process.
84 :param name: The name of the process.
85 :param args: The arguments of main method of the process.
86 :param startTime: Start time of the process
87 :param killTime: Kill time of the process
94 .. java:method:: protected native void create(Host host)
97 The native method to create an MSG process.
99 :param host: where to create the process.
104 .. java:method:: public static void debugAllThreads()
110 .. java:method:: public void exit()
113 Stops the execution of the current actor
118 .. java:method:: public static native Process fromPID(int pid)
121 This static method gets a process from a PID.
123 :param pid: The process identifier of the process to get.
124 :return: The process with the specified PID.
129 .. java:method:: public static native int getCount()
132 This static method returns the current amount of processes running
134 :return: The count of the running processes
139 .. java:method:: public static native Process getCurrentProcess()
142 This static method returns the currently running process.
144 :return: The current process.
149 .. java:method:: public Host getHost()
152 Returns the host of the process.
154 :return: The host instance of the process.
159 .. java:method:: public String getName()
162 Returns the name of the process
167 .. java:method:: public int getPID()
170 This method returns the PID of the process.
172 :return: The PID of the process.
177 .. java:method:: public int getPPID()
180 This method returns the PID of the parent of a process.
182 :return: The PID of the parent of the process.
187 .. java:method:: public native String getProperty(String name)
190 Returns the value of a given process property.
195 .. java:method:: public native boolean isSuspended()
198 Tests if a process is suspended.
200 **See also:** :java:ref:`.suspend()`, :java:ref:`.resume()`
205 .. java:method:: public native void kill()
208 Simply kills the receiving process. SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues.
213 .. java:method:: public static void kill(Process p)
219 .. java:method:: public static native void killAll()
222 This method kills all running process of the simulation.
227 .. java:method:: public abstract void main(String[] args) throws MsgException
230 The main function of the process (to implement by the user).
233 :throws MsgException:
238 .. java:method:: public native void migrate(Host host)
241 Migrates a process to another host.
243 :param host: The host where to migrate the process.
248 .. java:method:: public native void restart()
251 Restarts the process from the beginning
256 .. java:method:: public native void resume()
259 Resume a process that was suspended by \ :java:ref:`suspend()`\ .
264 .. java:method:: @Override public void run()
267 This method runs the process. It calls the method function that you must overwrite.
272 .. java:method:: public native void setAutoRestart(boolean autoRestart)
275 Specify whether the process should restart when its host restarts after a failure A process naturally stops when its host stops. It starts again only if autoRestart is set to true. Otherwise, it just disappears when the host stops.
280 .. java:method:: public native void setKillTime(double killTime)
283 Set the kill time of the process
285 :param killTime: the time when the process is killed
290 .. java:method:: public static void sleep(long millis) throws HostFailureException
293 Makes the current process sleep until millis milliseconds have elapsed. You should note that unlike "waitFor" which takes seconds (as usual in SimGrid), this method takes milliseconds (as usual for sleep() in Java).
295 :param millis: the length of time to sleep in milliseconds.
300 .. java:method:: public static native void sleep(long millis, int nanos) throws HostFailureException
303 Makes the current process sleep until millis milliseconds and nanos nanoseconds have elapsed. Unlike \ :java:ref:`waitFor(double)`\ which takes seconds, this method takes milliseconds and nanoseconds. Overloads Thread.sleep.
305 :param millis: the length of time to sleep in milliseconds.
306 :param nanos: additional nanoseconds to sleep.
311 .. java:method:: public final void start()
314 This method actually creates and run the process. It is a noop if the process is already launched.
319 .. java:method:: public native void suspend()
322 Suspends the process. See \ :java:ref:`resume()`\ to resume it afterward
327 .. java:method:: public native void waitFor(double seconds) throws HostFailureException
330 Makes the current process sleep until time seconds have elapsed.
332 :param seconds: The time the current process must sleep.
337 .. java:method:: public static native void yield()
340 Yield the current process. All other processes that are ready at the same timestamp will be executed first