Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the files generated by javasphinx in the git
[simgrid.git] / docs / source / java / org / simgrid / msg / Process.rst
1 class org.simgrid.msg... java:import:: java.util ArrayList
2
3 .. java:import:: java.util Arrays
4
5 Process
6 =============================
7
8 .. java:package:: org.simgrid.msg
9    :noindex:
10
11 .. java:type:: public abstract class Process implements Runnable
12
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.
14
15 Fields
16 ------
17 startTime
18 ^^^^^^^^^
19
20 .. java:field:: protected double startTime
21    :outertype: Process
22
23    Time at which the process should be created
24
25 Constructors
26 ------------
27 Process
28 ^^^^^^^
29
30 .. java:constructor:: public Process(String hostname, String name) throws HostNotFoundException
31    :outertype: Process
32
33    Constructs a new process from the name of a host and his name. The method function of the process doesn't have argument.
34
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.
38
39 Process
40 ^^^^^^^
41
42 .. java:constructor:: public Process(String hostname, String name, String[] args) throws HostNotFoundException
43    :outertype: Process
44
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.
46
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.
51
52 Process
53 ^^^^^^^
54
55 .. java:constructor:: public Process(Host host, String name)
56    :outertype: Process
57
58    Constructs a new process from a host and his name. The method function of the process doesn't have argument.
59
60    :param host: Where to create the process.
61    :param name: The name of the process.
62
63 Process
64 ^^^^^^^
65
66 .. java:constructor:: public Process(Host host, String name, String[] argsParam)
67    :outertype: Process
68
69    Constructs a new process from a host and his name, the arguments of here method function are specified by the parameter args.
70
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.
74
75 Process
76 ^^^^^^^
77
78 .. java:constructor:: public Process(Host host, String name, String[] args, double startTime, double killTime)
79    :outertype: Process
80
81    Constructs a new process from a host and his name, the arguments of here method function are specified by the parameter args.
82
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
88
89 Methods
90 -------
91 create
92 ^^^^^^
93
94 .. java:method:: protected native void create(Host host)
95    :outertype: Process
96
97    The native method to create an MSG process.
98
99    :param host: where to create the process.
100
101 debugAllThreads
102 ^^^^^^^^^^^^^^^
103
104 .. java:method:: public static void debugAllThreads()
105    :outertype: Process
106
107 exit
108 ^^^^
109
110 .. java:method:: public void exit()
111    :outertype: Process
112
113    Stops the execution of the current actor
114
115 fromPID
116 ^^^^^^^
117
118 .. java:method:: public static native Process fromPID(int pid)
119    :outertype: Process
120
121    This static method gets a process from a PID.
122
123    :param pid: The process identifier of the process to get.
124    :return: The process with the specified PID.
125
126 getCount
127 ^^^^^^^^
128
129 .. java:method:: public static native int getCount()
130    :outertype: Process
131
132    This static method returns the current amount of processes running
133
134    :return: The count of the running processes
135
136 getCurrentProcess
137 ^^^^^^^^^^^^^^^^^
138
139 .. java:method:: public static native Process getCurrentProcess()
140    :outertype: Process
141
142    This static method returns the currently running process.
143
144    :return: The current process.
145
146 getHost
147 ^^^^^^^
148
149 .. java:method:: public Host getHost()
150    :outertype: Process
151
152    Returns the host of the process.
153
154    :return: The host instance of the process.
155
156 getName
157 ^^^^^^^
158
159 .. java:method:: public String getName()
160    :outertype: Process
161
162    Returns the name of the process
163
164 getPID
165 ^^^^^^
166
167 .. java:method:: public int getPID()
168    :outertype: Process
169
170    This method returns the PID of the process.
171
172    :return: The PID of the process.
173
174 getPPID
175 ^^^^^^^
176
177 .. java:method:: public int getPPID()
178    :outertype: Process
179
180    This method returns the PID of the parent of a process.
181
182    :return: The PID of the parent of the process.
183
184 getProperty
185 ^^^^^^^^^^^
186
187 .. java:method:: public native String getProperty(String name)
188    :outertype: Process
189
190    Returns the value of a given process property.
191
192 isSuspended
193 ^^^^^^^^^^^
194
195 .. java:method:: public native boolean isSuspended()
196    :outertype: Process
197
198    Tests if a process is suspended.
199
200    **See also:** :java:ref:`.suspend()`, :java:ref:`.resume()`
201
202 kill
203 ^^^^
204
205 .. java:method:: public native void kill()
206    :outertype: Process
207
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.
209
210 kill
211 ^^^^
212
213 .. java:method:: public static void kill(Process p)
214    :outertype: Process
215
216 killAll
217 ^^^^^^^
218
219 .. java:method:: public static native void killAll()
220    :outertype: Process
221
222    This method kills all running process of the simulation.
223
224 main
225 ^^^^
226
227 .. java:method:: public abstract void main(String[] args) throws MsgException
228    :outertype: Process
229
230    The main function of the process (to implement by the user).
231
232    :param args:
233    :throws MsgException:
234
235 migrate
236 ^^^^^^^
237
238 .. java:method:: public native void migrate(Host host)
239    :outertype: Process
240
241    Migrates a process to another host.
242
243    :param host: The host where to migrate the process.
244
245 restart
246 ^^^^^^^
247
248 .. java:method:: public native void restart()
249    :outertype: Process
250
251    Restarts the process from the beginning
252
253 resume
254 ^^^^^^
255
256 .. java:method:: public native void resume()
257    :outertype: Process
258
259    Resume a process that was suspended by \ :java:ref:`suspend()`\ .
260
261 run
262 ^^^
263
264 .. java:method:: @Override public void run()
265    :outertype: Process
266
267    This method runs the process. It calls the method function that you must overwrite.
268
269 setAutoRestart
270 ^^^^^^^^^^^^^^
271
272 .. java:method:: public native void setAutoRestart(boolean autoRestart)
273    :outertype: Process
274
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.
276
277 setKillTime
278 ^^^^^^^^^^^
279
280 .. java:method:: public native void setKillTime(double killTime)
281    :outertype: Process
282
283    Set the kill time of the process
284
285    :param killTime: the time when the process is killed
286
287 sleep
288 ^^^^^
289
290 .. java:method:: public static void sleep(long millis) throws HostFailureException
291    :outertype: Process
292
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).
294
295    :param millis: the length of time to sleep in milliseconds.
296
297 sleep
298 ^^^^^
299
300 .. java:method:: public static native void sleep(long millis, int nanos) throws HostFailureException
301    :outertype: Process
302
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.
304
305    :param millis: the length of time to sleep in milliseconds.
306    :param nanos: additional nanoseconds to sleep.
307
308 start
309 ^^^^^
310
311 .. java:method:: public final void start()
312    :outertype: Process
313
314    This method actually creates and run the process. It is a noop if the process is already launched.
315
316 suspend
317 ^^^^^^^
318
319 .. java:method:: public native void suspend()
320    :outertype: Process
321
322    Suspends the process. See \ :java:ref:`resume()`\  to resume it afterward
323
324 waitFor
325 ^^^^^^^
326
327 .. java:method:: public native void waitFor(double seconds) throws HostFailureException
328    :outertype: Process
329
330    Makes the current process sleep until time seconds have elapsed.
331
332    :param seconds: The time the current process must sleep.
333
334 yield
335 ^^^^^
336
337 .. java:method:: public static native void yield()
338    :outertype: Process
339
340    Yield the current process. All other processes that are ready at the same timestamp will be executed first
341