static xbt_swag_t context_living = NULL;
#ifndef USE_PTHREADS /* USE_PTHREADS and USE_CONTEXT are exclusive */
-# ifndef HAVE_UCONTEXT_H
+# ifndef USE_UCONTEXT
/* don't want to play with conditional compilation in automake tonight, sorry.
include directly the c file from here when needed. */
# include "context_win32.c"
#ifdef USE_PTHREADS
if (context) {
xbt_context_t self = current_context;
+ DEBUG0("**** Locking ****");
pthread_mutex_lock(&(context->mutex));
+ DEBUG0("**** Updating current_context ****");
current_context = context;
+ DEBUG0("**** Releasing the prisonner ****");
pthread_cond_signal(&(context->cond));
+ DEBUG0("**** Going to jail ****");
pthread_cond_wait(&(context->cond), &(context->mutex));
+ DEBUG0("**** Unlocking ****");
pthread_mutex_unlock(&(context->mutex));
+ DEBUG0("**** Updating current_context ****");
current_context = self;
}
#else
int i;
#ifdef USE_PTHREADS
+ DEBUG0("**** Lock ****");
+ pthread_mutex_lock(&(context->mutex));
+ DEBUG0("**** Releasing the prisonner ****");
+ pthread_cond_signal(&(context->cond));
+ DEBUG0("**** Going to Jail ****");
pthread_cond_wait(&(context->cond), &(context->mutex));
+ DEBUG0("**** Unlocking ****");
pthread_mutex_unlock(&(context->mutex));
#endif
void xbt_context_start(xbt_context_t context)
{
#ifdef USE_PTHREADS
- pthread_mutex_lock(&(context->mutex));
-
/* Launch the thread */
+ DEBUG0("**** Locking ****");
+ pthread_mutex_lock(&(context->mutex));
+ DEBUG0("**** Pthread create ****");
xbt_assert0(!pthread_create(context->thread, NULL, __context_wrapper, context),
"Unable to create a thread.");
+ DEBUG0("**** Going to jail ****");
+ pthread_cond_wait(&(context->cond), &(context->mutex));
+ DEBUG0("**** Unlocking ****");
+ pthread_mutex_unlock(&(context->mutex));
#else
makecontext (&(context->uc), (void (*) (void)) __context_wrapper,
1, context);
/* WARNING : when this context is over, the current_context (i.e. the
father), is awaken... Theorically, the wrapper should prevent using
this feature. */
- res->uc.uc_stack.ss_sp = res->stack;
- res->uc.uc_stack.ss_size = STACK_SIZE;
+ res->uc.uc_stack.ss_sp = pth_skaddr_makecontext(res->stack,STACK_SIZE);
+ res->uc.uc_stack.ss_size = pth_sksize_makecontext(res->stack,STACK_SIZE);
#endif
res->argc = argc;
res->argv = argv;