factory should implement */
-typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
- (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
+typedef smx_context_t (*smx_pfn_context_factory_create_context_t)(
+ xbt_main_func_t, int, char **, void_pfn_smxprocess_t, smx_process_t process);
typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
typedef void (*smx_pfn_context_free_t) (smx_context_t);
typedef void (*smx_pfn_context_start_t) (smx_context_t);
typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
typedef void (*smx_pfn_context_runall_t) (void);
typedef smx_context_t (*smx_pfn_context_self_t) (void);
-typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
+typedef smx_process_t (*smx_pfn_context_get_process_t) (smx_context_t context);
/* interface of the context factories */
typedef struct s_smx_context_factory {
smx_pfn_context_suspend_t suspend;
smx_pfn_context_runall_t runall;
smx_pfn_context_self_t self;
- smx_pfn_context_get_data_t get_data;
+ smx_pfn_context_get_process_t get_process;
} s_smx_context_factory_t;
/* Hack: let msg load directly the right factory */
s_xbt_swag_hookup_t hookup;
xbt_main_func_t code;
void_pfn_smxprocess_t cleanup_func;
- void *data; /* Here SIMIX stores the smx_process_t containing the context */
+ smx_process_t process;
char **argv;
int argc;
unsigned iwannadie:1;
XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
XBT_PUBLIC(smx_context_t)
-smx_ctx_base_factory_create_context_sized(size_t size,
- xbt_main_func_t code, int argc,
- char **argv,
+smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code,
+ int argc, char **argv,
void_pfn_smxprocess_t cleanup,
- void* data);
+ smx_process_t process);
XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
-XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
+XBT_PUBLIC(smx_process_t) smx_ctx_base_get_process(smx_context_t context);
XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
static smx_context_t
-smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
- char **argv,
- void_pfn_smxprocess_t cleanup_func,
- void *data);
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code,
+ int argc, char **argv,
+ void_pfn_smxprocess_t cleanup_func,
+ smx_process_t process);
static void smx_ctx_cojava_free(smx_context_t context);
static void smx_ctx_cojava_suspend(smx_context_t context);
(*factory)->name = "ctx_cojava_factory";
//(*factory)->finalize = smx_ctx_base_factory_finalize;
(*factory)->self = smx_ctx_cojava_self;
- (*factory)->get_data = smx_ctx_base_get_data;
+ (*factory)->get_process = smx_ctx_base_get_process;
global_env = get_current_thread_env();
}
static smx_context_t
-smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
- char **argv,
- void_pfn_smxprocess_t cleanup_func,
- void* data)
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code,
+ int argc, char **argv,
+ void_pfn_smxprocess_t cleanup_func,
+ smx_process_t process)
{
smx_ctx_cojava_t context = xbt_new0(s_smx_ctx_cojava_t, 1);
/* If the user provided a function for the process then use it
maestro_context = (smx_context_t)context;
}
context->bound = 0;
- context->super.data = data;
+ context->super.process = process;
return (smx_context_t) context;
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jmsg, bindings, "MSG for Java(TM)");
static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
- char **argv,
+smx_ctx_java_factory_create_context(xbt_main_func_t code,
+ int argc, char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data);
+ smx_process_t process);
static void smx_ctx_java_free(smx_context_t context);
static void smx_ctx_java_suspend(smx_context_t context);
(*factory)->name = "ctx_java_factory";
//(*factory)->finalize = smx_ctx_base_factory_finalize;
(*factory)->self = smx_ctx_java_self;
- (*factory)->get_data = smx_ctx_base_get_data;
+ (*factory)->get_process = smx_ctx_base_get_process;
}
smx_context_t smx_ctx_java_self(void)
{
}
static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
- char **argv,
+smx_ctx_java_factory_create_context(xbt_main_func_t code,
+ int argc, char **argv,
void_pfn_smxprocess_t cleanup_func,
- void* data)
+ smx_process_t process)
{
static int thread_amount=0;
smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
context->thread = NULL;
xbt_os_thread_set_extra_data(context);
}
- context->super.data = data;
+ context->super.process = process;
return (smx_context_t) context;
}
(*factory)->suspend = NULL;
(*factory)->runall = NULL;
(*factory)->self = smx_ctx_base_self;
- (*factory)->get_data = smx_ctx_base_get_data;
+ (*factory)->get_process = smx_ctx_base_get_process;
(*factory)->name = "base context factory";
}
}
smx_context_t
-smx_ctx_base_factory_create_context_sized(size_t size,
- xbt_main_func_t code, int argc,
- char **argv,
+smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code,
+ int argc, char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data)
+ smx_process_t process)
{
smx_context_t context = xbt_malloc0(size);
} else {
SIMIX_context_set_current(context);
}
- context->data = data;
+ context->process = process;
return context;
}
void smx_ctx_base_stop(smx_context_t context)
{
if (context->cleanup_func)
- context->cleanup_func(context->data);
+ context->cleanup_func(context->process);
context->iwannadie = 0;
- simcall_process_cleanup(context->data);
+ simcall_process_cleanup(context->process);
context->iwannadie = 1;
}
return SIMIX_context_get_current();
}
-void *smx_ctx_base_get_data(smx_context_t context)
+smx_process_t smx_ctx_base_get_process(smx_context_t context)
{
- return context->data;
+ return context->process;
}
static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory);
static smx_context_t smx_ctx_raw_create_context(xbt_main_func_t code, int argc,
- char **argv, void_pfn_smxprocess_t cleanup_func, void *data);
+ char **argv, void_pfn_smxprocess_t cleanup_func, smx_process_t process);
static void smx_ctx_raw_free(smx_context_t context);
static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
static void smx_ctx_raw_stop(smx_context_t context);
* \param argv arguments to pass to the main function
* \param cleanup_func a function to call to free the user data when the
* context finished
- * \param data user data
+ * \param process SIMIX process
*/
static smx_context_t
smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
- void_pfn_smxprocess_t cleanup_func,
- void *data)
+ void_pfn_smxprocess_t cleanup_func,
+ smx_process_t process)
{
smx_ctx_raw_t context =
argc,
argv,
cleanup_func,
- data);
+ process);
/* if the user provided a function for the process then use it,
otherwise it is the context for maestro */
#endif /* HAVE_VALGRIND_VALGRIND_H */
} else {
- if(data != NULL && raw_maestro_context==NULL)
+ if(process != NULL && raw_maestro_context==NULL)
raw_maestro_context = context;
if(MC_is_active())
xbt_main_func_t code, int argc,
char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data);
+ smx_process_t process);
static void smx_ctx_sysv_free(smx_context_t context);
static smx_context_t
smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
- void_pfn_smxprocess_t cleanup_func, void* data);
+ void_pfn_smxprocess_t cleanup_func, smx_process_t process);
static void smx_ctx_sysv_wrapper(int count, ...);
smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
int argc, char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data)
+ smx_process_t process)
{
int ctx_addr[CTX_ADDR_LEN];
smx_ctx_sysv_t context =
argc,
argv,
cleanup_func,
- data);
+ process);
/* if the user provided a function for the process then use it,
otherwise it is the context for maestro */
sizeof(smx_ctx_sysv_t), sizeof(int), CTX_ADDR_LEN);
}
} else {
- if(data != NULL && sysv_maestro_context == NULL)
+ if (process != NULL && sysv_maestro_context == NULL)
sysv_maestro_context = context;
}
if(MC_is_active() && code)
- MC_new_stack_area(context, ((smx_process_t)((smx_context_t)context)->data)->name, &(context->uc), size);
+ MC_new_stack_area(context, ((smx_context_t)context)->process->name,
+ &(context->uc), size);
return (smx_context_t) context;
}
static smx_context_t
smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
- void_pfn_smxprocess_t cleanup_func,
- void *data)
+ void_pfn_smxprocess_t cleanup_func,
+ smx_process_t process)
{
- return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) + smx_context_stack_size,
+ return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) +
+ smx_context_stack_size,
code, argc, argv, cleanup_func,
- data);
+ process);
}
static xbt_os_sem_t smx_ctx_thread_sem;
static smx_context_t
-smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
- char **argv,
+smx_ctx_thread_factory_create_context(xbt_main_func_t code,
+ int argc, char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data);
+ smx_process_t process);
static void smx_ctx_thread_free(smx_context_t context);
static void smx_ctx_thread_stop(smx_context_t context);
smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
char **argv,
void_pfn_smxprocess_t cleanup_func,
- void *data)
+ smx_process_t process)
{
smx_ctx_thread_t context = (smx_ctx_thread_t)
smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_thread_t),
code, argc, argv,
- cleanup_func, data);
+ cleanup_func, process);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
}
/**
- \brief returns the data associated to a context
+ \brief returns the SIMIX process associated to a context
\param context The context
- \return The data
+ \return The SIMIX process
*/
-static XBT_INLINE void* SIMIX_context_get_data(smx_context_t context)
+static XBT_INLINE smx_process_t SIMIX_context_get_process(smx_context_t context)
{
- return simix_global->context_factory->get_data(context);
+ return simix_global->context_factory->get_process(context);
}
XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
{
smx_context_t self_context = SIMIX_context_self();
- return self_context ? SIMIX_context_get_data(self_context) : NULL;
+ return self_context ? SIMIX_context_get_process(self_context) : NULL;
}
/**