- smx_ctx_thread_t context = xbt_new0(s_smx_ctx_thread_t, 1);
-
- context->code = code;
- context->argc = argc;
- context->argv = argv;
- context->cleanup_func = cleanup_func;
- context->cleanup_arg = cleanup_arg;
- context->begin = xbt_os_sem_init(0);
- context->end = xbt_os_sem_init(0);
+ smx_ctx_thread_t context = (smx_ctx_thread_t)
+ smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_thread_t),
+ code, argc, argv,
+ cleanup_func, data);
+
+ /* If the user provided a function for the process then use it
+ otherwise is the context for maestro */
+ if (code) {
+ context->begin = xbt_os_sem_init(0);
+ context->end = xbt_os_sem_init(0);
+ if (smx_context_stack_size_was_set)
+ xbt_os_thread_setstacksize(smx_context_stack_size);
+
+ /* create and start the process */
+ /* NOTE: The first argument to xbt_os_thread_create used to be the process *
+ * name, but now the name is stored at SIMIX level, so we pass a null */
+ context->thread =
+ xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, context, context);
+
+
+ /* wait the starting of the newly created process */
+ xbt_os_sem_acquire(context->end);
+
+ } else {
+ xbt_os_thread_set_extra_data(context);
+ }