Update contrib.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\bench\t_ctxsw3.cpp
16 // Benchmark the inter-thread context switching.
18 // RThread, RRSemaphore.
20 // - Create a semaphore.
21 // - Create a thread (thread1) with a handle to the Semaphore and
22 // priority EPriorityLess. Verify the successful creation.
23 // - Create another thread (thread2) with a handle to the Semaphore
24 // and priority EPriorityMuchLess. Verify the successful creation.
25 // - thread1 counts the number of times the semaphore count is decremented.
26 // - thread2 counts the number of times the semaphore count is incremented.
27 // - Display the number of times the semaphore is signalled per second.
28 // Platforms/Drives/Compatibility:
30 // Assumptions/Requirement/Pre-requisites:
31 // Failures and causes:
32 // Base Port information:
38 RTest test(_L("T_CTXSW3"));
42 LOCAL_D RSemaphore StartSem;
44 LOCAL_C TInt Thread1(TAny* aSemaphore)
47 s.SetHandle((TInt)aSemaphore);
56 LOCAL_C TInt Thread2(TAny* aSemaphore)
59 s.SetHandle((TInt)aSemaphore);
68 const TInt KHeapSize=4096;
70 GLDEF_C TInt E32Main()
73 test.Start(_L("Timing inter-thread context switches..."));
75 TInt r=StartSem.CreateLocal(0);
82 r=t1.Create(_L("Thread1"),Thread1,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)sem.Handle());
84 t1.SetPriority(EPriorityLess);
85 r=t2.Create(_L("Thread2"),Thread2,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)sem.Handle());
87 t2.SetPriority(EPriorityMuchLess);
102 User::WaitForRequest(s2);
104 User::WaitForRequest(s1);
109 test.Printf(_L("%d per second\n"),count/2);