コード例 #1
0
ファイル: dmasim.cpp プロジェクト: kuailexs/symbiandump-os1
void DmacSim::TickCB(TAny*)
	{
	TInt orig = (TInt)__e32_atomic_ior_acq32(&StartStop, EDmaSimInISR);
	if (orig >= 0)
		{
		DmacSb::DoTransfer();
		DmacDb::DoTransfer();
		DmacSg::DoTransfer();
		}
	orig = (TInt)__e32_atomic_and_rel32(&StartStop, (TUint32)~EDmaSimInISR);
	if (orig < 0)
		{
		__e32_atomic_store_rel32(&StartStop, EDmaSimIdle);
		return;
		}
	TInt r = Timer.Again(KPeriod);
	if (r == KErrArgument)
		r = Timer.OneShot(KPeriod);
	__DMA_ASSERTA(r == KErrNone);
	}
コード例 #2
0
ファイル: power.cpp プロジェクト: kuailexs/symbiandump-os1
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
	}
コード例 #3
0
void TiedEventTest(TBool aTied, TInt aThreads, TTiedMode aMode)
	{
	TEST_PRINT3("TiedEventTest aTied=%d aThreads=%d aMode=%d", aTied, aThreads, aMode);

	// Set up shared parameters
	memclr((void*)&Flags,sizeof(Flags));
	Done = EFalse;
	FlagsSet = 0;

	// Create test threads to check data
	NFastSemaphore exitSem(0);
	NFastSemaphore doneSem(0);
	DoneSem = &doneSem;
	char name[5]={0x54, 0x45, 0x54, 0x31, 0};
	TInt i;
	NSchedulable* tieTo = NULL;
	NThread* t[16];
	NThreadGroup* group = NULL;
	if (aThreads == 1)
		{
		t[0] = CreateUnresumedThreadSignalOnExit(name, TiedEventThread, 10, NULL, 0, KSmallTimeslice, &exitSem, KCpuAffinityAny);
		if (aTied)
			tieTo = t[0];
		}
	else
		{
		group = &TG;
		if (aTied)
			tieTo = group;
		SNThreadGroupCreateInfo ginfo;
		ginfo.iCpuAffinity = KCpuAffinityAny;
		TInt r = NKern::GroupCreate(group, ginfo);
		TEST_RESULT(r==KErrNone, "Failed creating group");
		for (i=0; i<aThreads; ++i)
			{
			t[i] = CreateUnresumedThreadSignalOnExit(name, TiedEventThread, 10, NULL, 0, KSmallTimeslice, &exitSem, KCpuAffinityAny, group);
			++name[3];
			}
		}

#ifndef __X86__
	// Tie the system timer interrupt to the thread if we're testing interrupts
	// This means the timer function should always be exclusive with the theads
	// even though it's not tied itself.
	if (aMode == EInterrupt && tieTo)
		HijackSystemTimer(tieTo);
#endif

	// Create the IDFC
	NSchedulable* tieDFC = aMode == EIDFC ? tieTo : NULL;
	TDfc idfc(tieDFC, FiddleFlags, NULL);
	IDfc = &idfc;

	// Create and start NTimer
	// If we're testing timers it will be tied itself
	// If we're testing interrupts it will not be tied itself but will still run
	// exclusively because the interrupt is tied
	// If we're testing IDFCs it's just used to repeatedly queue the IDFC and
	// where the timer itself runs is irrelevant.
	NSchedulable* tieTimer = aMode == ETimer ? tieTo : NULL;
	NTimerFn timerfn = aMode == EIDFC ? IDfcQFn : TimerFn;
	NTimer timer(tieTimer, timerfn, NULL);
	Timer = &timer;
	timer.OneShot(10);

	// Resume threads
	for (i=0; i<aThreads; ++i)
		NKern::ThreadResume(t[i]);

	// Wait for threads to be done
	for (i=0; i<aThreads; ++i)
		NKern::FSWait(&doneSem);

	// Tell timer to stop requeueing itself
	__e32_atomic_store_rel32(&Done, ETrue);
	NKern::Sleep(100);

#ifndef __X86__
	// Restart the normal system timer if we're testing interrupts
	// as otherwise it will get unbound when the thing it's tied to
	// dies.
	if (aMode == EInterrupt && tieTo)
		HijackSystemTimer(NULL);
#endif

	// Clean up threads/group
	for (i=0; i<aThreads; ++i)
		{
		NKern::ThreadRequestSignal(t[i]);
		NKern::FSWait(&exitSem);
		}
	if (group)
		NKern::GroupDestroy(group);

	// Check that the flag was ok
	TEST_PRINT1("Flag was set %d times", FlagsSet);
	if (aTied)
		TEST_RESULT(FlagsSet == 0, "Flag was set, shouldn't be");
	else
		TEST_RESULT(FlagsSet > 0, "Flag wasn't set, test broken?");
	}
コード例 #4
0
void NFastMutexX::Create()
	{
	iMutex = new NFastMutex;
	TEST_OOM(iMutex);
	__e32_atomic_store_rel32(&iRefCount, 1);
	}