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 "simix/simix.h"
17 * This function returns a global reference to the java process instance
18 * specified by the parameter jprocess.
20 * @param jprocess The original java process instance.
21 * @param env The env of the current thread
23 * @return The global reference to the original java process
26 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
29 * This function delete a global reference to a java process instance.
30 * If the java process is alive the function joins it and stops it before.
32 * @param The global refernce to delete.
33 * @param env The env of the current thread
35 * @see jprocess_join()
36 * @see jprocess_exit()
38 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
42 * This function tests if the specified java process instance is alive.
43 * A java process object is alive if it has been started and has not yet
46 * @param jprocess The java process to test.
47 * @param env The env of the current thread
49 * @exception If the class Process is not found the function throws
50 * the ClassNotFoundException. If the methos isAlive() of
51 * this class is not found the function throws the exception
52 * NotSuchMethodException.
54 * @return If the java process is alive the function returns
55 * true. Otherwise the function returns false.
57 jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env);
60 * This function waits for a java process to terminate.
62 * @param jprocess The java process ot wait for.
63 * @param env The env of the current thread
65 * @exception If the class Process is not found the function throws
66 * the ClassNotFoundException. If the methos join() of
67 * this class is not found the function throws the exception
68 * NotSuchMethodException.
71 void jprocess_join(jobject jprocess, JNIEnv * env);
74 * This function starts the specified java process.
76 * @param jprocess The java process to start.
77 * @param env The env of the current thread
79 * @exception If the class Process is not found the function throws
80 * the ClassNotFoundException. If the methos start() of
81 * this class is not found the function throws the exception
82 * NotSuchMethodException.
84 void jprocess_start(jobject jprocess, JNIEnv * env);
87 * This function forces the java process to stop.
89 * @param jprocess The java process to stop.
90 * @param env The env of the current thread
92 * @exception If the class Process is not found the function throws
93 * the ClassNotFoundException. If the methos stop() of
94 * this class is not found the function throws the exception
95 * NotSuchMethodException.
97 void jprocess_exit(jobject jprocess, JNIEnv * env);
100 * This function associated a native process to a java process instance.
102 * @param jprocess The java process instance.
103 * @param process The native process to bind.
104 * @param env The env of the current thread
106 * @exception If the class Process is not found the function throws
107 * the ClassNotFoundException. If the field bind of
108 * this class is not found the function throws the exception
109 * NotSuchFieldException.
111 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
114 * This function returns a native process from a java process instance.
116 * @param jprocess The java process object from which get the native process.
117 * @param env The env of the current thread
119 * @return The function returns the native process associated to the
120 * java process object.
122 * @exception If the class Process is not found the function throws
123 * the ClassNotFoundException. If the field bind of
124 * this class is not found the function throws the exception
125 * NotSuchFieldException.
127 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
130 * This function gets the id of the specified java process.
132 * @param jprocess The java process to get the id.
133 * @param env The env of the current thread
135 * @exception If the class Process is not found the function throws
136 * the ClassNotFoundException. If the field id of
137 * this class is not found the function throws the exception
138 * NotSuchFieldException.
140 * @return The id of the specified java process.
142 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
145 * This function tests if a java process instance is valid.
146 * A java process object is valid if it is bind to a native
149 * @param jprocess The java process to test the validity.
150 * @param env The env of the current thread
152 * @return If the java process is valid the function returns true.
153 * Otherwise the function returns false.
155 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
158 * This function gets the name of the specified java process.
160 * @param jprocess The java process to get the name.
161 * @param env The env of the current thread
163 * @exception If the class Process is not found the function throws
164 * the ClassNotFoundException. If the field name of
165 * this class is not found the function throws the exception
166 * NotSuchFieldException.
168 * @return The name of the specified java process.
170 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
173 * This function yields the specified java process.
175 * @param jprocess The java process to yield.
176 * @param env The env of the current thread.
178 * @exception If the class Process is not found the function throws
179 * the ClassNotFoundException. If the method switchProcess of
180 * this class is not found the function throws the exception
181 * NotSuchMethodException.
183 void jprocess_yield(jobject jprocess, JNIEnv * env);
186 * This function locks the mutex of the specified java process.
188 * @param jprocess The java process of the mutex to lock.
189 * @param env The env of the current thread.
191 * @exception If the class Process is not found the function throws
192 * the ClassNotFoundException. If the method lockMutex of
193 * this class is not found the function throws the exception
194 * NotSuchMethodException.
196 void jprocess_lock_mutex(jobject jprocess, JNIEnv * env);
199 * This function unlocks the mutex of the specified java process.
201 * @param jprocess The java process of the mutex to unlock.
202 * @param env The env of the current thread.
204 * @exception If the class Process is not found the function throws
205 * the ClassNotFoundException. If the method unlockMutex of
206 * this class is not found the function throws the exception
207 * NotSuchMethodException.
209 void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env);
212 * This function signals the condition of the mutex of the specified java process.
214 * @param jprocess The java process of the condtion to signal.
215 * @param env The env of the current thread.
217 * @exception If the class Process is not found the function throws
218 * the ClassNotFoundException. If the method signalCond of
219 * this class is not found the function throws the exception
220 * NotSuchMethodException.
222 void jprocess_signal_cond(jobject jprocess, JNIEnv * env);
225 * This function waits the condition of the mutex of the specified java process.
227 * @param jprocess The java process of the condtion to wait for.
228 * @param env The env of the current thread.
230 * @exception If the class Process is not found the function throws
231 * the ClassNotFoundException. If the method waitCond of
232 * this class is not found the function throws the exception
233 * NotSuchMethodException.
235 void jprocess_wait_cond(jobject jprocess, JNIEnv * env);
237 void jprocess_schedule(smx_context_t context);
239 void jprocess_unschedule(smx_context_t context);
242 #endif /* !MSG_JPROCESS_H */