Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f6c28a924a33d0fe685126e9556a0817a2d57fee
[simgrid.git] / org / simgrid / msg / MsgNative.java
1 /*
2  * Contains all the native methods related to Process, Host and Task.
3  *
4  * Copyright 2006,2007,2010 The SimGrid Team           
5  * All right reserved. 
6  *
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. 
10  */
11
12 package org.simgrid.msg;
13
14 import org.simgrid.msg.Process;
15
16 /* FIXME: split into internal classes of Msg, Task, Host etc. */
17
18 /**
19  *  Contains all the native methods related to Process, Host and Task.
20  */
21 final class MsgNative {
22
23         /******************************************************************
24          * The natively implemented methods connected to the MSG Process  *
25          ******************************************************************/
26         /**
27          * The natively implemented method to create an MSG process.
28          *
29          * @param process The java process object to bind with the MSG native process.
30          * @param host    A valid (binded) host where create the process.
31          *
32          * @see  Process constructors.
33          */
34         final static native
35         void processCreate(Process process, String hostName) throws HostNotFoundException;
36
37         /**
38          * The natively implemented method to kill all the process of the simulation.
39          *
40          * @param resetPID        Should we reset the PID numbers. A negative number means no reset
41          *                        and a positive number will be used to set the PID of the next newly
42          *                        created process.
43          *
44          * @return                The function returns the PID of the next created process.
45          */
46         final static native int processKillAll(int resetPID);
47
48         /**
49          * The natively implemented method to suspend an MSG process.
50          *
51          * @param process        The valid (binded with a native process) java process to suspend.
52          *
53          * @see                 Process.pause()
54          */
55         final static native void processSuspend(Process process);
56
57         /**
58          * The natively implemented method to kill a MSG process.
59          *
60          * @param process        The valid (binded with a native process) java process to kill.
61          *
62          * @see                 Process.kill()
63          */
64         final static native void processKill(Process process);
65
66         /**
67          * The natively implemented method to resume a suspended MSG process.
68          *
69          * @param process        The valid (binded with a native process) java process to resume.
70          *
71          *
72          * @see                 Process.restart()
73          */
74         final static native void processResume(Process process);
75
76         /**
77          * The natively implemented method to test if MSG process is suspended.
78          *
79          * @param process        The valid (binded with a native process) java process to test.
80          *
81          * @return                If the process is suspended the method retuns true. Otherwise the
82          *                        method returns false.
83          *
84          * @see                 Process.isSuspended()
85          */
86         final static native boolean processIsSuspended(Process process);
87
88         /**
89          * The natively implemented method to get the host of a MSG process.
90          *
91          * @param process        The valid (binded with a native process) java process to get the host.
92          *
93          * @return                The method returns the host where the process is running.
94          *
95          * @exception            HostNotFoundException if the SimGrid native code failed (initialization error?).
96          *
97          * @see                 Process.getHost()
98          */
99         final static native Host processGetHost(Process process);
100
101         /**
102          * The natively implemented method to get a MSG process from his PID.
103          *
104          * @param PID            The PID of the process to get.
105          *
106          * @return                The process with the specified PID.
107          *
108          * @see                 Process.getFromPID()
109          */
110         final static native Process processFromPID(int PID) ;
111
112         /**
113          * The natively implemented method to get the PID of a MSG process.
114          *
115          * @param process        The valid (binded with a native process) java process to get the PID.
116          *
117          * @return                The PID of the specified process.
118          *
119          * @see                 Process.getPID()
120          */
121         final static native int processGetPID(Process process);
122
123         /**
124          * The natively implemented method to get the PPID of a MSG process.
125          *
126          * @param process        The valid (binded with a native process) java process to get the PID.
127          *
128          * @return                The PPID of the specified process.
129          *
130          * @see                 Process.getPPID()
131          */
132         final static native int processGetPPID(Process process);
133
134         /**
135          * The natively implemented method to get the current running process.
136          *
137          * @return             The current process.
138          *
139          * @see                Process.currentProcess()
140          */
141         final static native Process processSelf();
142
143         /**
144          * The natively implemented method to migrate a process from his currnet host to a new host.
145          *
146          * @param process        The (valid) process to migrate.
147          * @param host            A (valid) host where move the process.
148          *
149          *
150          * @see                Process.migrate()
151          * @see                Host.getByName()
152          */
153         final static native void processMigrate(Process process, Host host) ;
154
155         /**
156          * The natively implemented native to request the current process to sleep 
157          * until time seconds have elapsed.
158          *
159          * @param seconds        The time the current process must sleep.
160          *
161          * @exception            HostFailureException if the SimGrid native code failed.
162          *
163          * @see                 Process.waitFor()
164          */
165         final static native void processWaitFor(double seconds) throws HostFailureException;
166
167         /**
168          * The natively implemented native method to exit a process.
169          *
170          * @see                Process.exit()
171          */
172         final static native void processExit(Process process);
173
174
175         /******************************************************************
176          * The natively implemented methods connected to the MSG host     *
177          ******************************************************************/
178
179         /**
180          * The natively implemented native method to get all the hosts of the simulation.
181          *
182          * @return                A array which contains all the hosts of simulation.
183          */
184
185         final static native Host[] allHosts();
186
187 }