sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\misc\t_proc3a.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "u32std.h" sl@0: #include "../misc/prbs.h" sl@0: sl@0: TUint Seed[2]; sl@0: sl@0: #define PANIC(r) Panic(__LINE__,r) sl@0: void Panic(TInt aLine, TInt aCode) sl@0: { sl@0: _LIT(KLitTPROC3A,"T_PROC3A-"); sl@0: TBuf<16> b=KLitTPROC3A(); sl@0: b.AppendNum(aLine); sl@0: RProcess().Panic(b,aCode); sl@0: } sl@0: sl@0: void StartThread(TInt); sl@0: sl@0: TInt ThreadFunction(TAny* aParam) sl@0: { sl@0: TInt p=(TInt)aParam; sl@0: FOREVER sl@0: { sl@0: TProcessPriority pp=(p&1)?EPriorityForeground:EPriorityBackground; sl@0: RProcess().SetPriority(pp); sl@0: ++p; sl@0: StartThread(p); sl@0: User::AfterHighRes(1); sl@0: } sl@0: } sl@0: sl@0: void StartThread(TInt aParam) sl@0: { sl@0: RThread t; sl@0: TInt r=t.Create(KNullDesC(),ThreadFunction,0x1000,NULL,(TAny*)aParam); sl@0: if (r!=KErrNone) sl@0: PANIC(r); sl@0: t.Resume(); sl@0: t.Close(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf<256> cmd; sl@0: User::CommandLine(cmd); sl@0: TLex lex(cmd); sl@0: TUint param1; sl@0: TInt r=lex.Val(param1,EHex); sl@0: if (r!=KErrNone) sl@0: PANIC(r); sl@0: Seed[0]=param1; sl@0: Seed[1]=0; sl@0: StartThread(0); sl@0: TUint x=Random(Seed); sl@0: x&=63; sl@0: x+=2; sl@0: User::AfterHighRes(x); sl@0: RProcess().Kill(param1); sl@0: return 0; sl@0: }