2 * Contains all the native methods related to Process, Host and Task.
4 * Copyright 2006,2007,2010 The SimGrid Team
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 *(GNU LGPL) which comes with this package.
14 /* FIXME: split into internal classes of Msg, Task, Host etc. */
17 * Contains all the native methods related to Process, Host and Task.
19 final class MsgNative {
22 void selectContextFactory(String name) throws NativeException;
24 /******************************************************************
25 * The natively implemented methods connected to the MSG Process *
26 ******************************************************************/
28 * The natively implemented method to create an MSG process.
30 * @param process The java process object to bind with the MSG native process.
31 * @param host A valid (binded) host where create the process.
33 * @see Process constructors.
36 void processCreate(Process process, Host host);
39 * The natively implemented method to kill all the process of the simulation.
41 * @param resetPID Should we reset the PID numbers. A negative number means no reset
42 * and a positive number will be used to set the PID of the next newly
45 * @return The function returns the PID of the next created process.
47 final static native int processKillAll(int resetPID);
50 * The natively implemented method to suspend an MSG process.
52 * @param process The valid (binded with a native process) java process to suspend.
54 * @exception NativeException if the SimGrid native code failed.
56 * @see Process.pause()
58 final static native void processSuspend(Process process) throws NativeException;
61 * The natively implemented method to kill a MSG process.
63 * @param process The valid (binded with a native process) java process to kill.
67 final static native void processKill(Process process);
70 * The natively implemented method to resume a suspended MSG process.
72 * @param process The valid (binded with a native process) java process to resume.
74 * @exception NativeException if the SimGrid native code failed.
76 * @see Process.restart()
78 final static native void processResume(Process process) throws NativeException;
81 * The natively implemented method to test if MSG process is suspended.
83 * @param process The valid (binded with a native process) java process to test.
85 * @return If the process is suspended the method retuns true. Otherwise the
86 * method returns false.
88 * @see Process.isSuspended()
90 final static native boolean processIsSuspended(Process process);
93 * The natively implemented method to get the host of a MSG process.
95 * @param process The valid (binded with a native process) java process to get the host.
97 * @return The method returns the host where the process is running.
99 * @exception NativeException if the SimGrid native code failed.
101 * @see Process.getHost()
103 final static native Host processGetHost(Process process) throws NativeException;
106 * The natively implemented method to get a MSG process from his PID.
108 * @param PID The PID of the process to get.
110 * @return The process with the specified PID.
112 * @exception NativeException if the SimGrid native code failed.
114 * @see Process.getFromPID()
116 final static native Process processFromPID(int PID) throws NativeException;
119 * The natively implemented method to get the PID of a MSG process.
121 * @param process The valid (binded with a native process) java process to get the PID.
123 * @return The PID of the specified process.
125 * @exception NativeException if the SimGrid native code failed.
127 * @see Process.getPID()
129 final static native int processGetPID(Process process) throws NativeException;
132 * The natively implemented method to get the PPID of a MSG process.
134 * @param process The valid (binded with a native process) java process to get the PID.
136 * @return The PPID of the specified process.
138 * @exception NativeException if the SimGrid native code failed.
140 * @see Process.getPPID()
142 final static native int processGetPPID(Process process) throws NativeException;
145 * The natively implemented method to get the current running process.
147 * @return The current process.
149 * @exception NativeException if the SimGrid native code failed.
151 * @see Process.currentProcess()
153 final static native Process processSelf() throws NativeException;
156 * The natively implemented method to migrate a process from his currnet host to a new host.
158 * @param process The (valid) process to migrate.
159 * @param host A (valid) host where move the process.
161 * @exception NativeException if the SimGrid native code failed.
163 * @see Process.migrate()
164 * @see Host.getByName()
166 final static native void processChangeHost(Process process, Host host) throws NativeException;
169 * The natively implemented native to request the current process to sleep
170 * until time seconds have elapsed.
172 * @param seconds The time the current process must sleep.
174 * @exception NativeException if the SimGrid native code failed.
176 * @see Process.waitFor()
178 final static native void processWaitFor(double seconds) throws NativeException;
181 * The natively implemented native method to exit a process.
183 * @see Process.exit()
185 final static native void processExit(Process process);
188 /******************************************************************
189 * The natively implemented methods connected to the MSG host *
190 ******************************************************************/
193 * The natively implemented method to get an host from his name.
195 * @param name The name of the host to get.
197 * @return The host having the specified name.
199 * @exception HostNotFoundException if there is no such host
200 * NativeException if the SimGrid native code failed.
202 * @see Host.getByName()
204 final static native Host hostGetByName(String name) throws HostNotFoundException, NativeException;
207 * The natively implemented method to get the name of an MSG host.
209 * @param host The host (valid) to get the name.
211 * @return The name of the specified host.
213 * @see Host.getName()
215 final static native String hostGetName(Host host);
218 * The natively implemented method to get the number of hosts of the simulation.
220 * @return The number of hosts of the simulation.
222 * @see Host.getNumber()
224 final static native int hostGetCount();
227 * The natively implemented method to get the host of the current runing process.
229 * @return The host of the current running process.
231 * @see Host.currentHost()
233 final static native Host hostSelf();
236 * The natively implemented method to get the speed of a MSG host.
238 * @param host The host to get the host.
240 * @return The speed of the specified host.
242 * @see Host.getSpeed()
245 final static native double hostGetSpeed(Host host);
248 * The natively implemented native method to test if an host is avail.
250 * @param host The host to test.
252 * @return If the host is avail the method returns true.
253 * Otherwise the method returns false.
255 * @see Host.isAvail()
257 final static native boolean hostIsAvail(Host host);
260 * The natively implemented native method to get all the hosts of the simulation.
262 * @return A array which contains all the hosts of simulation.
265 final static native Host[] allHosts();
268 * The natively implemented native method to get the number of running tasks on a host.
270 * @param The host concerned by the operation.
272 * @return The number of running tasks.
274 final static native int hostGetLoad(Host host);
276 /******************************************************************
277 * The natively implemented methods connected to the MSG task *
278 ******************************************************************/
281 * The natively implemented method to create a MSG task.
283 * @param name The name of th task.
284 * @param computeDuration A value of the processing amount (in flop) needed
285 * to process the task. If 0, then it cannot be executed
286 * with the execute() method. This value has to be >= 0.
287 * @param messageSize A value of amount of data (in bytes) needed to transfert
288 * this task. If 0, then it cannot be transfered this task.
289 * If 0, then it cannot be transfered with the get() and put()
290 * methods. This value has to be >= 0.
291 * @param task The java task object to bind with the native task to create.
293 * @exception IllegalArgumentException if compute duration <0 or message size <0
297 final static native void taskCreate(Task task, String name,
298 double computeDuration,
300 throws IllegalArgumentException;
303 * The natively implemented method to get the sender of a task.
305 * @param task The task (valid) to get the sender.
307 * @return The sender of the task.
309 * @see Task.getSender()
311 final static native Process taskGetSender(Task task);
314 * The natively implementd method to get the source of a task.
316 * @param task The task to get the source.
318 * @return The source of the task.
320 * @exception NativeException if the SimGrid native code failed.
322 * @see Task.getSource()
324 final static native Host taskGetSource(Task task) throws NativeException;
327 * The natively implemented method to get the name of the task.
329 * @param task The task to get the name.
331 * @return The name of the specified task.
333 * @see Task.getName()
335 final static native String taskGetName(Task task);
338 * The natively implemented method to cancel a task.
340 * @param task The task to cancel.
342 * @exception NativeException if the cancellation failed.
344 * @see Task.cancel().
346 final static native void taskCancel(Task task) throws NativeException;
349 * The natively implemented method to create a MSG parallel task.
351 * @param name The name of the parallel task.
352 * @param hosts The list of hosts implied by the parallel task.
353 * @param computeDurations The total number of operations that have to be performed
355 * @param messageSizes An array of doubles
357 * @see ParallelTask.create()
359 final static native void parallelTaskCreate(Task pTask, String name,
361 double[]computeDurations,
362 double[]messageSizes)
363 throws NullPointerException, IllegalArgumentException;
366 * The natively implemented method to get the computing amount of the task.
368 * @param task The task to get the computing amount.
370 * @return The computing amount of the specified task.
372 * @see Task.getComputeDuration()
374 final static native double taskGetComputeDuration(Task task);
377 * The natively implemented method to get the remaining computation
379 * @param task The task to get the remaining computation.
381 * @return The remaining computation of the specified task.
383 * @see Task.getRemainingDuration()
385 final static native double taskGetRemainingDuration(Task task);
388 * The natively implemented method to set the priority of a task.
390 * @param task The task to set the priority
392 * @param priority The new priority of the specified task.
394 * @see Task.setPriority()
396 final static native void taskSetPriority(Task task, double priority);
399 * The natively implemented method to destroy a MSG task.
401 * @param The task to destroy.
403 * @exception NativeException on error in the C world
405 * @see Task.destroy()
407 final static native void taskDestroy(Task task) throws NativeException;
410 * The natively implemented method to execute a MSG task.
412 * @param task The task to execute.
414 * @exception NativeException on error in the C world
416 * @see Task.execute()
418 final static native void taskExecute(Task task) throws NativeException;
420 /* ****************************************************************
421 * Communication methods thru mailboxes *
422 **************************************************************** */
424 final static native void taskSend(String alias, Task task, double timeout) throws NativeException,TransferFailureException,HostFailureException,TimeoutFailureException;
425 final static native Task taskReceive(String alias, double timeout, Host host) throws NativeException;
426 final static native int taskListenFrom(String alias) throws NativeException;
427 final static native boolean taskListen(String alias);
428 final static native int taskListenFromHost(String alias, Host host);
430 /* ***************************************************************
431 * Task sending methods *
432 *************************************************************** */
435 * The natively implemented method to send a task in a mailbox associated with an alias, with a bounded transmition
438 * @param alias The alias of the mailbox.
439 * @param task The task to put.
440 * @param max_rate The bounded transmition rate.
442 * @exception NativeException on error in the C world
444 final static native void taskSendBounded(String alias, Task task, double maxrate) throws NativeException;