- smx_ctx_lua_t context = xbt_new0(s_smx_ctx_lua_t, 1);
-
- /* If the user provided a function for the process then use it
- otherwise is the context for maestro */
- if (code){
- context->code = code;
-
- context->argc = argc;
- context->argv = argv;
- context->cleanup_func = cleanup_func;
- context->cleanup_arg = cleanup_arg;
- INFO1("Created context for function %s",argv[0]);
-
- /* start the coroutine in charge of running that code */
- context->state = lua_newthread(lua_state);
- context->ref = luaL_ref(lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
-
- /* Start the co-routine */
- lua_getglobal(context->state,context->argv[0]);
- xbt_assert1(lua_isfunction(context->state,-1),
- "The lua function %s does not seem to exist",context->argv[0]);
-
- // push arguments onto the stack
- int i;
- for(i=1;i<context->argc;i++)
- lua_pushstring(context->state,context->argv[i]);
-
- // Call the function (in resume)
- context->nargs = context->argc-1;
-
- } else {
- INFO0("Created context for maestro");
- }
-
- return (smx_context_t)context;
+ return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t),
+ code,argc,argv,cleanup_func,cleanup_arg);