summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cebb892)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/contrib/trunk/simgrid-java@8968
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "msg/msg.h"
-#include "simix/context.h"
+#include <msg/msg.h>
+#include <simix/context.h>
+#include <surf/surfxml_parse.h>
+
#include "smx_context_java.h"
#include "jmsg_process.h"
#include "smx_context_java.h"
#include "jmsg_process.h"
#include "jxbt_utilities.h"
#include "jmsg.h"
#include "jxbt_utilities.h"
#include "jmsg.h"
-#include "surf/surfxml_parse.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
/* get the C string from the java string */
const char *name = (*env)->GetStringUTFChars(env, jname, 0);
/* get the C string from the java string */
const char *name = (*env)->GetStringUTFChars(env, jname, 0);
+ DEBUG1("Looking for host '%s'",name);
/* get the host by name (the hosts are created during the grid resolution) */
host = MSG_get_host_by_name(name);
/* get the host by name (the hosts are created during the grid resolution) */
host = MSG_get_host_by_name(name);
- DEBUG2("MSG gave %p as native host (simdata=%p)", host, host->simdata);
-
- (*env)->ReleaseStringUTFChars(env, jname, name);
+ DEBUG2("MSG gave %p as native host (simdata=%p)", host,host? host->simdata:NULL);
if (!host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
if (!host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+ (*env)->ReleaseStringUTFChars(env, jname, name);
if (!MSG_host_get_data(host)) { /* native host not associated yet with java host */
if (!MSG_host_get_data(host)) { /* native host not associated yet with java host */
jobject jhost;
/* Run everything */
jobject jhost;
/* Run everything */
+ INFO0("Ready to run MSG_MAIN");
+ INFO0("Done running MSG_MAIN");
jxbt_check_res("MSG_main()", rv, MSG_OK,
bprintf
("unexpected error : MSG_main() failed .. please report this bug "));
jxbt_check_res("MSG_main()", rv, MSG_OK,
bprintf
("unexpected error : MSG_main() failed .. please report this bug "));
- DEBUG0
- ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
+ INFO0("MSG_main finished");
- DEBUG0("Clean java world");
+ INFO0("Clean java world");
/* Cleanup java hosts */
hosts = MSG_get_host_table();
for (index = 0; index < MSG_get_host_number() - 1; index++) {
/* Cleanup java hosts */
hosts = MSG_get_host_table();
for (index = 0; index < MSG_get_host_number() - 1; index++) {
- DEBUG0("Clean native world");
+ INFO0("Clean native world");
/* cleanup native stuff */
rv = MSG_OK != MSG_clean();
jxbt_check_res("MSG_clean()", rv, MSG_OK,
/* cleanup native stuff */
rv = MSG_OK != MSG_clean();
jxbt_check_res("MSG_clean()", rv, MSG_OK,
env = get_current_thread_env();
env = get_current_thread_env();
- id = jxbt_get_smethod(env, "simgrid/msg/Process", "schedule", "()V");
+ id = jxbt_get_smethod(env, "org/simgrid/msg/Process", "schedule", "()V");
+ if (!id) {
+ CRITICAL0("Cannot find java method org/simgrid/msg/Process/schedule()V");
(*env)->CallVoidMethod(env, ((smx_ctx_java_t) context)->jprocess, id);
}
(*env)->CallVoidMethod(env, ((smx_ctx_java_t) context)->jprocess, id);
}
void_pfn_smxprocess_t cleanup_func,
void* data)
{
void_pfn_smxprocess_t cleanup_func,
void* data)
{
+ fprintf(stderr,"XXXX Create Context\n");
smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
/* If the user provided a function for the process then use it
smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
/* If the user provided a function for the process then use it
static void smx_ctx_java_stop(smx_context_t context)
{
jobject jprocess = NULL;
static void smx_ctx_java_stop(smx_context_t context)
{
jobject jprocess = NULL;
+ fprintf(stderr,"XXXX Context Stop\n");
ctx_java = (smx_ctx_java_t) context;
ctx_java = (smx_ctx_java_t) context;
- /*FIXME: is this really necessary? DIRTY HACK: let's comment it and see*/
-// if (((smx_process_t)smx_current_context->data)->iwannadie) {
+ /*FIXME: is this really necessary? Seems to. */
+ if (smx_current_context->iwannadie) {
+ INFO0("I wannadie");
/* The maestro call xbt_context_stop() with an exit code set to one */
if (ctx_java->jprocess) {
/* if the java process is alive schedule it */
/* The maestro call xbt_context_stop() with an exit code set to one */
if (ctx_java->jprocess) {
/* if the java process is alive schedule it */
jprocess_exit(jprocess, get_current_thread_env());
}
}
jprocess_exit(jprocess, get_current_thread_env());
}
}
/* the java process exits */
/* the java process exits */
-// jprocess = ctx_java->jprocess;
-// ctx_java->jprocess = NULL;
-// }
+ jprocess = ctx_java->jprocess;
+ ctx_java->jprocess = NULL;
+ }
/* delete the global reference associated with the java process */
jprocess_delete_global_ref(jprocess, get_current_thread_env());
}
/* delete the global reference associated with the java process */
jprocess_delete_global_ref(jprocess, get_current_thread_env());
}
-/*static void smx_ctx_java_swap(smx_context_t context)
-{
- if (context) {
- smx_context_t self = current_context;
-
- current_context = context;
-
- jprocess_schedule(context);
-
- current_context = self;
- }
-
- if (current_context->iwannadie)
- smx_ctx_java_stop(1);
-}*/
-
static void smx_ctx_java_suspend(smx_context_t context)
{
jprocess_unschedule(context);
static void smx_ctx_java_suspend(smx_context_t context)
{
jprocess_unschedule(context);
// FIXME: inline those functions
static void smx_ctx_java_resume(smx_context_t new_context)
{
// FIXME: inline those functions
static void smx_ctx_java_resume(smx_context_t new_context)
{
+ fprintf(stderr,"XXXX Context Resume\n");
jprocess_schedule(new_context);
}
jprocess_schedule(new_context);
}
{
smx_process_t process;
smx_context_t old_context;
{
smx_process_t process;
smx_context_t old_context;
+ fprintf(stderr,"XXXX Run all\n");
+
while ((process = xbt_swag_extract(processes))) {
old_context = smx_current_context;
smx_current_context = SIMIX_process_get_context(process);
smx_ctx_java_resume(smx_current_context);
smx_current_context = old_context;
}
while ((process = xbt_swag_extract(processes))) {
old_context = smx_current_context;
smx_current_context = SIMIX_process_get_context(process);
smx_ctx_java_resume(smx_current_context);
smx_current_context = old_context;
}
+ fprintf(stderr,"XXXX End of run all\n");