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_ramuse.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: struct SThread sl@0: { sl@0: TUint iId; sl@0: HBufC* iFullName; sl@0: TInt iHandles; sl@0: }; sl@0: sl@0: struct SProcess sl@0: { sl@0: TUint iId; sl@0: HBufC* iFullName; sl@0: TInt iHandles; sl@0: }; sl@0: sl@0: LOCAL_D RTest test(_L("T_RAMUSE")); sl@0: LOCAL_D RArray Threads; sl@0: LOCAL_D RArray Processes; sl@0: sl@0: LOCAL_C void GetProcessInfo() sl@0: { sl@0: TFindProcess fp(_L("*")); sl@0: TFullName fn; sl@0: while (fp.Next(fn)==KErrNone) sl@0: { sl@0: RProcess p; sl@0: TInt r=p.Open(fp); sl@0: if (r!=KErrNone) sl@0: continue; sl@0: SProcess pInfo; sl@0: TProcessId pid=p.Id(); sl@0: pInfo.iId=*((TUint*)&pid); sl@0: pInfo.iFullName=fn.Alloc(); sl@0: pInfo.iHandles=-1; sl@0: p.Close(); sl@0: Processes.InsertInUnsignedKeyOrder(pInfo); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void GetThreadInfo() sl@0: { sl@0: TFindThread ft(_L("*")); sl@0: TFullName fn; sl@0: while (ft.Next(fn)==KErrNone) sl@0: { sl@0: RThread t; sl@0: TInt r=t.Open(ft); sl@0: if (r!=KErrNone) sl@0: continue; sl@0: SThread tInfo; sl@0: TThreadId tid=t.Id(); sl@0: tInfo.iId=*((TUint*)&tid); sl@0: tInfo.iFullName=fn.Alloc(); sl@0: TInt tHandles; sl@0: TInt pHandles; sl@0: t.HandleCount(pHandles,tHandles); sl@0: tInfo.iHandles=tHandles; sl@0: RProcess p; sl@0: r=t.Process(p); sl@0: if (r==KErrNone) sl@0: { sl@0: TProcessId pid=p.Id(); sl@0: SProcess pInfo; sl@0: pInfo.iId=*((TUint*)&pid); sl@0: TInt i; sl@0: r=Processes.FindInUnsignedKeyOrder(pInfo,i); sl@0: if (r==KErrNone) sl@0: { sl@0: if (Processes[i].iHandles<0) sl@0: Processes[i].iHandles=pHandles; sl@0: } sl@0: p.Close(); sl@0: } sl@0: t.Close(); sl@0: Threads.InsertInUnsignedKeyOrder(tInfo); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void DisplayProcessInfo() sl@0: { sl@0: TInt n=Processes.Count(); sl@0: TInt i; sl@0: test.Printf(_L("%d Processes:\n"),n); sl@0: for (i=0; i