void DrmaManager::bspGet(int pid,const void * src, int offset, void * dst, int nBytes){ assert(0 <= pid < baseProcess_->getTotalNumProcs()); int logicSrc = findLastRegistration(src); Registration & reg = getRegistration(logicSrc); if (offset + nBytes > reg.size()){ cerr << "[ERROR] DrmaManager::BspGet->Invalid bounds on operation" << endl; throw InvalidBoundsOnDrmaOperationException(); } BspGetRequest request; request.pid(baseProcess_->getMyPid()) .logicSrc(logicSrc) .offset(offset) .nBytes(nBytes) .superstep(baseProcess_->superstep()) .dst(dst); // Put in a local vector (Care with superstep number) // Use a logical number and dual vector with a certain size /** ---------------- RYC ------------- */ // cerr << "[RYC] DrmaManager::bspGet->Address:" << dst << endl; if(pid != baseProcess_->getMyPid()) stubPool_->bspGetRequest(pid, request); else addPendingGetRequest(request); pendingGetRepliesCount.inc(); }
//-------------------------------------------------------------------------------- void BspProxyStubPool::bspGetRequest(const int & taskPid, const BspGetRequest & request){ int initialStackSize = lua_gettop(clientSideState); lua_getglobal(clientSideState, getTaskId(taskPid).c_str()); lua_pushstring(clientSideState, "bspGetRequest"); lua_gettable(clientSideState, -2); lua_getglobal(clientSideState, getTaskId(taskPid).c_str()); lua_newtable(clientSideState); LuaUtils::setFieldOnTable(clientSideState, "pid", request.pid(), -1); LuaUtils::setFieldOnTable(clientSideState, "logicSrc", request.logicSrc(), -1); LuaUtils::setFieldOnTable(clientSideState, "offset", request.offset(), -1); LuaUtils::setFieldOnTable(clientSideState, "nBytes", request.nBytes(), -1); LuaUtils::setFieldOnTable(clientSideState, "superstep", request.superstep(), -1); LuaUtils::setFieldOnTable(clientSideState, "dst", (unsigned long)request.dst(), -1); //FIXME: check if cast is ok if (lua_pcall(clientSideState, 2, 0, 0) != 0){ cerr << "[ERROR] BspProxyStubPool::bspGetRequest->Lua error: " << lua_tostring(clientSideState, -1) << endl; lua_pop(clientSideState, 1); } lua_pop(clientSideState, 1);//removes proxy from stack assert(initialStackSize == lua_gettop(clientSideState)); }
//----------------------------------------------------------------------- int BspProxyImpl::bspGetRequestWrapper(struct lua_State * state){ int n = lua_gettop(state); assert(n == 1); BspGetRequest request; request.pid(LuaUtils::getIntFromTable(state, "pid")) .logicSrc(LuaUtils::getIntFromTable(state, "logicSrc")) .offset(LuaUtils::getIntFromTable(state, "offset")) .nBytes(LuaUtils::getIntFromTable(state, "nBytes")) .superstep(LuaUtils::getIntFromTable(state, "superstep")) .dst((void *)LuaUtils::getLongFromTable(state, "dst")); lua_pop(state, 1); BspProxyImpl::singleInstance->drmaManager_->addPendingGetRequest(request); return 0; }