- smx_ctx_thread_t context = xbt_new0(s_smx_ctx_thread_t, 1);
-
- context->code = code;
- 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, cleanup_arg);
+
+ /* 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);
+
+
+ /* 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);
+
+ /* wait the starting of the newly created process */
+ xbt_os_sem_acquire(context->end);
+ }