void DmacSim::StopEmulation() { TInt orig = __e32_atomic_tas_ord32(&StartStop, (TInt)EDmaSimStarted, (TInt)EDmaSimStopping, 0); if (orig == EDmaSimIdle) return; // wasn't running // loop until we succeed in cancelling the timer or the timer callback // notices that we are shutting down while (!Timer.Cancel() && __e32_atomic_load_acq32(&StartStop)!=EDmaSimIdle) {} __e32_atomic_store_ord32(&StartStop, EDmaSimIdle); }
void FMTest1PInterfererThread(TAny* a) { SFMTest1Info& info = *(SFMTest1Info*)a; NThread* pC = NKern::CurrentThread(); TEST_PRINT1("Thread %T start", pC); TUint32 seed[2] = {(TUint32)pC, 0}; NThread* t0 = info.iThreads[0]; TInt n = 0; while (!__e32_atomic_load_acq32(&info.iStop)) { while (!__e32_atomic_load_acq32(&info.iStop) && t0->iPriority != 11) __chill(); TUint32 x = random(seed) & 2047; while(x) { __e32_atomic_add_ord32(&x, TUint32(-1)); } if (__e32_atomic_load_acq32(&info.iStop)) break; NKern::ThreadSetPriority(t0, 9); ++n; } TEST_PRINT2("Thread %T ran %d times", pC, n); }
void CEglTest_TestStep_StressLoad::LoadGpuProcessorL() { CSurface *surface = CSurface::SurfaceFactoryL(ESurfTypeEglWindow); CleanupStack::PushL(surface); surface->CreateL(EStandard128sqSurface, TPoint(128, 128)); TRgb bg = TRgb(0x55, 0x88, 0xff); // Cyan/turqoise-ish. TRgb fg = TRgb(0xff, 0x11, 0x22); // Red (sort of) while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuProcessor])) { surface->DrawContentL(bg); surface->DrawComplexL(fg); surface->SubmitContent(ETrue); } CleanupStack::PopAndDestroy(surface); eglReleaseThread(); }
void CEglTest_TestStep_StressLoad::LoadGpuMemoryL() { const TInt KMaxSurfaceAllocs = 1000; CSurface **surfaces = new CSurface*[KMaxSurfaceAllocs]; ENGINE_ASSERT(surfaces); TInt nSurfaces = 0; TInt err; while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuMemory])) { ENGINE_ASSERT(nSurfaces < KMaxSurfaceAllocs); CSurface* s = CSurface::SurfaceFactoryL(ESurfTypePBuffer); if (s) { TRAP(err, s->CreateL(ELargeSurface)); if (err == KErrNone) { surfaces[nSurfaces++] = s; TRAP(err, s->DrawContentL(TRgb(0x10, 0x20, 0xB0))); } else { delete s; s = NULL; } } if (!s) { User::After(100 * 1000); TInt nRelease = nSurfaces / 4; for(TInt i = 0; i < nRelease; i++) { delete surfaces[--nSurfaces]; surfaces[nSurfaces] = NULL; } User::After(100 * 1000); // 100 ms. } } while(nSurfaces) { delete surfaces[--nSurfaces]; } delete [] surfaces; eglReleaseThread(); }
void DPowerManager::ShutDownTimeoutFn(TAny* aArg) { __KTRACE_OPT(KPOWER,Kern::Printf(">DPowerManager::ShutDownTimeoutFn")); NFastSemaphore* sem = (NFastSemaphore*)aArg; #ifdef _DEBUG_POWER NKern::FSSignal(sem); #else TUint SignalCount = __e32_atomic_load_acq32(&(PowerManager->iPendingShutdownCount)); DPowerHandler* ph = PowerManager->iHandlers; do { ph->iSem = NULL; ph = ph->iPrev; }while(ph != PowerManager->iHandlers); __e32_atomic_store_rel32(&(PowerManager->iPendingShutdownCount), (TUint)ESHUTDOWN_TIMEOUT); // = -1 NKern::FSSignalN(sem,SignalCount); __KTRACE_OPT(KPOWER,Kern::Printf("<DPowerManager::ShutDownTimeoutFn")); #endif }
// Test thread, just looks for flags being set void TiedEventThread(TAny*) { TInt cpu, i, j; TUint32 set=0; for_each_cpu(cpu) { NKern::ThreadSetCpuAffinity(NKern::CurrentThread(), cpu); for (i=0; i<LoopCount; ++i) { for (j=0; j<FlagCount; ++j) if (__e32_atomic_load_acq32(&Flags[j])) ++set; } } __e32_atomic_add_ord32(&FlagsSet, set); NKern::FSSignal(DoneSem); NKern::WaitForAnyRequest(); }
TBool DmacSim::InISR() { return __e32_atomic_load_acq32(&StartStop) & EDmaSimInISR; }
// Used for IDFC case as the timer function void IDfcQFn(TAny*) { IDfc->Add(); if (!__e32_atomic_load_acq32(&Done)) Timer->OneShot(10); }
// Used for timer/interrupt cases as the timer function void TimerFn(TAny*) { FiddleFlags(NULL); if (!__e32_atomic_load_acq32(&Done)) Timer->OneShot(10); }
TInt DPowerManager::PowerDown() { // called by ExecHandler __KTRACE_OPT(KPOWER,Kern::Printf(">PowerManger::PowerDown(0x%x) Enter", iPowerController->iTargetState)); __ASSERT_CRITICAL; Lock(); if (iPowerController->iTargetState == EPwActive) { Unlock(); return KErrNotReady; } __PM_ASSERT(iHandlers); NFastSemaphore shutdownSem(0); NTimer ntimer; TDfc dfc(ShutDownTimeoutFn, &shutdownSem); #ifndef _DEBUG_POWER iPendingShutdownCount = 0; #endif DPowerHandler* ph = iHandlers; //Power down in reverse order of handle registration. do { #ifdef _DEBUG_POWER __PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone)); #endif ph->iSem = &shutdownSem; ph->PowerDown(iPowerController->iTargetState); #ifndef _DEBUG_POWER iPendingShutdownCount++; #else if(iPslShutdownTimeoutMs>0) { // Fire shut down timeout timer ntimer.OneShot(iPslShutdownTimeoutMs, dfc); } NKern::FSWait(&shutdownSem); // power down drivers one after another to simplify debug __e32_atomic_and_ord32(&(ph->iStatus), ~DPowerHandler::EDone); // timeout condition if(iPslShutdownTimeoutMs>0 && ph->iSem) { __e32_atomic_store_ord_ptr(&ph->iSem, 0); } ntimer.Cancel(); #endif ph = ph->iPrev; }while(ph != iHandlers); #ifndef _DEBUG_POWER if(iPslShutdownTimeoutMs>0) { // Fire shut down timeout timer ntimer.OneShot(iPslShutdownTimeoutMs, dfc); } ph = iHandlers; do { NKern::FSWait(&shutdownSem); if(__e32_atomic_load_acq32(&iPendingShutdownCount)==ESHUTDOWN_TIMEOUT) { iPendingShutdownCount = 0; NKern::Lock(); shutdownSem.Reset(); // iPendingShutdownCount could be altered while ShutDownTimeoutFn is running // reset it to make sure shutdownSem is completely clean. NKern::Unlock(); break; } __e32_atomic_add_ord32(&iPendingShutdownCount, (TUint)(~0x0)); // iPendingShutDownCount--; ph = ph->iPrev; }while(ph != iHandlers); ntimer.Cancel(); #endif TTickQ::Wait(); iPowerController->PowerDown(K::SecondQ->WakeupTime()); __PM_ASSERT(iPowerController->iTargetState != EPwOff); iPowerController->iTargetState = EPwActive; K::SecondQ->WakeUp(); TTickQ::Signal(); NFastSemaphore powerupSem(0); ph = iHandlers->iNext; //Power up in same order of handle registration. do { #ifdef _DEBUG_POWER __PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone)); #endif ph->iSem = &powerupSem; ph->PowerUp(); #ifdef _DEBUG_POWER NKern::FSWait(&powerupSem); // power down drivers one after another to simplify debug __PM_ASSERT(!ph->iSem); __PM_ASSERT(ph->iStatus & DPowerHandler::EDone); ph->iStatus &= ~DPowerHandler::EDone; #endif ph = ph->iNext; }while(ph != iHandlers->iNext); #ifndef _DEBUG_POWER ph = iHandlers->iNext; do { NKern::FSWait(&powerupSem); ph = ph->iNext; }while(ph != iHandlers->iNext); #endif // complete wakeup notification request if any NotifyWakeupEvent(KErrNone); Unlock(); __KTRACE_OPT(KPOWER,Kern::Printf("<PowerManger::PowerDown() Leave")); return KErrNone; }