Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: save the ucontext of each running thread in a per context basis.
authorcristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 8 Dec 2010 22:08:35 +0000 (22:08 +0000)
committercristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 8 Dec 2010 22:08:35 +0000 (22:08 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9102 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/smx_context_sysv.c
src/simix/smx_context_sysv_private.h

index 9b1fbdf..d17a080 100644 (file)
@@ -29,7 +29,6 @@ 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);
 
-
 static void smx_ctx_sysv_wrapper(smx_ctx_sysv_t context);
 
 void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory)
@@ -154,7 +153,7 @@ void smx_ctx_sysv_wrapper(smx_ctx_sysv_t context)
 void smx_ctx_sysv_suspend(smx_context_t context)
 {
   smx_current_context = (smx_context_t)maestro_context;
-  int rv = swapcontext(&((smx_ctx_sysv_t) context)->uc, &maestro_context->uc);
+  int rv = swapcontext(&((smx_ctx_sysv_t) context)->uc, &((smx_ctx_sysv_t)context)->old_uc);
 
   xbt_assert0((rv == 0), "Context swapping failure");
 }
@@ -162,7 +161,7 @@ void smx_ctx_sysv_suspend(smx_context_t context)
 void smx_ctx_sysv_resume(smx_context_t context)
 {
   smx_current_context = context; 
-  int rv = swapcontext(&maestro_context->uc, &((smx_ctx_sysv_t) context)->uc);
+  int rv = swapcontext(&((smx_ctx_sysv_t)context)->old_uc, &((smx_ctx_sysv_t) context)->uc);
 
   xbt_assert0((rv == 0), "Context swapping failure");
 }
@@ -178,7 +177,8 @@ void smx_ctx_sysv_runall(xbt_swag_t processes)
 void smx_ctx_sysv_resume_parallel(smx_context_t context)
 {
   xbt_os_thread_set_extra_data(context);
-  int rv = swapcontext(&maestro_context->uc, &((smx_ctx_sysv_t) context)->uc);
+  int rv = swapcontext(&((smx_ctx_sysv_t)context)->old_uc, &((smx_ctx_sysv_t) context)->uc);
+  xbt_os_thread_set_extra_data(NULL);
 
   xbt_assert0((rv == 0), "Context swapping failure");
 }
index de4b441..5660770 100644 (file)
@@ -29,6 +29,7 @@ SG_BEGIN_DECL()
 typedef struct s_smx_ctx_sysv {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
   ucontext_t uc;                /* the thread that execute the code */
+  ucontext_t old_uc;            /* the context that was swapped with */
 #ifdef HAVE_VALGRIND_VALGRIND_H
   unsigned int valgrind_stack_id;       /* the valgrind stack id */
 #endif