specific flag on smx_context_java.
It lets us now use a "process_kill" naturally :).
(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos) {
double time = jmillis / 1000 + jnanos / 1000;
(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos) {
double time = jmillis / 1000 + jnanos / 1000;
-
- MSG_error_t rv = MSG_process_sleep(time);
- jxbt_check_res("MSG_process_sleep()", rv, MSG_OK,
+ MSG_error_t rv;
+ TRY {
+ rv = MSG_process_sleep(time);
+ }
+ CATCH_ANONYMOUS {
+ return;
+ }
+ jxbt_check_res("MSG_process_sleep()", rv, MSG_OK,
bprintf("unexpected error , please report this bug"));
}
JNIEXPORT void JNICALL
bprintf("unexpected error , please report this bug"));
}
JNIEXPORT void JNICALL
jxbt_throw_notbound(env, "process", jprocess);
return;
}
jxbt_throw_notbound(env, "process", jprocess);
return;
}
- MSG_error_t rv = MSG_process_sleep((double)jseconds);
+ MSG_error_t rv;
+ TRY {
+ rv = MSG_process_sleep((double)jseconds);
+ }
+ CATCH_ANONYMOUS {
+ return;
+ }
if (rv != MSG_OK) {
// smx_ctx_java_stop(smx_ctx_java_self());
}
if (rv != MSG_OK) {
// smx_ctx_java_stop(smx_ctx_java_self());
}
jxbt_throw_notbound(env, "process", jprocess);
return;
}
jxbt_throw_notbound(env, "process", jprocess);
return;
}
- /* Sets the "killed" flag to kill the process on the next unschedule */
- smx_ctx_java_t context = (smx_ctx_java_t)MSG_process_get_smx_ctx(process);
- context->killed = 1;
MSG_process_kill(process);
}
MSG_process_kill(process);
}
context->jprocess = (jobject) code;
context->begin = xbt_os_sem_init(0);
context->end = xbt_os_sem_init(0);
context->jprocess = (jobject) code;
context->begin = xbt_os_sem_init(0);
context->end = xbt_os_sem_init(0);
context->thread = xbt_os_thread_create(NULL,smx_ctx_java_thread_run,context,NULL);
}
else {
context->thread = xbt_os_thread_create(NULL,smx_ctx_java_thread_run,context,NULL);
}
else {
xbt_assert(context == my_current_context,
"The context to stop must be the current one");
/* I am the current process and I am dying */
xbt_assert(context == my_current_context,
"The context to stop must be the current one");
/* I am the current process and I am dying */
- if (ctx_java->killed == 1) {
- ctx_java->killed = 0;
+ if (context->iwannadie == -1) {
+ context->iwannadie = 0;
JNIEnv *env = get_current_thread_env();
jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process killed :)"));
THROWF(cancel_error, 0, "process cancelled");
JNIEnv *env = get_current_thread_env();
jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process killed :)"));
THROWF(cancel_error, 0, "process cancelled");
xbt_os_thread_t thread;
xbt_os_sem_t begin; /* this semaphore is used to schedule/yield the process */
xbt_os_sem_t end; /* this semaphore is used to schedule/unschedule the process */
xbt_os_thread_t thread;
xbt_os_sem_t begin; /* this semaphore is used to schedule/yield the process */
xbt_os_sem_t end; /* this semaphore is used to schedule/unschedule the process */
} s_smx_ctx_java_t, *smx_ctx_java_t;
void SIMIX_ctx_java_factory_init(smx_context_factory_t *factory);
} s_smx_ctx_java_t, *smx_ctx_java_t;
void SIMIX_ctx_java_factory_init(smx_context_factory_t *factory);