Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill arg 'old_ctx' of function resume in context factory. Was only used when killing...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Mar 2010 00:49:54 +0000 (00:49 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Mar 2010 00:49:54 +0000 (00:49 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7303 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/private.h
src/simix/smx_context_java.c
src/simix/smx_context_lua.c
src/simix/smx_context_private.h
src/simix/smx_context_ruby.c
src/simix/smx_context_sysv.c
src/simix/smx_context_thread.c

index a21e458..d58d6e5 100644 (file)
@@ -58,7 +58,7 @@ extern SIMIX_Global_t simix_global;
     @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;
 
@@ -264,8 +264,7 @@ typedef void (*smx_pfn_context_stop_t) (smx_context_t);
 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 {
@@ -358,10 +357,9 @@ static inline void SIMIX_context_stop(smx_context_t context) {
  \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);
 }
 
 /**
 }
 
 /**
index 8a64130..d2f9ddb 100644 (file)
@@ -21,15 +21,10 @@ smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, char** argv,
 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)
 {
@@ -150,8 +145,9 @@ static void smx_ctx_java_suspend(smx_context_t context)
   jprocess_unschedule(context);
 }
 
   jprocess_unschedule(context);
 }
 
+// FIXME: inline those functions
 static void 
 static void 
-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);
 }
index a71dbba..efd9a01 100644 (file)
@@ -48,12 +48,11 @@ smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char** argv,
     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);
 
@@ -175,7 +174,7 @@ static void smx_ctx_lua_suspend(smx_context_t pcontext) {
 }
 
 static void 
 }
 
 static 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);
index 47afd85..7ee1ce0 100644 (file)
@@ -68,7 +68,6 @@ typedef void (*smx_pfn_context_stop_t) (int);
 
 /* 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;
index 112ca36..8295eb3 100644 (file)
@@ -23,8 +23,7 @@ static int smx_ctx_ruby_factory_finalize(smx_context_factory_t *factory);
 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); 
 
 
@@ -125,9 +124,8 @@ static void smx_ctx_ruby_suspend(smx_context_t context) {
       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;
index a44593d..fe0f7ac 100644 (file)
@@ -25,7 +25,6 @@ typedef struct s_smx_ctx_sysv {
   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                          
@@ -38,13 +37,9 @@ smx_ctx_sysv_factory_create_context(xbt_main_func_t code, int argc, char** argv,
 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);
 
@@ -159,28 +154,21 @@ static void smx_ctx_sysv_wrapper()
   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) {
   int rv;
   int rv;
+  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) {
   int rv;
   int rv;
+  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");
 }
index 30c6653..63f2556 100644 (file)
@@ -32,9 +32,7 @@ static int smx_ctx_thread_factory_finalize(smx_context_factory_t * factory);
 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);
 
@@ -45,7 +43,6 @@ void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory)
   (*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;
@@ -81,7 +78,7 @@ smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, char** arg
     /* 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);
@@ -149,15 +146,12 @@ static void *smx_ctx_thread_wrapper(void *param)
   return NULL;
 }
 
   return NULL;
 }
 
-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);
 }