コード例 #1
0
void FMTest1P()
	{
	TEST_PRINT("Testing priority change");
	if (NKern::NumberOfCpus()==1)
		return;

	NFastSemaphore exitSem(0);
	SFMTest1Info* pI = new SFMTest1Info;
	TEST_OOM(pI);
	memclr(pI, sizeof(SFMTest1Info));
	TEST_PRINT1("Info@0x%08x", pI);
	pI->iBlockSize = 256;
	pI->iBlock = (TUint32*)malloc(pI->iBlockSize*sizeof(TUint32));
	TEST_OOM(pI->iBlock);
	pI->iPriorityThreshold = 9;
	pI->iBlock[0] = 0;
	setup_block((TUint32*)pI->iBlock, pI->iBlockSize);
	pI->iStop = FALSE;
	TInt cpu;
	TInt threadCount = 0;
	TInt pri = 9;
	char name[16] = "FMTest1P.0";
	for_each_cpu(cpu)
		{
		name[9] = (char)(threadCount + '0');
		if (cpu==1)
			pI->iThreads[threadCount] = CreateThreadSignalOnExit("FMTest1PInterferer", &FMTest1PInterfererThread, 12, pI, 0, KSmallTimeslice, &exitSem, 1);
		else
			pI->iThreads[threadCount] = CreateThreadSignalOnExit(name, &FMTest1Thread, pri, pI, 0, KSmallTimeslice, &exitSem, cpu);
		pri = 10;
		threadCount++;
		}
	TUint32 b0 = 0xffffffffu;
	FOREVER
		{
		NKern::Sleep(1000);
		TUint32 b = pI->iBlock[0];
		TEST_PRINT1("%d", b);
		if (b > 1048576)
			{
			pI->iStop = TRUE;
			break;
			}
		if (b == b0)
			{
			__crash();
			}
		b0 = b;
		}
	while (threadCount--)
		NKern::FSWait(&exitSem);
	TEST_PRINT1("Total iterations %d", pI->iBlock[0]);
	free((TAny*)pI->iBlock);
	free(pI);
	}
コード例 #2
0
// Destructor should never be called
TNaviEngineWatchdog::~TNaviEngineWatchdog()
	{
	__crash();
	}
コード例 #3
0
ファイル: nk_timer.cpp プロジェクト: kuailexs/symbiandump-os1
TBool NTimer::DoCancelMutating(TUint aFlags)
	{
	CHECK_PRECONDITIONS(MASK_NOT_ISR,"NTimer::Cancel (mutating NTimer)");
	TSubScheduler& ss0 = SubScheduler();
	TBool wait = FALSE;
	TInt cpu = -1;
	TBool result = TRUE;
	TDfc* d = (TDfc*)this;
	NKern::Lock();
	TDfcQue* q = iDfcQ;
	NThreadBase* t = q->iThread;
	t->AcqSLock();
	TheTimerQ.iTimerSpinLock.LockIrq();

	// 0000->0000, XX00->ZZ00, xxYY->zzYY
	TUint state = d->CancelInitialStateChange();
	if (state & 0xFF00)
		{
		// someone else cancelling at the same time - just wait for them to finish
		// they can only be waiting for the cancel IPI
		result = FALSE;
		wait = TRUE;
		goto end;
		}
	if (state == 0)	// timer was not active
		{
		result = FALSE;
		goto end;
		}
	if (state>=ETransferring && state<=EFinal)
		{
		DoCancel0(state);
		// cancel is complete
		goto reset;
		}
	if (state==1)
		{
		// on DFC final queue
		q->Remove((TPriListLink*)this);
		goto reset;
		}
	// must be on IDFC queue - need to send cancel IPI
	__NK_ASSERT_ALWAYS((state>>5)==4);
	cpu = state & 0x1f;
	if (TUint(cpu) == ss0.iCpuNum)
		{
		// it's on this CPU's IDFC queue so just dequeue it and finish
		Deque();
		cpu = -1;
reset:
		d->ResetState();	// release semantics
		}
end:
	if (aFlags & ECancelDestroy)
		iHType = EEventHandlerDummy;
	TheTimerQ.iTimerSpinLock.UnlockIrq();
	t->RelSLock();
	if (cpu>=0)
		{
		TCancelIPI ipi;
		ipi.Send(d, cpu);
		ipi.WaitCompletion();
		wait = TRUE;
		}
	if (wait)
		{
		TUint n = 0x01000000;
		while ((i8816.iHState16>>8) & ss0.iCpuMask)
			{
			__chill();
			if (!--n)
				__crash();
			}
		}
	NKern::Unlock();
	return result;
	}