0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\misc\t_proc3a.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
#include "u32std.h"
|
|
21 |
#include "../misc/prbs.h"
|
|
22 |
|
|
23 |
TUint Seed[2];
|
|
24 |
|
|
25 |
#define PANIC(r) Panic(__LINE__,r)
|
|
26 |
void Panic(TInt aLine, TInt aCode)
|
|
27 |
{
|
|
28 |
_LIT(KLitTPROC3A,"T_PROC3A-");
|
|
29 |
TBuf<16> b=KLitTPROC3A();
|
|
30 |
b.AppendNum(aLine);
|
|
31 |
RProcess().Panic(b,aCode);
|
|
32 |
}
|
|
33 |
|
|
34 |
void StartThread(TInt);
|
|
35 |
|
|
36 |
TInt ThreadFunction(TAny* aParam)
|
|
37 |
{
|
|
38 |
TInt p=(TInt)aParam;
|
|
39 |
FOREVER
|
|
40 |
{
|
|
41 |
TProcessPriority pp=(p&1)?EPriorityForeground:EPriorityBackground;
|
|
42 |
RProcess().SetPriority(pp);
|
|
43 |
++p;
|
|
44 |
StartThread(p);
|
|
45 |
User::AfterHighRes(1);
|
|
46 |
}
|
|
47 |
}
|
|
48 |
|
|
49 |
void StartThread(TInt aParam)
|
|
50 |
{
|
|
51 |
RThread t;
|
|
52 |
TInt r=t.Create(KNullDesC(),ThreadFunction,0x1000,NULL,(TAny*)aParam);
|
|
53 |
if (r!=KErrNone)
|
|
54 |
PANIC(r);
|
|
55 |
t.Resume();
|
|
56 |
t.Close();
|
|
57 |
}
|
|
58 |
|
|
59 |
GLDEF_C TInt E32Main()
|
|
60 |
{
|
|
61 |
TBuf<256> cmd;
|
|
62 |
User::CommandLine(cmd);
|
|
63 |
TLex lex(cmd);
|
|
64 |
TUint param1;
|
|
65 |
TInt r=lex.Val(param1,EHex);
|
|
66 |
if (r!=KErrNone)
|
|
67 |
PANIC(r);
|
|
68 |
Seed[0]=param1;
|
|
69 |
Seed[1]=0;
|
|
70 |
StartThread(0);
|
|
71 |
TUint x=Random(Seed);
|
|
72 |
x&=63;
|
|
73 |
x+=2;
|
|
74 |
User::AfterHighRes(x);
|
|
75 |
RProcess().Kill(param1);
|
|
76 |
return 0;
|
|
77 |
}
|