- xbt_context_t context = c;
-
-#ifdef USE_PTHREADS
- DEBUG2("**[%p:%p]** Lock ****",context,(void*)pthread_self());
- pthread_mutex_lock(&(context->mutex));
- DEBUG2("**[%p:%p]** Releasing the prisonner ****",context,(void*)pthread_self());
- pthread_cond_signal(&(context->cond));
- DEBUG2("**[%p:%p]** Going to Jail ****",context,(void*)pthread_self());
- pthread_cond_wait(&(context->cond), &(context->mutex));
- DEBUG2("**[%p:%p]** Unlocking ****",context,(void*)pthread_self());
- pthread_mutex_unlock(&(context->mutex));
+ xbt_context_t context = current_context;
+
+#ifdef CONTEXT_THREADS
+ context = (xbt_context_t) c;
+ context->thread = xbt_os_thread_self();
+
+ DEBUG3("**[ctx:%p;self:%p]** Lock creation_mutex %p ****", context,
+ (void *) xbt_os_thread_self(), creation_mutex);
+ xbt_os_mutex_lock(creation_mutex);
+ xbt_os_mutex_lock(context->mutex);
+
+ DEBUG4
+ ("**[ctx:%p;self:%p]** Releasing the creator (creation_cond %p,%p) ****",
+ context, (void *) xbt_os_thread_self(), creation_cond,
+ creation_mutex);
+ xbt_os_cond_signal(creation_cond);
+ xbt_os_mutex_unlock(creation_mutex);
+
+ DEBUG4("**[ctx:%p;self:%p]** Going to Jail on lock %p and cond %p ****",
+ context, (void *) xbt_os_thread_self(), context->mutex,
+ context->cond);
+ xbt_os_cond_wait(context->cond, context->mutex);
+
+ DEBUG3("**[ctx:%p;self:%p]** Unlocking individual %p ****",
+ context, (void *) xbt_os_thread_self(), context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
+