X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1b1016c3ad9e396286bf2c692c92cf5fd567b1d3..76d868f42e7824432bff8778aaf4d63e6d01a941:/src/simix/smx_global.c diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 6e9174ad43..fffa264b77 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -24,8 +24,6 @@ static void* SIMIX_action_mallocator_new_f(void); static void SIMIX_action_mallocator_free_f(void* action); static void SIMIX_action_mallocator_reset_f(void* action); -static void SIMIX_clean(void); - /* FIXME: Yeah, I'll do it in a portable maner one day [Mt] */ #include @@ -42,11 +40,17 @@ static void _XBT_CALL inthandler(int ignored) exit(1); } +#ifndef WIN32 static void _XBT_CALL segvhandler(int signum, siginfo_t *siginfo, void *context) { if (siginfo->si_signo == SIGSEGV && siginfo->si_code == SEGV_ACCERR) { fprintf(stderr, - "Access violation detected. This can result from a stack overflow.\n" + "Access violation detected.\n" + "This can result from a programming error in your code or, although less likely,\n" + "from a bug in SimGrid itself. This can also be the sign of a bug in the OS or\n" + "in third-party libraries. Failing hardware can sometimes generate such errors\n" + "too.\n" + "Finally, if nothing of the above applies, this can result from a stack overflow.\n" "Try to increase stack size with --cfg=contexts/stack_size (current size is %d KiB).\n", smx_context_stack_size / 1024); if (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_debug)) { @@ -100,6 +104,7 @@ static void install_segvhandler(void) } } +#endif /********************************* SIMIX **************************************/ XBT_INLINE double SIMIX_timer_next(void) @@ -157,9 +162,10 @@ void SIMIX_global_init(int *argc, char **argv) /* Prepare to display some more info when dying on Ctrl-C pressing */ signal(SIGINT, inthandler); +#ifndef WIN32 /* Install SEGV handler */ install_segvhandler(); - +#endif /* register a function to be called by SURF after the environment creation */ sg_platf_init(); sg_platf_postparse_add_cb(SIMIX_post_create_environment); @@ -185,12 +191,14 @@ void SIMIX_global_init(int *argc, char **argv) * * This functions remove the memory used by SIMIX */ -static void SIMIX_clean(void) +void SIMIX_clean(void) { + static int cleaned = 0; #ifdef TIME_BENCH_PER_SR smx_ctx_raw_new_sr(); #endif - + if (cleaned) return; // to avoid double cleaning by java and C + cleaned = 1; /* Kill everyone (except maestro) */ SIMIX_process_killall(simix_global->maestro_process, 1); @@ -378,7 +386,7 @@ void SIMIX_run(void) /* Handle any pending timer */ while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) { //FIXME: make the timers being real callbacks - // (i.e. provide dispatchers that read and expand the args) + // (i.e. provide dispatchers that read and expand the args) timer = xbt_heap_pop(simix_timers); if (timer->func) ((void (*)(void*))timer->func)(timer->args); @@ -412,7 +420,7 @@ void SIMIX_run(void) XBT_DEBUG("### time %f, empty %d", time, xbt_dynar_is_empty(simix_global->process_to_run)); - // !(time == -1.0 && xbt_dynar_is_empty()) + // !(time == -1.0 && xbt_dynar_is_empty()) } while (time != -1.0 || !xbt_dynar_is_empty(simix_global->process_to_run));