XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+#ifdef CONTEXT_THREADS
static xbt_parmap_t parmap;
+#endif
static smx_context_t
smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
(*factory)->suspend = smx_ctx_sysv_suspend;
(*factory)->name = "smx_sysv_context_factory";
- if (smx_parallel_contexts) {
+ if (SIMIX_context_is_parallel()) {
#ifdef CONTEXT_THREADS /* To use parallel ucontexts a thread pool is needed */
parmap = xbt_parmap_new(2);
(*factory)->runall = smx_ctx_sysv_runall_parallel;
(*factory)->self = smx_ctx_sysv_self_parallel;
+ (*factory)->get_thread_id = smx_ctx_sysv_get_thread_id;
#else
THROW0(arg_error, 0, "No thread support for parallel context execution");
#endif
context->uc.uc_link = NULL;
context->uc.uc_stack.ss_sp =
- pth_skaddr_makecontext(context->stack, CONTEXT_STACK_SIZE);
+ pth_skaddr_makecontext(context->stack, smx_context_stack_size);
context->uc.uc_stack.ss_size =
- pth_sksize_makecontext(context->stack, CONTEXT_STACK_SIZE);
+ pth_sksize_makecontext(context->stack, smx_context_stack_size);
#ifdef HAVE_VALGRIND_VALGRIND_H
context->valgrind_stack_id =
void *data)
{
- return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t),
+ return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) + smx_context_stack_size,
code, argc, argv, cleanup_func,
data);
void smx_ctx_sysv_resume_parallel(smx_process_t process)
{
smx_context_t context = process->context;
- xbt_os_thread_set_extra_data(context);
+ smx_current_context = (smx_context_t)context;
int rv = swapcontext(&((smx_ctx_sysv_t)context)->old_uc, &((smx_ctx_sysv_t) context)->uc);
- xbt_os_thread_set_extra_data(NULL);
+ smx_current_context = (smx_context_t)maestro_context;
xbt_assert0((rv == 0), "Context swapping failure");
}
smx_context_t smx_ctx_sysv_self_parallel(void)
{
- smx_context_t self_context = (smx_context_t) xbt_os_thread_get_extra_data();
- return self_context ? self_context : (smx_context_t) maestro_context;
+ /*smx_context_t self_context = (smx_context_t) xbt_os_thread_get_extra_data();
+ return self_context ? self_context : (smx_context_t) maestro_context;*/
+ return smx_current_context;
+}
+
+int smx_ctx_sysv_get_thread_id(void)
+{
+ return (int)(unsigned long)xbt_os_thread_get_extra_data();
}