Exemplo n.º 1
0
/* static */ SysStatus
FRPANonPageableRamOnly::Create(ObjectHandle &oh, ProcessID processID,
			       ObjectHandle file,
			       uval len,
			       uval fileToken,
			       char *name, uval namelen,
			       KernelPagingTransportRef ref)
{
    // This is the same thing as FRPA::_Create
    SysStatus rc;
    FRPANonPageableRamOnlyRef frref;
    ProcessRef pref;
    FRPANonPageableRamOnly *fr;

    // get process ref for calling file system
    rc = DREFGOBJ(TheProcessSetRef)->getRefFromPID(processID,
						   (BaseProcessRef&)pref);
    tassert(_SUCCESS(rc), err_printf("calling process can't go away??\n"));

    fr = new FRPANonPageableRamOnly;
    tassert( (fr!=NULL), err_printf("alloc should never fail\n"));

    rc = fr->init(file, len, fileToken, name, namelen, ref);

    tassert( _SUCCESS(rc), err_printf("woops\n"));

    frref = (FRPANonPageableRamOnlyRef)CObjRootSingleRep::Create(fr);

    // call giveAccessInternal here to provide fileSystemAccess to
    // the file systems OH
    // note that we set the client data to 1 to mark this as the fr
    // oh so we know if the fs goes away
    rc = DREF(frref)->giveAccessInternal(
	oh, processID,
	MetaFR::fileSystemAccess|MetaObj::controlAccess|MetaObj::attach,
	MetaObj::none, 0, 1);

    if (_FAILURE(rc)) return rc;

    return 0;
}
Exemplo n.º 2
0
/// checks a string wether it detects some errors, result = true means the string should be parsed correctly
void checkParser (const char * code, bool result = true) {
	printf ("Testing %s expected: %d\n", code, result);
	sf::json::Object parser (code);
	if (parser.error() == result){
		if (parser.error()){
			printf ("Could not parse %s error = %s (this error was expected!)\n", code, parser.errorMessage().c_str());
		}
		else{
			tassert (false, "Parser returned no error while it should have");
		}
	}
}
Exemplo n.º 3
0
SysStatus
MPMsgMgr::MsgAsync::send(DispatcherID dspid)
{
    MsgHeader *const hdr = GetHeader(this);
    SysStatus rc;
    MPMsgMgr *targetMgr;

    rc = DREF(hdr->manager->getRegistry())->lookupMgr(dspid, targetMgr);
    tassert(_SUCCESS(rc), err_printf("MPMsgAsync: lookupMgr failed.\n"));
    targetMgr->addPendingSend(hdr);
    return 0;
}
Exemplo n.º 4
0
/* virtual */ SysStatus
PacketRing::unbindFilter()
{
    refCount--; // FIXME: Atomic dec??
    tassert(refCount >= 0, err_printf("PacketRing::unbindFilter - cnt=%ld\n",
                                      refCount));
    if (beingDestroyed && refCount == 0) {
        destroy();
    }

    return 0;
}
Exemplo n.º 5
0
static void testInsertAndRemove(MprTestGroup *gp)
{
    MprList     *lp;
    int         index;

    lp = mprCreateList(0, 0);
    tassert(lp != 0);

    /*
        Do one insert and remove 
     */
    index = mprAddItem(lp, (void*) 1);
    tassert(index >= 0);
    tassert(mprGetListLength(lp) == 1);

    mprRemoveItem(lp, (void*) 1);
    tassert(mprGetListLength(lp) == 0);

    /*
        Test remove will compact
     */
    mprAddItem(lp, (void*) 1);
    mprAddItem(lp, (void*) 2);
    mprAddItem(lp, (void*) 3);

    mprRemoveItem(lp, (void*) 2);
    tassert(mprGetListLength(lp) == 2);
    mprRemoveItem(lp, (void*) 3);
    tassert(mprGetListLength(lp) == 1);
}
Exemplo n.º 6
0
/* static */ SysStatus
RegionReplicated::_CreateFixedLenExtDyn(uval& regionVaddr, uval regionSize,
					uval alignmentreq, ObjectHandle frOH,
					uval fileOffset, uval accessreq,
					XHandle target, ObjectHandle tsOH,
					RegionType::Type regionType,
					__CALLER_PID callerPID)
{
    RegionRef ref;
    ProcessRef pref=0;
    SysStatus rc;
    FCMRef fcmRef;
    TypeID type;
    ObjRef objRef;
    FRRef frRef;

    rc = RegionDefault::PrefFromTarget(target, callerPID, pref);
    _IF_FAILURE_RET(rc);

    rc = XHandleTrans::XHToInternal(frOH.xhandle(), callerPID,
				    MetaObj::attach, objRef, type);
    tassertWrn(_SUCCESS(rc), "RegionReplicated failed XHToInternal\n");
    _IF_FAILURE_RET(rc);

    // verify that type is of FRComp - we'd really like just FR
// FIXMEXX talk to Orran, the brilliant, charming, ..
    if (!MetaFR::isBaseOf(type)) {
	tassertWrn(0, "object handle <%lx,%lx> not of correct type\n",
		   frOH.commID(), frOH.xhandle());
	return _SERROR(1542, 0, EINVAL);
    }

    //FIXME check xobj to make sure it matches our processID

    frRef = (FRRef)objRef;

    rc = RegionReplicated::CreateFixedLen(
	ref, pref, regionVaddr,
	regionSize, alignmentreq, frRef, fileOffset,
	(AccessMode::mode)accessreq);

    // FIXME: Kludge for enabling dyn-switch
#if 0
    CObjRoot *partitionedFCMRoot = 0;
    rc = FCMPartitionedTrivial::Create(partitionedFCMRoot, fcmRef, regionSize,
				       /* number of cache lines per rep */ 256,
				       /* associativity of each line */    4);
    tassert(_SUCCESS(rc), err_printf("Replicated Trivial fcm create\n"));

    PMRef pmRef;
    rc = DREF(pref)->getPM(pmRef);
    tassert(_SUCCESS(rc), ;);
Exemplo n.º 7
0
static void testMakeDir(MprTestGroup *gp)
{
    TestPath    *ts;
    int         rc;
    
    ts = (TestPath*) gp->data;

    mprGlobalLock(gp);
    rc = mprMakeDir(ts->dir1, DIRMODE, -1, -1, 1);
    tassert(rc == 0);
    tassert(access(ts->dir1, X_OK) == 0);

    rmdir(ts->dir1);
    tassert(access(ts->dir1, X_OK) < 0);

    rmdir(ts->dir2);
    rmdir(ts->dir1);

    /*
        Dir should not exist before test
     */
    tassert(access(ts->dir1, X_OK) < 0);

    /*
        Make directory path
     */
    rc = mprMakeDir(ts->dir2, DIRMODE, -1, -1, 1);
    tassert(rc == 0);
    tassert(access(ts->dir2, X_OK) == 0);

    rc = mprDeletePath(ts->dir2);
    tassert(rc == 0);
    rc = mprDeletePath(ts->dir1);
    tassert(rc == 0);
    
    tassert(access(ts->dir1, X_OK) < 0);
    tassert(access(ts->dir2, X_OK) < 0);
    mprGlobalUnlock(gp);
}
Exemplo n.º 8
0
/* virtual */ SysStatus
FRPA::_explicitFsync()
{
    FCMRef fcmRefTmp;
    fcmRefTmp = fcmRef;			// careful because locks not held
    if (fcmRefTmp) {
	return DREF(fcmRefTmp)->fsync(1 /*force*/);
    } else {
	// FIXME dilma: is is possible that fcmRef is 0 here?
	tassert(0, err_printf("investigate if we should invoke getFCM\n"));
	return 0;
    }
}
Exemplo n.º 9
0
void
MPMsgMgrException::ClassInit(DispatcherID dspid, MemoryMgrPrimitive *pa)
{
    static MPMsgMgrRegistryRef theRegistryRef = NULL;

    MPMsgMgrException *mgr;
    mgr = new(pa) MPMsgMgrException;
    tassert(mgr != NULL, err_printf("failed to create MPMsgMgrException.\n"));

    mgr->init(dspid, pa, theRegistryRef);
    exceptionLocal.setExceptionMsgMgr(mgr);
    mgr->addToRegistry(dspid);
}
Exemplo n.º 10
0
/* static */ SysStatus
PacketFilterRoot::Create(PacketFilterRootRef &pfrRef)
{
    PacketFilterRoot *pfr = new PacketFilterRoot;
    SysStatus rc;

    rc = pfr->init();
    tassert(_SUCCESS(rc), err_printf("PacketFilterRoot::Create failed\n"));

    pfrRef = (PacketFilterRootRef)CObjRootSingleRep::Create(pfr);

    return 0;
}
Exemplo n.º 11
0
void disable_gptimers(uint16_t mask)
{
    int i;
    uint16_t m = mask;
    tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0);
    for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) {
        group_regs[i]->disable = m & 0xFF;
        m >>= 8;
    }
    for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i)
        if (mask & (1 << i))
            group_regs[BFIN_TIMER_OCTET(i)]->status |= trun_mask[i];
    SSYNC();
}
Exemplo n.º 12
0
/* virtual */ SysStatusUval
FCMPrimitive<PL,ALLOC>::getPage(uval fileOffset, void *&dataPtr,
		      PageFaultNotification */*fn*/)
{
    SysStatus rc;
    uval paddr;

    this->lock.acquire();

    PageDesc *pg = this->findPage(fileOffset);
    if (!pg) {
	// allocate a new page
	uval virtAddr;
	this->lock.release();
	rc = DREF(this->pmRef)->allocPages(this->getRef(), virtAddr,
		this->pageSize, this->pageable);
	tassert(_SUCCESS(rc), err_printf("woops\n"));
	this->lock.acquire();
	if ((pg = this->findPage(fileOffset)) != 0) {
	    // added in our absence
	    DREF(this->pmRef)->deallocPages(this->getRef(), virtAddr,
		    this->pageSize);
	    paddr = pg->paddr;
	    TraceOSMemFCMPrimFoundPage(fileOffset, paddr);
	} else {
	    paddr = PageAllocatorKernPinned::virtToReal(virtAddr);
	    TraceOSMemFCMPrimGetPage(fileOffset, paddr);
	    pg = this->addPage(fileOffset, paddr, this->pageSize);
	}
    } else {
	paddr = pg->paddr;
	TraceOSMemFCMPrimFoundPage(fileOffset, paddr);
    }
    tassert(1, err_printf(" should use offset %ld\n", fileOffset));
    dataPtr = (void *)PageAllocatorKernPinned::realToVirt(pg->paddr);
    return 0;
}
Exemplo n.º 13
0
/* private */ void
PacketRing::reclaimSpaceRX()
{
    PacketRingHdr *recvHdr;
    uval length;

    cprintf("PacketRing::reclaimSpace - (freeSpace=%ld, pckt count=%ld)\n", 
            freeSpaceRX, packetCountRX);

    recvHdr = (PacketRingHdr *)(pageArray[beginIdxRX] + beginOffsetRX);
  
    while((!RingHdrValid((uval)recvHdr)) && packetCountRX > 0) {

	length = (sizeof(PacketRingHdr) + recvHdr->prepad + recvHdr->length + 
		  recvHdr->postpad);
	beginOffsetRX += length;

	if (beginOffsetRX >= PAGE_SIZE) {
	    beginOffsetRX = beginOffsetRX % PAGE_SIZE;
	    beginIdxRX = (beginIdxRX + 1) % pageArrayNumRX;
	}
	packetCountRX--;
	freeSpaceRX += length;
        
        tassert(beginOffsetRX < PAGE_SIZE, 
                err_printf("beginOffsetRX out of bounds\n"));
        tassert(beginIdxRX >= 0 && 
                beginIdxRX < pageArrayNumRX,
                err_printf("beginIdxRX out of bounds\n"));

	recvHdr = (PacketRingHdr *)(pageArray[beginIdxRX] + beginOffsetRX);
    }

    cprintf("PacketRing::reclaimSpace - End (freeSpace=%ld)\n", freeSpaceRX);

    return;
}
Exemplo n.º 14
0
static void testLotsOfInserts(MprTestGroup *gp)
{
    MprList     *lp;
    int         i;

    lp = mprCreateList(LIST_MAX_ITEMS, 0);
    tassert(lp != 0);

    /*
        Do lots insertions 
     */
    for (i = 0; i < LIST_MAX_ITEMS; i++) {
        mprAddItem(lp, (void*) (long) i);
        tassert(mprGetListLength(lp) == (i + 1));
    }

    /*
        Now remove
     */
    for (i = LIST_MAX_ITEMS - 1; i >= 0; i--) {
        mprRemoveItem(lp, (void*) (long) i);
        tassert(mprGetListLength(lp) == i);
    }
}
Exemplo n.º 15
0
SysStatus
HATDefaultBase<ALLOC>::findSegmentGlobal(uval virtAddr, SegmentHATRef &result,
				   uval createIfNoSeg)
{
    SysStatus rc = 0;
    SegmentHATRef segmentHATRef;
    VPSet *ppset;
    AutoLock<LockType> al(&glock);

    tassertMsg(virtAddr < KERNEL_REGIONS_END,
	       "%lx should be handled by the low level page fault code\n",
	       virtAddr);
    segmentHATRef = segmentList.findSegment(virtAddr, ppset);

    //err_printf("findSegmentGlobal %lx/%ld -> %p\n", virtAddr, createIfNoSeg,
    //       segmentHATRef);
    if (!segmentHATRef) {
	if (!createIfNoSeg) return HAT::NOSEG;
	// round address down to segment boundary
	uval segVirtAddr = virtAddr&(~(SEGMENT_SIZE-1));
	// create private segment using protected function
	// so kernel can do it differently - see HATKernel
	rc = createSegmentHATPrivate(segmentHATRef);
	tassert(!rc, err_printf("no memory for SegmentHAT\n"));
	if (rc)
	    return rc;
	rc = segmentList.addSegment(segVirtAddr,SEGMENT_SIZE,
				    segmentHATRef, ppset);
	tassert(!rc, err_printf("no memory for SegmentList\n"));
	if (rc)
	    return rc;
    }
    ppset->addVP(Scheduler::GetVP());
    result = segmentHATRef;
    return rc;
}
Exemplo n.º 16
0
SysStatus
PacketRing::allocCtrl()
{
    SysStatus rc;

    rc = DREFGOBJK(ThePinnedPageAllocatorRef)->allocPages(ctrlPage, PAGE_SIZE);
    tassert(_SUCCESS(rc), err_printf("allocPages failed - ctrl page\n"));   

    cprintf("Created page at: %#lx\n", ctrlPage);

    // FIXME: need better handling of these errors
    rc = DREF(fcmRef)->addReference();
    tassert(_SUCCESS(rc), err_printf("addReference failed - ctrl page\n"));
    
    rc = DREF(fcmRef)->establishPage(fcmOffset, ctrlPage, PAGE_SIZE);
    tassert(_SUCCESS(rc), err_printf("establishPage failed - ctrl page\n"));
    
    fcmOffset += PAGE_SIZE;

    ctrlRegister = (volatile uval32 *)ctrlPage;
    AtomicAnd32Synced(ctrlRegister, 0);

    return 0;
}
Exemplo n.º 17
0
/*static*/ SysStatus
MPMsgMgr::SendAsyncUval(MPMsgMgr *mgr, DispatcherID dspid,
			SysStatusFunctionUval func, uval val)
{
    SysStatus rc;
    MsgAsyncUval *const msg = new(mgr) MsgAsyncUval;
    tassert(msg != NULL, err_printf("message allocate failed.\n"));

    msg->function = func;
    msg->value = val;

    rc = msg->send(dspid);

    return rc;
}
Exemplo n.º 18
0
SysStatus
ProgExec::parsePHdr(HDR *phdr, uval phdr_num, ProgExec::BinInfo *info)
{
    /* we assume sections are all adjacent to each other */
    /* we assume only one text and one data/bss section */
    info->numSegs = 0;
    uval i;
    for (i=0; i<phdr_num; i++,phdr++) {
	if (phdr->p_type==PT_LOAD) {
	    passertMsg(info->numSegs < BinInfo::MAXNUMSEG,
		       "too many segments\n");
	    tassert((phdr->p_memsz >= phdr->p_filesz),
		    err_printf("seomthing's wrong with data segment\n"));
	    info->seg[info->numSegs].offset = phdr->p_offset;
	    info->seg[info->numSegs].vaddr = phdr->p_vaddr;
	    info->seg[info->numSegs].filesz = phdr->p_filesz;
	    info->seg[info->numSegs].memsz = phdr->p_memsz;
	    info->seg[info->numSegs].flags = phdr->p_flags;
	    info->numSegs += 1;
	} else 	if (phdr->p_type==PT_INTERP && info) {
	    info->interpOffset = phdr->p_offset;
	}
    }

    /*
     *FIXME Marc and Bryan 3/2/2004
     * In fixing a bug, we started to fix the load logic.
     * in theory, we should load multi segment modules in a systematic
     * way, looping over the segments respecting flags etc.  but the rest
     * of the code is too painful to change today, so we revert to the
     * TEXT, DATA assumptions of the rest of the code by requiring
     * exactly 2 segments and calling one TEXT, one DATA.
     * we do this by kludge - the TEXT is either the first r-x segment
     * or the first segment period, the other is DATA
     */
    passertMsg(info->numSegs == 2, "Only support 2 segment modules\n");
    
    info->textSegIndex = 0;
    for (i=0; i<info->numSegs; i++) {
	if ((info->seg[i].flags & ((PF_R) | (PF_W) | (PF_X))) ==
	    ((PF_R) | (PF_X))) {
	    info->textSegIndex = i;
	    break;
	}
    }
    info->dataSegIndex = info->textSegIndex ^ 1;	// couldn't resist
    return 0;
}
Exemplo n.º 19
0
void Channel::get_subchannel_names(KVS &kvs, int owner_id, 
				   const std::string &prefix, 
				   std::vector<std::string> &names, 
				   unsigned int nlevels) {
  std::string kvs_prefix = string_printf("%d", owner_id);
  if (prefix != "") kvs_prefix += "." + prefix;
  std::vector<std::string> keys;
  kvs.get_subkeys(kvs_prefix, keys, nlevels, not_all_digits_filter);
  for (unsigned i = 0; i < keys.size(); i++) {
    if (filename_suffix(keys[i]) == "info") {
      std::string name_with_uid = filename_sans_suffix(keys[i]);
      tassert(strchr(name_with_uid.c_str(), '.'));
      names.push_back(1+strchr(name_with_uid.c_str(), '.'));
    }
  }
}
Exemplo n.º 20
0
SysStatus
HATDefaultBase<ALLOC>::getSegmentTable(VPNum vp, SegmentTable *&st)
{
    if (!byVP[vp].segps) {
	TraceOSMemAllocSegment(vp);
	SysStatus rc = SegmentTable::Create(byVP[vp].segps);
	if (!_SUCCESS(rc)) {
	    tassert(0, err_printf("no space for HAT segment table\n"));
	    return rc;
	}
    }
    // record current pp on every call - may change on migration
    byVP[vp].pp = Scheduler::GetVP();
    st = byVP[vp].segps;
    return 0;
}
Exemplo n.º 21
0
// this end of socket
/*virtual*/ SysStatus
FileLinuxPacket::getsocketname(char* addr, uval &addrLen)
{
    AutoLock<LockType> al(&objLock);
    tassert(local, err_printf("local sockaddr is not available\n"));
    if (addrLen < localLen) {
	return _SERROR(2044, 0, EINVAL);
    }

    if (local) {
	addrLen = localLen;
	memcpy(addr, local, addrLen);
	return 0;
    }
    return _SERROR(2045, 0, ENOTSOCK);
}
Exemplo n.º 22
0
SysStatus
FileLinuxDevZero::Create(FileLinuxRef &newFile, ObjectHandle toh, uval oflags)
{
    FileLinuxDevZero *newp;

    // no initialization, this stinker is *simple*
    newp = new FileLinuxDevZero;
    tassert(newp != NULL, err_printf("new failed.\n"));

    newp->init(toh);
    newp->setFlags(oflags);
    newFile = (FileLinuxRef)CObjRootSingleRep::Create(newp);

    //FIXME - cleanup on failure paths?
    return _SRETUVAL(0);
}
Exemplo n.º 23
0
/*virtual*/ SysStatus
DispatcherMgr::enter(DispatcherID dspid, Dispatcher *dsp)
{
    AutoLock<LockType> al(&lock);	// locks now, unlocks on return

    RDNum rd; VPNum vp;
    SysTypes::UNPACK_DSPID(dspid, rd, vp);
    tassert((rd < Scheduler::RDLimit) &&
	    (vp < Scheduler::VPLimit) &&
	    (dispatcher[rd][vp] == NULL),
	    err_printf("Bad or duplicate dspid.\n"));

    dispatcher[rd][vp] = dsp;
    ((DispatcherDefault *) dsp)->published = published;

    return 0;
}
Exemplo n.º 24
0
/*static*/ SysStatus
ResMgrWrapper::CreateAndRegisterFirstDispatcher()
{
    ObjectHandle oh;
    SysStatus rc;

    ResMgrWrapper *wrapper = new ResMgrWrapper;
    tassert(wrapper != NULL, err_printf("failed to create res mgr wrapper\n"));

    rc = StubResMgr::_CreateAndRegisterFirstDispatcher(oh);
    passertMsg(_SUCCESS(rc), "failed to create resource manager wrapper.\n");
    wrapper->stub.setOH(oh);

    new CObjRootSingleRep(wrapper, (RepRef)GOBJ(TheResourceManagerRef));
//;;cprintf("successfully created res manager wrapper\n");
    return 0;
}
Exemplo n.º 25
0
static void testArgvRegressions(MprTestGroup *gp)
{
    int     argc;
    cchar   **argv;

    //  "\bin\sh" "-c" "c:/home/mob/ejs/out/bin/ejs.exe ./args \"a b\" c"
    argc = mprMakeArgv("\"\\bin\\sh\" \"-c\" \"c:/home/mob/ejs/out/bin/ejs.exe ./args \\\"a b\\\" c\"", &argv, 0);
    tassert(argc == 3);
    tassert(strcmp(argv[0], "\\bin\\sh") == 0);
    tassert(strcmp(argv[1], "-c") == 0);
    tassert(strcmp(argv[2], "c:/home/mob/ejs/out/bin/ejs.exe ./args \"a b\" c") == 0);

    //  "\bin\sh" "-c" "/bin/ejs ./args \"a b\" c"
    argc = mprMakeArgv("\"\\bin\\sh\" \"-c\" \"/bin/ejs ./args \\\"a b\\\" c\"", &argv, 0);
    tassert(argc == 3);
    tassert(strcmp(argv[0], "\\bin\\sh") == 0);
    tassert(strcmp(argv[1], "-c") == 0);
    tassert(strcmp(argv[2], "/bin/ejs ./args \"a b\" c") == 0);
}
Exemplo n.º 26
0
SysStatus
BlockDevBase::StubFRHolder::init(ObjectHandle myOH, uval size)
{
    ObjectHandle oh;
    SysStatus rc;

    /* We added name information in the interface to make dubugging FCMs
     * and FRs easier, but we don't need them here. Also, fileToken is
     * not relevant */
    char foo;
    rc = FRPA::_Create(oh, _KERNEL_PID, myOH, size, 0 /* fileToken */,
		       &foo, 0);
    tassert( _SUCCESS(rc), err_printf("woops\n"));
    stubFR.setOH(oh);

    // err_printf("constructing StubFRHolder %p\n", this);
    return 0;
};
Exemplo n.º 27
0
/* virtual */ SysStatusUval
FRPA::startFillPage(uval physAddr, uval objOffset)
{
    if (objOffset >= filelen) {
	return PAGE_NOT_FOUND;
    }
    FetchAndAddSignedVolatile(&outstanding, 1);

    SysStatus rc;
    uval addr;
    
    rc = convertAddressReadFrom(physAddr, addr); /* almost nop for FRPA;
						  * conversion for FRVA */
    tassert(_SUCCESS(rc), err_printf("convertAddress failed\n"));
	
    if (kptref) {
	rc = DREF(kptref)->startFillPage(fileToken, addr, objOffset);
    } else {
	/* we don't have a transport setup, so we will use the async
	 * interfaces */

	/* not having kptref means that the old _Create itfc has been used,
	 * let's check that fileToken has not been given */
	tassertMsg(fileToken == 0, "how come?");

	uval interval = 20000;		// do this in cycles, not time

	rc = stubFile->_startFillPage(addr, objOffset);

	while (!_SUCCESS(rc) && (_SGENCD(rc) == EBUSY) &&
	       interval < 200000000000UL) {
	    Scheduler::DelayUntil(interval, TimerEvent::relative);
	    interval = interval*10;		// back off to avoid livelock
	    rc = stubFile->_startFillPage(addr, objOffset);
	}
	
	passertMsg(_SUCCESS(rc), "timed out trying to send to file system\n");
    }

    passertMsg((rc == 0 || rc == PAGE_NOT_FOUND),
	       "assuming getting back 0 or PAGE_NOT_FOUND from FS\n");
    
    return rc;
}
Exemplo n.º 28
0
/* virtual */ DataTransferObject *
ProcessShared<ALLOC>::Root::dataTransferExport(DTType dtt, VPSet transferVPSet)
{
    ProcessShared<ALLOC> *rep = (ProcessShared<ALLOC> *)therep;
    tassert(dtt == DTT_PROCESS_DEFAULT, err_printf("wrong transfer type\n"));

    if (transferVPSet.firstVP() != Scheduler::GetVP()) {
        /* only do transfer on first VP */
        return 0;
    }

    tassertMsg(!rep->updatedFlagDoNotDestroy, "process being updated twice\n");
    rep->updatedFlagDoNotDestroy = true;

    return new ProcessDataTransferObject<ALLOC>(
            &rep->rlst, &rep->lazyState, &rep->vpList, &rep->matched,
            &rep->memTransMgr, rep->hatRefProcess, rep->pmRef, rep->OSData,
            &exported);
}
Exemplo n.º 29
0
/*
 * unmaps the page from the process this region is attached to
 * argument is the FCM offset - which the Region can convert
 * to a virtual address
 * we find the specific vp this offset is in
 */
SysStatus
RegionPerProcessorKernel::unmapPage(uval offset)
{
    if (hat) {
	VPNum vp;
	//calculate which vp this offset is "in"
	vp = (offset-fileOffset)/regionSize;
	/* vp should be local vp, although not having the vp is ok as well.
	 * this actually may not be fatal if for some reason we share these
	 */
	VPNum pp;
	tassert(_FAILURE(DREF(proc)->vpnumToPpnum(vp, pp))
		|| (pp == Scheduler::GetVP()),
		err_printf("RPP::unmapPageLocal wrong proc: %ld != %ld\n",
			   uval(pp), uval(Scheduler::GetVP())));
	DREF(hat)->unmapPage((offset-fileOffset)-vp*regionSize+regionVaddr);
    }
    return 0;
}
Exemplo n.º 30
0
/*
 * For now, destruction only under the control of ServerFileBlockNFS,
 * eventually the kernel will have to have some way to manage how
 * many FRs there are in the system, and destroy those of a
 * non-responsive file system.
 */
SysStatus
FRPA::locked_destroy()
{
    _ASSERT_HELD(lock);

    // FIXME: take a look at synchronization

    //err_printf("FRPA::locked_destroy() : %lx\n",getRef());

    if (beingDestroyed) return _SDELETED(2204);

    beingDestroyed = 1;

    //err_printf("Before fcmRef->fsync and destroy(), outstanding=%ld\n",
    //           outstanding);

    // first flush back dirty pages and destroy FCM
    // these might result in callbacks, and there may be I/Os pending
    // checks on beingDestroyed avoid deadlock in those cases

    if (fcmRef) {
	if (!removed) DREF(fcmRef)->fsync(1 /*force*/);
	DREF(fcmRef)->destroy();
    }

    tassert(outstanding == 0, err_printf("oops: outstanding is %ld\n",
					 outstanding));

    {   // remove all ObjRefs to this object
	SysStatus rc=closeExportedXObjectList();
	// most likely cause is that another destroy is in progress
	if (_FAILURE(rc)) return rc;
    }

    delete stubFile;
    stubFile = 0;

    // schedule the object for deletion
    destroyUnchecked();

    return (0);
}