void Forest::PrintVals(MDDHandle root, level k) { for (level k1 = K; k1 > 0; k1--) { FlushCaches(k1); for (int i = 0; i < last[k1]; i++) { Node *child; child = &FDDL_NODE(k1, i); if (child->flags & FLAG_SHARED) child->flags = (flag)(child->flags - FLAG_SHARED); } } InternalPrintVals(k, root.index); //Mark all nodes in Query for (int i = 0; i < last[k]; i++) { Node *nodeP = &FDDL_NODE(k, i); if (nodeP->flags & FLAG_SHARED) { for (int j = 0; j < nodeP->size; j++) { if (FDDL_NODE(k - 1, FDDL_ARC(k, nodeP, j)).flags & FLAG_SHARED) printf("%d ", j); } } } printf("\n"); }
void CLookupProxy::Process(UINT Tick) { CKadOperation::Process(Tick); if((Tick & E10PerSec) == 0) return; FlushCaches(); }
/************************************************************************* Destructor *************************************************************************/ DefaultLogger::~DefaultLogger(void) { if (d_pFile) { FlushCaches(); logEvent2(_T("DuiEngine::Logger singleton destroyed: (%p)"),static_cast<void*>(this)); fclose(d_pFile); } }
void DefaultLogger::setLogFilename(LPCTSTR filename, bool append) { if(d_pFile) { fclose(d_pFile); d_pFile=NULL; } d_pFile=_tfopen(filename,append?_T("a+"):_T("w")); FlushCaches(); }
// call from KERNEL thread int nlhLoadDrivers(SceModuleInfo* modInfoPtr) { // libraries load where they want, patch workaround needed LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/ifhandle.prx"); // kernel LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_inet.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_apctl.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_resolver.prx"); FlushCaches(); //REVIEW: add error checks return 0; }
//=================================== // Close the file represented by fcb //=================================== long CloseFile(struct FCB *fcb) { if (fcb->bufferIsDirty) WriteBlock(fcb->currentBlock, fcb->buffer); if (fcb->inodeIsDirty) PutINode(fcb->inodeNumber, fcb->inode); DeallocMem(fcb->buffer); DeallocMem(fcb->inode); DeallocMem(fcb); FlushCaches(); return 0; }
void Forest::CompactTopLevel() { DynArray < node_idx > *arc_temp_array; //Store the new arcs for level K arc_temp_array = new DynArray < node_idx > (0); node_idx i; arc_idx j; tail[K] = 0; //Clear the arc array int numvalidnodes = 1; //Start at 1, because 0 is valid #ifdef BRIEF_DEBUG printf("Compact Top Level\n"); #endif for (i = 1; i < last[K]; i++) UT->remove(K, i); for (i = 1; i < last[K]; i++) { //Scan throught the NODE list (except node 0) Node *nodeI = &FDDL_NODE(K, i); if (!IS_DELETED(nodeI)) { //If it's not deleted, //Copy (and compact) the arcs. int newdown = tail[K]; if (nodeI->flags & FLAG_SPARSE) { //If it's sparse, compact for (j = 0; j < nodeI->size; j++) { //its arcs this way. (*(*arc_temp_array)[tail[K]]) = SPARSE_INDEX(K, nodeI, j); (*(*arc_temp_array)[tail[K] + 1]) = SPARSE_ARC(K, nodeI, j); tail[K] += 2; } } else { //Otherwise, do it in full. for (j = 0; j < nodeI->size; j++) { (*(*arc_temp_array)[tail[K]]) = FULL_ARC(K, nodeI, j); tail[K]++; } } nodeI->down = newdown; UT->add(K, i); numvalidnodes++; } //If it IS deleted, all we do is take it out of the unique table. //It should have been "deleted downstream" earlier. } delete arcs[K]; arcs[K] = arc_temp_array; FlushCaches(K); }
// call from KERNEL thread int adhocLoadDrivers(SceModuleInfo* modInfoPtr) { #ifdef FW3X sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON); // AHMAN sceUtilityLoadNetModule(PSP_NET_MODULE_ADHOC); // AHMAN #else // libraries load where they want, patch workaround needed LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/ifhandle.prx"); // kernel LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/memab.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_adhoc_auth.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_adhoc.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_adhocctl.prx"); LoadAndStartAndPatch(modInfoPtr, "flash0:/kd/pspnet_adhoc_matching.prx"); FlushCaches(); #endif return 0; }
void Forest::PrintAddy(MDDHandle root, level k) { node_idx newRoot; level mask[K + 1]; for (int i = 0; i <= K; i++) mask[k] = 0; for (int i = 0; i < 4; i++) { mask[k - i] = 1; } newRoot = Projection(K, root.index, mask); //newRoot = ProjectVals(K, root.index, k - 3); for (level k1 = K; k1 > 0; k1--) { FlushCaches(k1); for (int i = 0; i < last[k1]; i++) { Node *child; child = &FDDL_NODE(k1, i); if (child->flags & FLAG_SHARED) child->flags = (flag)(child->flags - FLAG_SHARED); } } InternalPrintVals(K, newRoot); //Mark all nodes in Query numSolutions = 0; int *vals = new int[4]; for (int i = 0; i < 4; i++) vals[i] = (-1); for (int i = 0; i < last[k]; i++) { if (FDDL_NODE(k, i).flags & FLAG_SHARED) PrintAddy(k, i, vals, 0); } delete[]vals; printf("\n# %.0f result%s\n", numSolutions, numSolutions == 1 ? "." : "s."); }
void Forest::Compact(level k) { #ifdef BRIEF_DEBUG printf("Compact Level %d\n", k); #endif compactions++; #ifdef NOCOMPACT return; #endif //Don't compact bad levels if (k > K) return; if (k == K) { //The Top Level is special. CompactTopLevel(); return; } DynArray < node_idx > *arc_temp_array; //Store the new arcs for level k arc_temp_array = new DynArray < node_idx > (0); DynArray < Node > *node_temp_array; node_temp_array = new DynArray < Node >; //Store the nodes here //Store a mapping of old->new of node indices so that we can re-hash and also update the level above. DynArray<node_idx> *node_remap_array = new DynArray < node_idx > (0); node_idx i; arc_idx j; arc_idx arc; tail[k] = 0; //Clear the arc array int numvalidnodes = 1; //Start at 1, because 0 is valid (*(*node_remap_array)[0]) = 0; for (i = 1; i < last[k]; i++) { //Scan throught the NODE list (except node 0) Node *nodeI = &FDDL_NODE(k, i); //If it's not deleted, copy it. // if (nodeI->in > 0) if (!(nodeI->flags & FLAG_DELETED)) { //Save the "old" idx of the node //into a temp array. (*(*node_remap_array)[i]) = numvalidnodes; (*(*node_temp_array)[numvalidnodes]) = (*nodeI); //Copy (and compact) the arcs, too. int newdown = tail[k]; if (nodeI->flags & FLAG_SPARSE) { //If it's sparse, compact //its arcs this way. for (j = 0; j < nodeI->size; j++) { (*(*arc_temp_array)[tail[k]]) = SPARSE_INDEX(k, nodeI, j); (*(*arc_temp_array)[tail[k] + 1]) = SPARSE_ARC(k, nodeI, j); tail[k] += 2; } } else { //Otherwise, do it in full. for (j = 0; j < nodeI->size; j++) { (*(*arc_temp_array)[tail[k]]) = FULL_ARC(k, nodeI, j); tail[k]++; } } (*(*node_temp_array)[numvalidnodes]).down = newdown; numvalidnodes++; } else { //If it IS deleted, "DeleteDownstream" it. UT->remove(k, i); assert(nodeI->flags & FLAG_DELETED); if (k >= 2) { for (j = 0; j < nodeI->size; j++) { if (nodeI->flags & FLAG_SPARSE) arc = SPARSE_ARC(k, nodeI, j); else arc = FULL_ARC(k, nodeI, j); Node *nodeJ = &FDDL_NODE(k - 1, arc); SetArc(k, i, j, 0); //Compaction should ALWAYS be done if (nodeJ->in == 0) //Top Down so that Deletion Marking DeleteNode(k - 1, arc); //Actually Deletes -Downstream- } } } } last[k] = numvalidnodes; delete nodes[k]; nodes[k] = node_temp_array; UT->remap(k, node_remap_array); //Update all the unique table entries delete arcs[k]; arcs[k] = arc_temp_array; for (i = 1; i < last[k + 1]; i++) { //Now fix our upstairs pointers. Node *nodeI = &FDDL_NODE(k + 1, i); if (!IS_DELETED(nodeI)) { if (nodeI->flags & FLAG_SPARSE) { for (j = 0; j < nodeI->size; j++) { assert((*(*node_remap_array) [SPARSE_ARC(k + 1, nodeI, j)]) >= 0); SPARSE_ARC(k + 1, nodeI, j) = (*(*node_remap_array) [SPARSE_ARC (k + 1, nodeI, j)]); } } else { for (j = 0; j < nodeI->size; j++) { assert((*(*node_remap_array) [FULL_ARC(k + 1, nodeI, j)]) >= 0); FULL_ARC(k + 1, nodeI, j) = (*(*node_remap_array) [FULL_ARC (k + 1, nodeI, j)]); } } } } //Reinsert nodes into Unique table. Check that this does not violate //integrity with an assert. for (i = 1; i < last[k + 1]; i++) { Node *nodeI = &FDDL_NODE(k + 1, i); if ((nodeI->flags & FLAG_CHECKED_IN) && !IS_DELETED(nodeI)) { int s = UT->add(k + 1, i); //@@@DEBUG: Removed for testing. @@@// assert(s == i); } } FlushCaches(k); delete node_remap_array; }
void CKadLookup::PrepareStop() { FlushCaches(); m_StopTime = GetCurTick() + SEC2MS(GetParent<CKademlia>()->Cfg()->GetInt("RequestTimeOut")); }
/** @SYMTestCaseID TI18N-FNTSTORE-CIT-4002 @SYMTestCaseDesc This case is to test the safty of actions over the shared heap. @SYMTestActions 1. Shared heap is initialised in the constructor 2. Run rasterizing function to Flush the font caches(glyph tree and session cache). 3. Launch KNumOfProc worker processes running with random latency at beginning, which is to seach the cache from different processes. The globle chunk and font handles are passed via process environment variables. 4. Each one lasts about 1 sec. Within duration of 5 sec, if one terminates, re-launch it. @SYMTestExpectedResults Test should pass without any Panic. */ void CTFontSessionCache::RunMultiWorkerProcessL() { RProcess ProcArray[KNumOfProc]; TRequestStatus *completeStatus[KNumOfProc]; FlushCaches(); for (TInt i = 0; i < KNumOfProc; i++) { RDebug::Print(_L(">>> Launching %d..."),i); TInt err; err = ProcArray[i].Create(KWorkerProcess, KNullDesC); User::LeaveIfError(err); TInt FontOffset = reinterpret_cast<TInt>(iFont) - Base(); ProcArray[i].SetParameter(1,iChunk); ProcArray[i].SetParameter(2,FontOffset); ProcArray[i].SetParameter(3,i); completeStatus[i] = new(ELeave) TRequestStatus; CleanupStack::PushL(completeStatus[i]); *completeStatus[i] = KRequestPending; ProcArray[i].Logon(*completeStatus[i]); ProcArray[i].Resume(); //start the process } RTimer timer; timer.CreateLocal(); TRequestStatus timerStatus = KRequestPending; TTimeIntervalMicroSeconds32 timeout(KRunningTime); timer.After(timerStatus, timeout); do { User::WaitForNRequest(completeStatus, KNumOfProc); TInt i = 0; for(;i < KNumOfProc;i++ ) { if (*completeStatus[i] != KRequestPending) { break; } } TExitType exit = ProcArray[i].ExitType(); TEST(exit == EExitKill); TInt reason = ProcArray[i].ExitReason(); TEST (reason == 0); RDebug::Print(_L("<<< Close %d..."), i); ProcArray[i].Close(); RDebug::Print(_L(">>> Launching %d..."), i); TInt err; err = ProcArray[i].Create(KWorkerProcess, KNullDesC); User::LeaveIfError(err); TInt FontOffset = reinterpret_cast<TInt>(iFont) - Base(); ProcArray[i].SetParameter(1,iChunk); ProcArray[i].SetParameter(2,FontOffset); ProcArray[i].SetParameter(3,i); //run process 1 *completeStatus[i] = KRequestPending; ProcArray[i].Logon(*completeStatus[i]); ProcArray[i].Resume(); //start the process } while (timerStatus == KRequestPending); for (TInt i = 0; i < KNumOfProc; i++) { if(*completeStatus[i] == KRequestPending) { User::WaitForRequest(*completeStatus[i]); } RDebug::Print(_L("<<< Tear down Close %d..."),i); ProcArray[i].Close(); //tear down } CleanupStack::PopAndDestroy(KNumOfProc); }