+ self = current_context;
+
+ if (is_main_thread()) {
+ /* the main thread has called this function
+ * - update the current context
+ * - signal the condition of the process to run
+ * - wait on its condition
+ * - restore thr current contex
+ */
+
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
+
+ /* update the current context */
+ current_context = context;
+ xbt_os_cond_signal(context->cond);
+ xbt_os_mutex_unlock(context->mutex);
+
+ xbt_os_cond_wait(master_cond, master_mutex);
+ xbt_os_mutex_unlock(master_mutex);
+ /* retore the current context */
+ current_context = self;
+
+ } else {
+ /* a java thread has called this function
+ * - update the current context
+ * - signal the condition of the main thread
+ * - wait on its condition
+ * - restore thr current contex
+ */
+
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
+ /* update the current context */
+ current_context = context;
+ xbt_os_cond_signal(master_cond);
+ xbt_os_mutex_unlock(master_mutex);
+ xbt_os_cond_wait(context->cond, context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
+ /* retore the current context */
+ current_context = self;
+ }
+
+#else /* use SUSv2 contexts */