1 /* Functions related to the java process instances. */
3 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #define MSG_JPROCESS_H
14 #include <simgrid/simix.h>
16 jobject native_to_java_process(m_process_t process);
19 * This function returns a global reference to the java process instance
20 * specified by the parameter jprocess.
22 * @param jprocess The original java process instance.
23 * @param env The env of the current thread
25 * @return The global reference to the original java process
28 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
31 * This function delete a global reference to a java process instance.
32 * If the java process is alive the function joins it and stops it before.
34 * @param The global refernce to delete.
35 * @param env The env of the current thread
37 * @see jprocess_join()
38 * @see jprocess_exit()
40 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
44 * This function tests if the specified java process instance is alive.
45 * A java process object is alive if it has been started and has not yet
48 * @param jprocess The java process to test.
49 * @param env The env of the current thread
51 * @exception If the class Process is not found the function throws
52 * the ClassNotFoundException. If the methos isAlive() of
53 * this class is not found the function throws the exception
54 * NotSuchMethodException.
56 * @return If the java process is alive the function returns
57 * true. Otherwise the function returns false.
59 jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env);
62 * This function waits for a java process to terminate.
64 * @param jprocess The java process ot wait for.
65 * @param env The env of the current thread
67 * @exception If the class Process is not found the function throws
68 * the ClassNotFoundException. If the methos join() of
69 * this class is not found the function throws the exception
70 * NotSuchMethodException.
73 void jprocess_join(jobject jprocess, JNIEnv * env);
76 * This function starts the specified java process.
78 * @param jprocess The java process to start.
79 * @param env The env of the current thread
81 * @exception If the class Process is not found the function throws
82 * the ClassNotFoundException. If the methos start() of
83 * this class is not found the function throws the exception
84 * NotSuchMethodException.
86 void jprocess_start(jobject jprocess, JNIEnv * env);
89 * This function forces the java process to stop.
91 * @param jprocess The java process to stop.
92 * @param env The env of the current thread
94 * @exception If the class Process is not found the function throws
95 * the ClassNotFoundException. If the methos stop() of
96 * this class is not found the function throws the exception
97 * NotSuchMethodException.
99 void jprocess_exit(jobject jprocess, JNIEnv * env);
102 * This function associated a native process to a java process instance.
104 * @param jprocess The java process instance.
105 * @param process The native process to bind.
106 * @param env The env of the current thread
108 * @exception If the class Process is not found the function throws
109 * the ClassNotFoundException. If the field bind of
110 * this class is not found the function throws the exception
111 * NotSuchFieldException.
113 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
116 * This function returns a native process from a java process instance.
118 * @param jprocess The java process object from which get the native process.
119 * @param env The env of the current thread
121 * @return The function returns the native process associated to the
122 * java process object.
124 * @exception If the class Process is not found the function throws
125 * the ClassNotFoundException. If the field bind of
126 * this class is not found the function throws the exception
127 * NotSuchFieldException.
129 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
132 * This function gets the id of the specified java process.
134 * @param jprocess The java process to get the id.
135 * @param env The env of the current thread
137 * @exception If the class Process is not found the function throws
138 * the ClassNotFoundException. If the field id of
139 * this class is not found the function throws the exception
140 * NotSuchFieldException.
142 * @return The id of the specified java process.
144 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
147 * This function tests if a java process instance is valid.
148 * A java process object is valid if it is bind to a native
151 * @param jprocess The java process to test the validity.
152 * @param env The env of the current thread
154 * @return If the java process is valid the function returns true.
155 * Otherwise the function returns false.
157 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
160 * This function gets the name of the specified java process.
162 * @param jprocess The java process to get the name.
163 * @param env The env of the current thread
165 * @exception If the class Process is not found the function throws
166 * the ClassNotFoundException. If the field name of
167 * this class is not found the function throws the exception
168 * NotSuchFieldException.
170 * @return The name of the specified java process.
172 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
175 * This function yields the specified java process.
177 * @param jprocess The java process to yield.
178 * @param env The env of the current thread.
180 * @exception If the class Process is not found the function throws
181 * the ClassNotFoundException. If the method switchProcess of
182 * this class is not found the function throws the exception
183 * NotSuchMethodException.
185 void jprocess_yield(jobject jprocess, JNIEnv * env);
188 * This function locks the mutex of the specified java process.
190 * @param jprocess The java process of the mutex to lock.
191 * @param env The env of the current thread.
193 * @exception If the class Process is not found the function throws
194 * the ClassNotFoundException. If the method lockMutex of
195 * this class is not found the function throws the exception
196 * NotSuchMethodException.
198 void jprocess_lock_mutex(jobject jprocess, JNIEnv * env);
201 * This function unlocks the mutex of the specified java process.
203 * @param jprocess The java process of the mutex to unlock.
204 * @param env The env of the current thread.
206 * @exception If the class Process is not found the function throws
207 * the ClassNotFoundException. If the method unlockMutex of
208 * this class is not found the function throws the exception
209 * NotSuchMethodException.
211 void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env);
214 * This function signals the condition of the mutex of the specified java process.
216 * @param jprocess The java process of the condtion to signal.
217 * @param env The env of the current thread.
219 * @exception If the class Process is not found the function throws
220 * the ClassNotFoundException. If the method signalCond of
221 * this class is not found the function throws the exception
222 * NotSuchMethodException.
224 void jprocess_signal_cond(jobject jprocess, JNIEnv * env);
227 * This function waits the condition of the mutex of the specified java process.
229 * @param jprocess The java process of the condtion to wait for.
230 * @param env The env of the current thread.
232 * @exception If the class Process is not found the function throws
233 * the ClassNotFoundException. If the method waitCond of
234 * this class is not found the function throws the exception
235 * NotSuchMethodException.
237 void jprocess_wait_cond(jobject jprocess, JNIEnv * env);
239 void jprocess_schedule(smx_context_t context);
241 void jprocess_unschedule(smx_context_t context);
243 * Class org_simgrid_msg_Process
247 JNIEXPORT void JNICALL
248 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
251 * Class org_simgrid_msg_Process
253 * Signature (Lsimgrid/msg/Host;)V
255 JNIEXPORT void JNICALL
256 Java_org_simgrid_msg_Process_create(JNIEnv * env,
257 jobject jprocess, jobject jhost);
260 * Class org_simgrid_msg_Process
264 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
265 (JNIEnv *, jclass, jint);
268 * Class org_simgrid_msg_Process
270 * Signature (I)Lsimgrid/msg/Process;
272 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
273 (JNIEnv *, jclass, jint);
276 * Class org_simgrid_msg_Process
277 * Method currentProcess
278 * Signature ()Lsimgrid/msg/Process;
280 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
283 * Class org_simgrid_msg_Process
285 * Signature (Lsimgrid/msg/Process;)V
287 JNIEXPORT void JNICALL
288 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
291 * Class org_simgrid_msg_Process
293 * Signature (Lsimgrid/msg/Process;)V
295 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
298 * Class org_simgrid_msg_Process
300 * Signature (Lsimgrid/msg/Process;)Z
302 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
306 * Class org_simgrid_msg_Process
310 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
311 (JNIEnv *, jobject, jdouble);
313 * Class org_simgrid_msg_Process
317 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_exit
320 * Class org_simgrid_msg_Process
322 * Signature (Lsimgrid/msg/Process;)V
324 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
325 (JNIEnv *, jclass, jobject);
328 * Class org_simgrid_msg_Process
330 * Signature (Lsimgrid/msg/Host;)V
332 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
333 (JNIEnv *, jobject, jobject);
335 #endif /* !MSG_JPROCESS_H */