git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7303
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
@ingroup m_datatypes_management_details @{ */
typedef struct s_smx_process {
s_xbt_swag_hookup_t process_hookup;
@ingroup m_datatypes_management_details @{ */
typedef struct s_smx_process {
s_xbt_swag_hookup_t process_hookup;
- s_xbt_swag_hookup_t synchro_hookup;
+ s_xbt_swag_hookup_t synchro_hookup; /* process_to_run or mutex->sleeping and co */
s_xbt_swag_hookup_t host_proc_hookup;
s_xbt_swag_hookup_t destroy_hookup;
s_xbt_swag_hookup_t host_proc_hookup;
s_xbt_swag_hookup_t destroy_hookup;
typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
/* function used to resume the current context */
typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
/* function used to resume the current context */
-typedef void (*smx_pfn_context_resume_t) (smx_context_t old_context,
- smx_context_t new_context);
+typedef void (*smx_pfn_context_resume_t) (smx_context_t new_context);
/* interface of the context factories */
typedef struct s_smx_context_factory {
/* interface of the context factories */
typedef struct s_smx_context_factory {
\param old_context the actual context from which is resuming
\param new_context the context to resume
*/
\param old_context the actual context from which is resuming
\param new_context the context to resume
*/
-static inline void SIMIX_context_resume(smx_context_t old_context,
- smx_context_t new_context)
+static inline void SIMIX_context_resume(smx_context_t new_context)
- (*(simix_global->context_factory->resume)) (old_context, new_context);
+ (*(simix_global->context_factory->resume)) (new_context);
static int smx_ctx_java_factory_finalize(smx_context_factory_t * factory);
static void smx_ctx_java_free(smx_context_t context);
static int smx_ctx_java_factory_finalize(smx_context_factory_t * factory);
static void smx_ctx_java_free(smx_context_t context);
static void smx_ctx_java_start(smx_context_t context);
static void smx_ctx_java_start(smx_context_t context);
static void smx_ctx_java_stop(smx_context_t context);
static void smx_ctx_java_stop(smx_context_t context);
static void smx_ctx_java_suspend(smx_context_t context);
static void smx_ctx_java_suspend(smx_context_t context);
-
-static void
- smx_ctx_java_resume(smx_context_t old_context, smx_context_t new_context);
+static void smx_ctx_java_resume(smx_context_t new_context);
void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory)
{
void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory)
{
jprocess_unschedule(context);
}
jprocess_unschedule(context);
}
+// FIXME: inline those functions
-smx_ctx_java_resume(smx_context_t old_context, smx_context_t new_context)
+smx_ctx_java_resume(smx_context_t new_context)
{
jprocess_schedule(new_context);
}
{
jprocess_schedule(new_context);
}
void_f_pvoid_t cleanup_func, void* cleanup_arg);
static int smx_ctx_lua_factory_finalize(smx_context_factory_t *factory);
void_f_pvoid_t cleanup_func, void* cleanup_arg);
static int smx_ctx_lua_factory_finalize(smx_context_factory_t *factory);
static void smx_ctx_lua_free(smx_context_t context);
static void smx_ctx_lua_stop(smx_context_t context);
static void smx_ctx_lua_suspend(smx_context_t context);
static void smx_ctx_lua_free(smx_context_t context);
static void smx_ctx_lua_stop(smx_context_t context);
static void smx_ctx_lua_suspend(smx_context_t context);
-
-static void
-smx_ctx_lua_resume(smx_context_t old_context, smx_context_t new_context);
+static void smx_ctx_lua_resume(smx_context_t new_context);
static void smx_ctx_sysv_wrapper(void);
static void smx_ctx_sysv_wrapper(void);
-smx_ctx_lua_resume(smx_context_t old_context, smx_context_t new_context) {
+smx_ctx_lua_resume(smx_context_t new_context) {
smx_ctx_lua_t context = (smx_ctx_lua_t)new_context;
DEBUG1("Resuming %s",context->argv[0]);
int ret = lua_resume(context->state,context->nargs);
smx_ctx_lua_t context = (smx_ctx_lua_t)new_context;
DEBUG1("Resuming %s",context->argv[0]);
int ret = lua_resume(context->state,context->nargs);
/* interface of the context factories */
typedef struct s_smx_context_factory {
/* interface of the context factories */
typedef struct s_smx_context_factory {
- smx_pfn_context_factory_create_maestro_context_t create_maestro_context;
smx_pfn_context_factory_create_context_t create_context;
smx_pfn_context_factory_finalize_t finalize;
smx_pfn_context_free_t free;
smx_pfn_context_factory_create_context_t create_context;
smx_pfn_context_factory_finalize_t finalize;
smx_pfn_context_free_t free;
static void smx_ctx_ruby_free(smx_context_t context);
static void smx_ctx_ruby_stop(smx_context_t context);
static void smx_ctx_ruby_suspend(smx_context_t context);
static void smx_ctx_ruby_free(smx_context_t context);
static void smx_ctx_ruby_stop(smx_context_t context);
static void smx_ctx_ruby_suspend(smx_context_t context);
-static void
-smx_ctx_ruby_resume(smx_context_t old_context,smx_context_t new_context);
+static void smx_ctx_ruby_resume(smx_context_t new_context);
static void smx_ctx_ruby_wrapper(void);
static void smx_ctx_ruby_wrapper(void);
rb_process_unschedule(ctx_ruby->process);
}
rb_process_unschedule(ctx_ruby->process);
}
-static void smx_ctx_ruby_resume(smx_context_t old_context,smx_context_t new_context) {
- DEBUG2("smx_ctx_ruby_resume(%s,%s)",
- (old_context->argc?old_context->argv[0]:"maestro"),
+static void smx_ctx_ruby_resume(smx_context_t new_context) {
+ DEBUG1("smx_ctx_ruby_resume(%s)",
(new_context->argc?new_context->argv[0]:"maestro"));
smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context;
(new_context->argc?new_context->argv[0]:"maestro"));
smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context;
SMX_CTX_BASE_T;
ucontext_t uc; /* the thread that execute the code */
char stack[STACK_SIZE]; /* the thread stack size */
SMX_CTX_BASE_T;
ucontext_t uc; /* the thread that execute the code */
char stack[STACK_SIZE]; /* the thread stack size */
- struct s_smx_ctx_sysv *prev; /* the previous process */
#ifdef HAVE_VALGRIND_VALGRIND_H
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
#ifdef HAVE_VALGRIND_VALGRIND_H
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
static int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory);
static void smx_ctx_sysv_free(smx_context_t context);
static int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory);
static void smx_ctx_sysv_free(smx_context_t context);
static void smx_ctx_sysv_stop(smx_context_t context);
static void smx_ctx_sysv_stop(smx_context_t context);
static void smx_ctx_sysv_suspend(smx_context_t context);
static void smx_ctx_sysv_suspend(smx_context_t context);
-
-static void
-smx_ctx_sysv_resume(smx_context_t old_context, smx_context_t new_context);
+static void smx_ctx_sysv_resume(smx_context_t new_context);
static void smx_ctx_sysv_wrapper(void);
static void smx_ctx_sysv_wrapper(void);
smx_ctx_sysv_stop((smx_context_t)context);
}
smx_ctx_sysv_stop((smx_context_t)context);
}
-static void smx_ctx_sysv_suspend(smx_context_t context)
-{
+static void smx_ctx_sysv_suspend(smx_context_t context) {
+ ucontext_t maestro_ctx = ((smx_ctx_sysv_t)simix_global->maestro_process->context)->uc;
- smx_ctx_sysv_t prev_context = ((smx_ctx_sysv_t) context)->prev;
-
- ((smx_ctx_sysv_t) context)->prev = NULL;
-
- rv = swapcontext(&((smx_ctx_sysv_t) context)->uc, &prev_context->uc);
+ rv = swapcontext(&((smx_ctx_sysv_t) context)->uc, &maestro_ctx);
xbt_assert0((rv == 0), "Context swapping failure");
}
static void
xbt_assert0((rv == 0), "Context swapping failure");
}
static void
-smx_ctx_sysv_resume(smx_context_t old_context, smx_context_t new_context)
-{
+smx_ctx_sysv_resume(smx_context_t new_context) {
+ smx_ctx_sysv_t maestro = (smx_ctx_sysv_t)simix_global->maestro_process->context;
- ((smx_ctx_sysv_t) new_context)->prev = (smx_ctx_sysv_t)old_context;
-
- rv = swapcontext(&((smx_ctx_sysv_t)old_context)->uc,
- &((smx_ctx_sysv_t)new_context)->uc);
+ rv = swapcontext(&(maestro->uc), &((smx_ctx_sysv_t)new_context)->uc);
xbt_assert0((rv == 0), "Context swapping failure");
}
xbt_assert0((rv == 0), "Context swapping failure");
}
static void smx_ctx_thread_free(smx_context_t context);
static void smx_ctx_thread_stop(smx_context_t context);
static void smx_ctx_thread_suspend(smx_context_t context);
static void smx_ctx_thread_free(smx_context_t context);
static void smx_ctx_thread_stop(smx_context_t context);
static void smx_ctx_thread_suspend(smx_context_t context);
-
-static void
- smx_ctx_thread_resume(smx_context_t old_context, smx_context_t new_context);
+static void smx_ctx_thread_resume(smx_context_t new_context);
static void *smx_ctx_thread_wrapper(void *param);
static void *smx_ctx_thread_wrapper(void *param);
(*factory)->create_context = smx_ctx_thread_factory_create_context;
(*factory)->finalize = smx_ctx_thread_factory_finalize;
(*factory)->free = smx_ctx_thread_free;
(*factory)->create_context = smx_ctx_thread_factory_create_context;
(*factory)->finalize = smx_ctx_thread_factory_finalize;
(*factory)->free = smx_ctx_thread_free;
- (*factory)->start = smx_ctx_thread_start;
(*factory)->stop = smx_ctx_thread_stop;
(*factory)->suspend = smx_ctx_thread_suspend;
(*factory)->resume = smx_ctx_thread_resume;
(*factory)->stop = smx_ctx_thread_stop;
(*factory)->suspend = smx_ctx_thread_suspend;
(*factory)->resume = smx_ctx_thread_resume;
/* NOTE: The first argument to xbt_os_thread_create used to be the process *
* name, but now the name is stored at SIMIX level, so we pass a null */
context->thread =
/* NOTE: The first argument to xbt_os_thread_create used to be the process *
* name, but now the name is stored at SIMIX level, so we pass a null */
context->thread =
- xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, ctx_thread);
+ xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, context);
/* wait the starting of the newly created process */
xbt_os_sem_acquire(context->end);
/* wait the starting of the newly created process */
xbt_os_sem_acquire(context->end);
-static void smx_ctx_thread_suspend(smx_context_t context)
-{
+static void smx_ctx_thread_suspend(smx_context_t context) {
xbt_os_sem_release(((smx_ctx_thread_t) context)->end);
xbt_os_sem_acquire(((smx_ctx_thread_t) context)->begin);
}
xbt_os_sem_release(((smx_ctx_thread_t) context)->end);
xbt_os_sem_acquire(((smx_ctx_thread_t) context)->begin);
}
-static void smx_ctx_thread_resume(smx_context_t not_used,
- smx_context_t new_context)
-{
+static void smx_ctx_thread_resume(smx_context_t new_context) {
xbt_os_sem_release(((smx_ctx_thread_t) new_context)->begin);
xbt_os_sem_acquire(((smx_ctx_thread_t) new_context)->end);
}
xbt_os_sem_release(((smx_ctx_thread_t) new_context)->begin);
xbt_os_sem_acquire(((smx_ctx_thread_t) new_context)->end);
}