diff -r 000000000000 -r a41df078684a kerneltest/e32test/misc/t_tmout.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/misc/t_tmout.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,143 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\misc\t_tmout.cpp +// +// + +#include +#include "d_rndtim.h" + +RTest test(_L("T_TMOUT")); + +_LIT(KLitThread1Name,"IsrThread"); +const TInt KThread1Priority = 56; +_LIT(KLitThread2Name,"WaitThread"); +const TInt KThread2Priority = 55; + +const TInt KTimeout = 5; // milliseconds + +volatile TUint32 RandomSignalInterval; +volatile TUint32 RandomSignalCount; +volatile TUint32 TotalCount; +volatile TUint32 TimeoutCount; +volatile TUint32 BadCount; +volatile TUint32 Bad0Count; +volatile TUint32 Bad1Count; +volatile TUint32 Calibration; + +RThread IsrT; +RThread WaitT; +RSemaphore Sem; + +TInt IsrThread(TAny*) + { + RThread me; + RRndTim rt; + TInt r = rt.Open(); + if (r!=KErrNone) + return r; + r = rt.SetPriority(me, KThread1Priority); + if (r!=KErrNone) + return r; + rt.StartTimer(); + Calibration = rt.Calibrate(1024); + r = rt.SetPriority(WaitT, KThread2Priority); + if (r!=KErrNone) + return r; + WaitT.Resume(); + RThread::Rendezvous(KErrNone); + FOREVER + { + rt.Wait(); + if (RandomSignalCount && !--RandomSignalCount) + { + RandomSignalCount = RandomSignalInterval; + Sem.Signal(); + } + } + } + +TInt WaitThread(TAny*) + { + TUint32 t1, t2; + FOREVER + { + t1 = User::NTickCount(); + TInt r = Sem.Wait(KTimeout*1000); + t2 = User::NTickCount(); + ++TotalCount; + if (r == KErrTimedOut) + { + ++TimeoutCount; + TInt d = (TInt)(t2-t1); + if (d