int schedule() { tcb_t *scheduled = NULL; scheduled = schedule_select(); thread_switch(scheduled); return 1; }
static int lselect(lua_State *L) { lua_rawgetp(L, LUA_REGISTRYINDEX, S); if (lua_type(L, -1) != LUA_TNUMBER) return luaL_error(L, "select should call in a task"); taskid id = lua_tointeger(L, -1); lua_pop(L, 1); int n = lua_gettop(L); channelid channels[n]; int i; for (i=0;i<n;i++) { channels[i] = luaL_checkinteger(L, i+1); } channelid c = schedule_select(S, id, n, channels); if (c == 0) return 0; lua_pushinteger(L, c); return 1; }