p Testing a simple master/slave example application handling failures
$ masterslave/masterslave_failure$EXEEXT ${srcdir:=.}/small_platform_with_failures.xml ${srcdir:=.}/masterslave/deployment_masterslave.xml --cfg:path=${srcdir}
-> [0.000000] simix/smx_process.c:92: [simix_process/WARNING] Cannot launch process 'slave' on failed host 'Fafard'
+> [0.000000] simix/smx_process.c:100: [simix_process/WARNING] Cannot launch process 'slave' on failed host 'Fafard'
> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Got 5 slave(s) :
> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Jupiter
> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Fafard
#include "xbt/dict.h"
#include "xbt/config.h"
#include "xbt/function_types.h"
+#include "xbt/ex_interface.h"
/******************************** Datatypes ***********************************/
char *name; /**< @brief process name if any */
smx_host_t smx_host; /* the host on which the process is running */
smx_context_t context; /* the context that executes the scheduler function */
+ ex_ctx_t *exception;
int blocked : 1;
int suspended : 1;
int iwannadie : 1;
xbt_dict_t properties;
} s_smx_process_arg_t, *smx_process_arg_t;
+void SIMIX_create_maestro_process(void);
void SIMIX_process_empty_trash(void);
-void __SIMIX_process_schedule(smx_process_t process);
-void __SIMIX_process_yield(void);
+void SIMIX_process_schedule(smx_process_t process);
+void SIMIX_process_yield(void);
+ex_ctx_t *SIMIX_process_get_exception(void);
+void SIMIX_process_exception_terminate(xbt_ex_t * e);
+
/*************************** Mutex and Conditional ****************************/
void __SIMIX_cond_wait(smx_cond_t cond);
void __SIMIX_cond_display_actions(smx_cond_t cond);
void __SIMIX_action_display_conditions(smx_action_t action);
-void __SIMIX_create_maestro_process(void);
/******************************** Context *************************************/
/* each context type must contain this macro at its begining -- OOP in C :/ */
#define SMX_CTX_BASE_T \
s_xbt_swag_hookup_t hookup; \
- ex_ctx_t *exception; \
xbt_main_func_t code; \
int argc; \
char **argv; \
/* init the desired factory */
SIMIX_context_init_factory_by_name(&simix_global->context_factory, name);
- __SIMIX_create_maestro_process ();
+ SIMIX_create_maestro_process ();
return 0;
}
#include "xbt/function_types.h"
-#include "xbt/ex_interface.h"
#include "private.h"
#include "smx_context_java.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(jmsg, "MSG for Java(TM)");
-/* callback: context fetching */
-static ex_ctx_t *xbt_ctx_java_ex_ctx(void);
-
-/* callback: termination */
-static void xbt_ctx_java_ex_terminate(xbt_ex_t * e);
-
static smx_context_t
smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, char** argv,
void_f_pvoid_t cleanup_func, void* cleanup_arg);
static void
smx_ctx_java_resume(smx_context_t old_context, smx_context_t new_context);
-
-/* callback: context fetching */
-static ex_ctx_t *xbt_ctx_java_ex_ctx(void)
-{
- return simix_global->current_process->context->exception;
-}
-
-/* callback: termination */
-static void xbt_ctx_java_ex_terminate(xbt_ex_t * e)
-{
- xbt_ex_display(e);
- abort();
-}
-
void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory)
{
- /* context exception handlers */
- __xbt_ex_ctx = xbt_ctx_java_ex_ctx;
- __xbt_ex_terminate = xbt_ctx_java_ex_terminate;
-
/* instantiate the context factory */
*factory = xbt_new0(s_smx_context_factory_t, 1);
{
free(*factory);
*factory = NULL;
-
- /* Restore the default exception setup */
- __xbt_ex_ctx = &__xbt_ex_ctx_default;
- __xbt_ex_terminate = &__xbt_ex_terminate_default;
-
return 0;
}
{
smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
- context->exception = xbt_new(ex_ctx_t, 1);
- XBT_CTX_INITIALIZE(context->exception);
-
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
if(code){
jprocess_join(jprocess, get_current_thread_env());
}
- if (ctx_java->exception)
- free(ctx_java->exception);
-
free(context);
context = NULL;
}
/* 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 "xbt/ex_interface.h"
#include "private.h"
#include "context_sysv_config.h" /* loads context system definitions */
#include "portable.h"
#endif
} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
-
-/* callback: context fetching */
-static ex_ctx_t *xbt_jcontext_ex_ctx(void);
-
-/* callback: termination */
-static void xbt_jcontext_ex_terminate(xbt_ex_t *e);
-
static smx_context_t
smx_ctx_sysv_factory_create_context(xbt_main_func_t code, int argc, char** argv,
void_f_pvoid_t cleanup_func, void* cleanup_arg);
static void smx_ctx_sysv_wrapper(void);
-/* callback: context fetching */
-static ex_ctx_t *xbt_ctx_sysv_ex_ctx(void)
-{
- /*FIXME: the factory should access simix level datastructures! */
- return simix_global->current_process->context->exception;
-}
-
-/* callback: termination */
-static void xbt_ctx_sysv_ex_terminate(xbt_ex_t * e)
-{
- xbt_ex_display(e);
- abort();
-}
-
void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory)
{
*factory = xbt_new0(s_smx_context_factory_t, 1);
(*factory)->suspend = smx_ctx_sysv_suspend;
(*factory)->resume = smx_ctx_sysv_resume;
(*factory)->name = "smx_sysv_context_factory";
-
- /* context exception handlers */
- __xbt_ex_ctx = xbt_ctx_sysv_ex_ctx;
- __xbt_ex_terminate = xbt_ctx_sysv_ex_terminate;
}
static int smx_ctx_sysv_factory_finalize(smx_context_factory_t * factory)
{
free(*factory);
*factory = NULL;
-
- /* Restore the default exception setup */
- __xbt_ex_ctx = &__xbt_ex_ctx_default;
- __xbt_ex_terminate = &__xbt_ex_terminate_default;
-
return 0;
}
void_f_pvoid_t cleanup_func, void* cleanup_arg)
{
smx_ctx_sysv_t context = xbt_new0(s_smx_ctx_sysv_t, 1);
-
- context->exception = xbt_new(ex_ctx_t, 1);
- XBT_CTX_INITIALIZE(context->exception);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
smx_ctx_sysv_t context = (smx_ctx_sysv_t)pcontext;
if (context){
- if (context->exception)
- free(context->exception);
-
#ifdef HAVE_VALGRIND_VALGRIND_H
VALGRIND_STACK_DEREGISTER(((smx_ctx_sysv_t) context)->valgrind_stack_id);
#endif /* HAVE_VALGRIND_VALGRIND_H */
void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory)
{
- /* Initialize the thread portability layer
- xbt_os_thread_mod_init();*/
-
*factory = xbt_new0(s_smx_context_factory_t, 1);
(*factory)->create_context = smx_ctx_thread_factory_create_context;
static int smx_ctx_thread_factory_finalize(smx_context_factory_t * factory)
{
- /* Stop the thread portability layer
- xbt_os_thread_mod_exit();*/
free(*factory);
*factory = NULL;
return 0;
simix_global->cleanup_process_function = SIMIX_process_cleanup;
SIMIX_context_mod_init();
- __SIMIX_create_maestro_process();
+ SIMIX_create_maestro_process();
+
+ /* context exception handlers */
+ __xbt_ex_ctx = SIMIX_process_get_exception;
+ __xbt_ex_terminate = SIMIX_process_exception_terminate;
+
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
/* Let's free maestro now */
SIMIX_context_free(simix_global->maestro_process->context);
- free(simix_global->maestro_process);
+ xbt_free(simix_global->maestro_process->exception);
+ xbt_free(simix_global->maestro_process);
simix_global->maestro_process = NULL;
+
+ /* Restore the default exception setup */
+ __xbt_ex_ctx = &__xbt_ex_ctx_default;
+ __xbt_ex_terminate = &__xbt_ex_terminate_default;
/* Finish context module and SURF */
SIMIX_context_mod_exit();
+
surf_exit();
- free(simix_global);
+ xbt_free(simix_global);
simix_global = NULL;
return;
while ((process = xbt_swag_extract(simix_global->process_to_run))) {
DEBUG2("Scheduling %s on %s", process->name, process->smx_host->name);
- __SIMIX_process_schedule(process);
+ SIMIX_process_schedule(process);
}
{
while ((process = xbt_swag_extract(simix_global->process_to_destroy))){
SIMIX_context_free(process->context);
+
+ /* Free the exception allocated at creation time */
+ if (process->exception)
+ free(process->exception);
+
free(process->name);
process->name = NULL;
free(process);
/**
* \brief Creates and runs the maestro process
*/
-void __SIMIX_create_maestro_process()
+void SIMIX_create_maestro_process()
{
smx_process_t process = NULL;
process = xbt_new0(s_smx_process_t, 1);
/* Process data */
process->name = (char *)"";
+ process->exception = xbt_new(ex_ctx_t, 1);
+ XBT_CTX_INITIALIZE(process->exception);
+
/* Create a dummy context for maestro */
process->context = SIMIX_context_new(NULL, 0, NULL, NULL, NULL);
process->mutex = NULL;
process->cond = NULL;
process->iwannadie = 0;
-
+ process->data = data;
+
VERB1("Create context %s", process->name);
process->context = SIMIX_context_new(code, argc, argv,
simix_global->cleanup_process_function,
process);
-
- process->data = data;
+
+ process->exception = xbt_new(ex_ctx_t, 1);
+ XBT_CTX_INITIALIZE(process->exception);
/* Add properties */
process->properties = properties;
if (process == SIMIX_process_self())
SIMIX_context_stop(process->context);
else
- __SIMIX_process_schedule(process);
+ SIMIX_process_schedule(process);
}
* Only the processes can call this function, giving back the control
* to the maestro
*/
-void __SIMIX_process_yield(void)
+void SIMIX_process_yield(void)
{
DEBUG1("Yield process '%s'", simix_global->current_process->name);
xbt_assert0((simix_global->current_process != simix_global->maestro_process),
SIMIX_context_stop(simix_global->current_process->context);
}
-void __SIMIX_process_schedule(smx_process_t new_process)
+void SIMIX_process_schedule(smx_process_t new_process)
{
DEBUG1("Scheduling context: '%s'", new_process->name);
/* restore the current process to the previously saved process */
simix_global->current_process = old_process;
}
+
+/* callback: context fetching */
+ex_ctx_t *SIMIX_process_get_exception(void)
+{
+ return simix_global->current_process->exception;
+}
+
+/* callback: termination */
+void SIMIX_process_exception_terminate(xbt_ex_t * e)
+{
+ xbt_ex_display(e);
+ abort();
+}
+
+
xbt_swag_insert(self, mutex->sleeping);
self->mutex = mutex;
/* wait for some process make the unlock and wake up me from mutex->sleeping */
- __SIMIX_process_yield();
+ SIMIX_process_yield();
self->mutex = NULL;
/* verify if the process was suspended */
while (self->suspended) {
- __SIMIX_process_yield();
+ SIMIX_process_yield();
}
mutex->refcount = 1;
self->cond = cond;
xbt_swag_insert(self, cond->sleeping);
- __SIMIX_process_yield();
+ SIMIX_process_yield();
self->cond = NULL;
while (self->suspended) {
- __SIMIX_process_yield();
+ SIMIX_process_yield();
}
return;