From: Jonathan Rouzaud-Cornabas Date: Thu, 11 Oct 2012 15:38:44 +0000 (+0200) Subject: Fix an issue in smx_ctx_cojava_runall ie do not try to run when no process exists X-Git-Tag: v3_9_90~569^2~19^2~8^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/695f327338ceecd86325a8a0cf18b8c3ab67f8cb Fix an issue in smx_ctx_cojava_runall ie do not try to run when no process exists --- diff --git a/examples/masterslave/masterslaveDeployment.xml b/examples/masterslave/masterslaveDeployment.xml index 6c01ac0120..7794206c2c 100644 --- a/examples/masterslave/masterslaveDeployment.xml +++ b/examples/masterslave/masterslaveDeployment.xml @@ -2,7 +2,7 @@ - + diff --git a/src/smx_context_cojava.c b/src/smx_context_cojava.c index 42c655e067..4e43ef7694 100644 --- a/src/smx_context_cojava.c +++ b/src/smx_context_cojava.c @@ -83,6 +83,7 @@ void SIMIX_ctx_cojava_factory_init(smx_context_factory_t * factory) jclass class_thread = (*global_env)->FindClass(global_env, "java/lang/Thread"); xbt_assert((class_thread != NULL), "Can't find java.lang.Thread class"); + jclass class_coroutine_support = (*global_env)->FindClass(global_env, "java/dyn/CoroutineSupport"); xbt_assert((class_coroutine_support != NULL), "Can't find java.dyn.CoroutineSupport class"); jmethodID thread_get_current = (*global_env)->GetStaticMethodID(global_env, class_thread, "currentThread", "()Ljava/lang/Thread;"); @@ -244,10 +245,12 @@ static void smx_ctx_cojava_runall(void) { cojava_processes = SIMIX_process_get_runnable(); smx_process_t process; - process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t); - cojava_process_index = 1; - /* Execute the first process */ - smx_ctx_cojava_resume(SIMIX_process_get_context(process)); + if (xbt_dynar_length(cojava_processes) > 0) { + process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t); + cojava_process_index = 1; + /* Execute the first process */ + smx_ctx_cojava_resume(SIMIX_process_get_context(process)); + } } static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context) {