sl@0: // Copyright (c) 2002-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\smpsoak\t_smpsoakprocess.cpp sl@0: sl@0: // User Includes sl@0: #include "t_smpsoak.h" sl@0: sl@0: #define PRINT(args)\ sl@0: if (!TestSilent)\ sl@0: test.Printf args sl@0: sl@0: void ParseCmdLine(); sl@0: sl@0: //class for soak process and same executable(t_smpsoakprocess.exe) will be lauched with different process operation sl@0: //Example: IPC Read, IPC Write, File Process, Timer Process sl@0: class CSMPSoakProcess sl@0: { sl@0: public: sl@0: CSMPSoakProcess(); sl@0: ~CSMPSoakProcess(); sl@0: void CreateThread(TPtrC aThreadType); sl@0: private: sl@0: //Thread Functions sl@0: static TInt FileThread(TAny*); sl@0: static TInt TimerThread(TAny*); sl@0: static TInt MemoryThread(TAny*); sl@0: private: sl@0: // Thread member functions sl@0: TInt DoFileThread(); sl@0: TInt DoTimerThread(); sl@0: TInt DoMemoryThread(); sl@0: void DoCreateThread(TAny*); sl@0: void ResumeThread(); sl@0: //IPC's sl@0: void WriteProcess(); sl@0: void ReadProcess(); sl@0: //Thread Priority sl@0: void SetThreadPriority(); sl@0: //Utils for soak process sl@0: void SetSoakProcessPriority(); sl@0: void CommitChunk(RChunk& aChunk, TInt aSize); sl@0: void ReadChunk(RChunk& aChunk, TInt aSize); sl@0: void WriteToChunk(RChunk& aChunk, TInt aSize); sl@0: void DeleteChunk(RChunk& aChunk); sl@0: private: sl@0: //Thread tables sl@0: static TThread KOOMemoryTable[]; sl@0: static TThread KFileTable[]; sl@0: static TThread KTimerTable[]; sl@0: private: sl@0: TThreadData iThreadData; sl@0: RThread iThread; sl@0: TInt iPriority; sl@0: }; sl@0: sl@0: //Memory thread data sl@0: TThread CSMPSoakProcess::KOOMemoryTable[] = sl@0: { sl@0: { _L("SMPOOMemoryThread1"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLowNormal, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}}, sl@0: { _L("SMPOOMemoryThread2"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}}, sl@0: { _L("SMPOOMemoryThread3"), CSMPSoakProcess::MemoryThread, {{EPriorityMore, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}}, sl@0: { _L("SMPOOMemoryThread4"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}}, sl@0: }; sl@0: sl@0: //File thread data sl@0: TThread CSMPSoakProcess::KFileTable[] = sl@0: { sl@0: { _L("SMPFileThread1"), CSMPSoakProcess::FileThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 11, 5}}, sl@0: { _L("SMPFileThread2"), CSMPSoakProcess::FileThread, {{EPriorityNormal, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 22, 10}}, sl@0: { _L("SMPFileThread3"), CSMPSoakProcess::FileThread, {{EPriorityMore, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 33, 15}}, sl@0: { _L("SMPFileThread4"), CSMPSoakProcess::FileThread, {{EPriorityAbsoluteVeryLow, EPriorityMore, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 44, 20}}, sl@0: }; sl@0: sl@0: //Timer thread data sl@0: TThread CSMPSoakProcess::KTimerTable[] = sl@0: { sl@0: { _L("SMPTimerThread1"), CSMPSoakProcess::TimerThread, {{EPriorityAbsoluteLowNormal, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 1000, 2, NULL, NULL,NULL}}, sl@0: { _L("SMPTimerThread2"), CSMPSoakProcess::TimerThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 1500, 2, NULL, NULL,NULL}}, sl@0: }; sl@0: //Constructor sl@0: CSMPSoakProcess::CSMPSoakProcess() sl@0: { sl@0: } sl@0: //Destructor sl@0: CSMPSoakProcess::~CSMPSoakProcess() sl@0: { sl@0: } sl@0: //Set the process priority each time for each process sl@0: void CSMPSoakProcess::SetSoakProcessPriority() sl@0: { sl@0: RProcess proc; sl@0: TInt priority; sl@0: static TInt priorityindex = 0; sl@0: static const TProcessPriority priorityTable[]= sl@0: { sl@0: EPriorityLow, sl@0: EPriorityBackground, sl@0: EPriorityForeground, sl@0: EPriorityHigh sl@0: }; sl@0: if(++priorityindex >= 4) sl@0: priorityindex=0; sl@0: priority = priorityTable[priorityindex]; sl@0: proc.SetPriority((TProcessPriority)priority); sl@0: PRINT((_L("Process Priority:%d \n"),proc.Priority())); sl@0: } sl@0: //Changes the thread priority each time time, for each thread by Random, Increment, from List, Fixed. sl@0: //pick up the priority option from thread table sl@0: void CSMPSoakProcess::SetThreadPriority() sl@0: { sl@0: static TInt64 randSeed = KRandSeed; sl@0: static const TThreadPriority priorityTable[]= sl@0: { sl@0: EPriorityMuchLess, EPriorityLess, EPriorityNormal, EPriorityMore, EPriorityMuchMore, sl@0: EPriorityRealTime, EPriorityRealTime, EPriorityAbsoluteVeryLow, EPriorityAbsoluteLowNormal, sl@0: EPriorityAbsoluteLow, EPriorityAbsoluteBackgroundNormal, EPriorityAbsoluteBackground, sl@0: EPriorityAbsoluteForegroundNormal, EPriorityAbsoluteForeground, EPriorityAbsoluteHighNormal, EPriorityAbsoluteHigh sl@0: }; sl@0: TInt priorityIndex = 0; sl@0: switch (iThreadData.threadPriorityChange) sl@0: { sl@0: case EpriorityFixed: sl@0: break; sl@0: sl@0: case EPriorityList: sl@0: if (++iPriority >= KPriorityOrder) sl@0: iPriority = 0; sl@0: if (iThreadData.threadPriorities[iPriority] == 0) sl@0: iPriority = 0; sl@0: // PRINT(_L("SetPriority List CPU %d index %d priority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread),iPriority, iThreadData.threadPriorities[iPriority]); sl@0: iThread.SetPriority((TThreadPriority)iThreadData.threadPriorities[iPriority]); sl@0: break; sl@0: sl@0: case EPriorityIncrement: sl@0: while (priorityTable[priorityIndex] <= iPriority) sl@0: { sl@0: priorityIndex++; sl@0: } sl@0: iPriority = priorityTable[priorityIndex]; sl@0: if (iPriority > iThreadData.threadPriorities[2]) sl@0: iPriority = iThreadData.threadPriorities[1]; sl@0: // PRINT(_L("SetPriority Increment CPU %d priority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread), iPriority); sl@0: iThread.SetPriority((TThreadPriority)iPriority); sl@0: break; sl@0: sl@0: case EPriorityRandom: sl@0: iPriority = Math::Rand(randSeed) % (iThreadData.threadPriorities[2] - iThreadData.threadPriorities[1] + 1); sl@0: iPriority += iThreadData.threadPriorities[1]; sl@0: while (priorityTable[priorityIndex] < iPriority) sl@0: { sl@0: priorityIndex++; sl@0: } sl@0: iPriority = priorityTable[priorityIndex]; sl@0: // PRINT(_L("SetPriority Random CPU %d iPriority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread), iPriority); sl@0: iThread.SetPriority((TThreadPriority)iPriority); sl@0: break; sl@0: } sl@0: } sl@0: //Resume each thread sl@0: void CSMPSoakProcess::ResumeThread() sl@0: { sl@0: iThread.Resume(); sl@0: } sl@0: // CSMPSoakProcess Thread Creation. sl@0: // @param aThread thread table data sl@0: void CSMPSoakProcess::DoCreateThread(TAny* aThread) sl@0: { sl@0: //Initialize each thread data sl@0: iThreadData = ((TThread*)aThread)->threadData; sl@0: test.Next(_L("Create Thread")); sl@0: PRINT ((_L("%s CPU affinity %d Priority %d\n"),((TThread*)aThread)->threadName.Ptr(),iThreadData.cpuAffinity,iThreadData.threadPriorities[0])); sl@0: TInt r = iThread.Create(((TThread*)aThread)->threadName, ((TThread*)aThread)->threadFunction, KDefaultStackSize, KHeapMinSize, KHeapMaxSize,(TAny*)this); sl@0: test_KErrNone(r); sl@0: if (iThreadData.threadPriorityChange == EPriorityList) sl@0: { sl@0: iPriority = 0; sl@0: } sl@0: else sl@0: { sl@0: iPriority = iThreadData.threadPriorities[0]; sl@0: } sl@0: iThread.SetPriority((TThreadPriority)iThreadData.threadPriorities[0]); sl@0: //Set the thread CPU Affinity sl@0: gSMPStressDrv.ChangeThreadAffinity(&iThread, iThreadData.cpuAffinity); sl@0: } sl@0: //Commit the chunk with aSize sl@0: void CSMPSoakProcess::CommitChunk(RChunk& aChunk, TInt aSize) sl@0: { sl@0: //PRINT ((_L("Commit Chunk \n"))); sl@0: test_KErrNone(aChunk.Adjust(aSize)); sl@0: } sl@0: //Write some data into the chunk sl@0: void CSMPSoakProcess::WriteToChunk(RChunk& aChunk, TInt aSize) sl@0: { sl@0: TUint8 *writeaddr = aChunk.Base(); sl@0: TPtr8 write(writeaddr,aSize); sl@0: write.Fill('S',aSize); sl@0: write.Copy(memData); sl@0: } sl@0: //Read the data from chunk and verify sl@0: void CSMPSoakProcess::ReadChunk(RChunk& aChunk, TInt aSize) sl@0: { sl@0: TUint8 *readaddr = aChunk.Base(); sl@0: TPtr8 read(readaddr,aSize); sl@0: test_KErrNone(read.Compare(memData)); sl@0: } sl@0: //Cleaunup chunk sl@0: void CSMPSoakProcess::DeleteChunk(RChunk& aChunk) sl@0: { sl@0: test_KErrNone(aChunk.Adjust(0)); sl@0: } sl@0: //IPC Read operation sl@0: void CSMPSoakProcess::ReadProcess() sl@0: { sl@0: RTest test(_L("SMPSoakReadProcess")); sl@0: FOREVER sl@0: { sl@0: // SetSoakProcessPriority(); sl@0: gWriteSem.Wait(); //Wait for write completion sl@0: PRINT((_L("Read Chunk\n"))); sl@0: ReadChunk( gChunk,KChunkSize); sl@0: PRINT((_L("Delete Chunk\n"))); sl@0: DeleteChunk(gChunk); sl@0: gReadSem.Signal(); //Read completion sl@0: } sl@0: } sl@0: //IPC Write operation sl@0: void CSMPSoakProcess::WriteProcess() sl@0: { sl@0: RTest test(_L("SMPSoakWriteProcess")); sl@0: FOREVER sl@0: { sl@0: // SetSoakProcessPriority(); sl@0: CommitChunk( gChunk, KChunkSize); sl@0: PRINT((_L("Write To Chunk\n"))); sl@0: WriteToChunk( gChunk,KChunkSize); sl@0: gWriteSem.Signal(); //Write completion sl@0: gReadSem.Wait(); //Wait for read completion sl@0: } sl@0: } sl@0: //File Thread - creates Dir's, Files, Fileread, Filewrite and verify sl@0: //param aSoakThread - CSMPSoakUtil pointer sl@0: TInt CSMPSoakProcess::FileThread(TAny* aSoakThread) sl@0: { sl@0: CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread; sl@0: __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::TimerThread Panic"),0)); sl@0: return self->DoFileThread(); sl@0: } sl@0: //Member Filethread sl@0: TInt CSMPSoakProcess::DoFileThread() sl@0: { sl@0: RTest test(_L("SMPFileThread")); sl@0: TInt r = KErrNone; sl@0: sl@0: TFileName sessionPath; sl@0: TBuf8 fileData; sl@0: fileData.Copy(KFileData); sl@0: RFs fs; sl@0: RFile file; sl@0: sl@0: TBuf filename; sl@0: TBuf directory; sl@0: TBuf tempdir; sl@0: sl@0: //Setup Dir structure sl@0: tempdir.Format(KDir,iThreadData.dirID); sl@0: test_KErrNone(fs.Connect()); sl@0: sessionPath=KSessionPath; sl@0: TChar driveLetter; sl@0: sl@0: //Setup Drive and Session sl@0: test_KErrNone(fs.DriveToChar(EDriveD,driveLetter)); sl@0: sessionPath[0]=(TText)driveLetter; sl@0: test_KErrNone(fs.SetSessionPath(sessionPath)); sl@0: test.Printf(_L("SessionPath=%S\n"),&sessionPath); sl@0: directory=sessionPath; sl@0: directory.Append(tempdir); sl@0: PRINT((_L("Dir Level =%S Creation\n"),&directory)); sl@0: sl@0: FOREVER sl@0: { sl@0: r= fs.MkDirAll(directory); sl@0: test(r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: //Create Number of files then write data into it. sl@0: for (TInt i = 0; i < iThreadData.numFile; i++) sl@0: { sl@0: filename.Format(KFile,iThreadData.dirID,i); sl@0: PRINT((_L("File = %S Write\n"),&filename)); sl@0: test_KErrNone(file.Create(fs,filename,EFileWrite)); sl@0: test_KErrNone(file.Write(fileData)); sl@0: file.Close(); sl@0: } sl@0: sl@0: //Read those files and verify it sl@0: for (TInt i = 0; i < iThreadData.numFile; i++) sl@0: { sl@0: TBuf8 readData; sl@0: filename.Format(KFile,iThreadData.dirID,i); sl@0: PRINT((_L("File = %S Read/Verify\n"),&filename)); sl@0: test_KErrNone(file.Open(fs,filename,EFileRead)); sl@0: test_KErrNone(file.Read(readData)); sl@0: test_KErrNone(readData.Compare(fileData)); sl@0: file.Close(); sl@0: } sl@0: sl@0: //Delete files sl@0: for (TInt i = 0; i < iThreadData.numFile; i++) sl@0: { sl@0: filename.Format(KFile,iThreadData.dirID,i); sl@0: PRINT((_L("File = %S Delete\n"),&filename)); sl@0: test_KErrNone(fs.Delete(filename)); sl@0: } sl@0: sl@0: //Remove Dir's sl@0: PRINT((_L("Dir Level =%S Removed\n"),&directory)); sl@0: test_KErrNone(fs.RmDir(directory)); sl@0: SetThreadPriority(); sl@0: if (gAbort) sl@0: break; sl@0: User::After(gPeriod); sl@0: } sl@0: fs.Close(); sl@0: return 0x00; sl@0: } sl@0: //Timer Thread - produces DFC's in the kernel side sl@0: //param aSoakThread - CSMPSoakUtil pointer sl@0: TInt CSMPSoakProcess::TimerThread(TAny* aSoakThread) sl@0: { sl@0: CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread; sl@0: __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::TimerThread Panic"),0)); sl@0: return self->DoTimerThread(); sl@0: } sl@0: //Member TimerThread sl@0: TInt CSMPSoakProcess::DoTimerThread() sl@0: { sl@0: RTest test(_L("SMPSoakTimerThread")); sl@0: sl@0: RTimer timer; sl@0: test_KErrNone(timer.CreateLocal()); sl@0: TRequestStatus status; sl@0: sl@0: FOREVER sl@0: { sl@0: timer.After(status, iThreadData.delayTime*1000); sl@0: User::WaitForRequest(status); sl@0: test(status == KErrNone); sl@0: PRINT((_L("$"))); sl@0: SetThreadPriority(); sl@0: if (gAbort) sl@0: break; sl@0: User::After(gPeriod); sl@0: } sl@0: sl@0: timer.Close(); sl@0: return 0x00; sl@0: } sl@0: sl@0: //OOM Thread - produces out of memory condition on SMP threads run on different cpu cores sl@0: //param aSoakThread - this pointer sl@0: TInt CSMPSoakProcess::MemoryThread(TAny* aSoakThread) sl@0: { sl@0: CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread; sl@0: __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::MemoryThread Panic"),0)); sl@0: return self->DoMemoryThread(); sl@0: } sl@0: //Memory thread member sl@0: TInt CSMPSoakProcess::DoMemoryThread() sl@0: { sl@0: RTest test(_L("SMPOOMemoryThread")); sl@0: sl@0: static TInt memOKCount =0; sl@0: TAny* oomheap = NULL; sl@0: TAny* prev = NULL; sl@0: sl@0: //Reserve the memory in heap sl@0: RHeap* heap; sl@0: heap = UserHeap::ChunkHeap(NULL, KHeapMinSize, KHeapMaxiSize); sl@0: sl@0: //Keep produce OOM condition and inform to other threads (run on different CPU cores) sl@0: FOREVER sl@0: { sl@0: TInt allocsize = KHeapMaxiSize - KHeapReserveSize; sl@0: sl@0: if(memOKCount == iThreadData.numThreads-1) sl@0: allocsize = KHeapMaxiSize; sl@0: sl@0: prev = oomheap; sl@0: oomheap = heap->Alloc(allocsize); sl@0: if(oomheap == NULL) sl@0: { sl@0: PRINT(_L("Out Of Memory\n")); sl@0: heap->Free(prev); sl@0: PRINT(_L("Recover Back Memory\n")); sl@0: memOKCount = 0; sl@0: ooMemSem.Signal(iThreadData.numThreads - 1); sl@0: } sl@0: else sl@0: { sl@0: ++memOKCount; sl@0: PRINT((_L("%d:Here MemOK\n"),memOKCount)); sl@0: ooMemSem.Wait(); sl@0: } sl@0: //Change Thread Priority sl@0: SetThreadPriority(); sl@0: if (gAbort) sl@0: break; sl@0: User::After(gPeriod); sl@0: } sl@0: if(heap != NULL) sl@0: heap->Close(); sl@0: return 0x00; sl@0: } sl@0: //Create thread sl@0: void CSMPSoakProcess::CreateThread(TPtrC aThreadType) sl@0: { sl@0: if (aThreadType == _L("-W")) sl@0: { sl@0: CSMPSoakProcess smpipcwrite; sl@0: smpipcwrite.WriteProcess(); sl@0: } sl@0: else if (aThreadType == _L("-R")) sl@0: { sl@0: CSMPSoakProcess smpipcread; sl@0: smpipcread.ReadProcess(); sl@0: } sl@0: else if (aThreadType == _L("-F")) sl@0: { sl@0: CSMPSoakProcess smpfilethread[KNumFileThreads]; sl@0: for (TInt i = 0; i < KNumFileThreads; i++) sl@0: smpfilethread[i].DoCreateThread(&KFileTable[i]); sl@0: for (TInt i = 0; i < KNumFileThreads; i++) sl@0: smpfilethread[i].ResumeThread(); sl@0: } sl@0: else if (aThreadType == _L("-T")) sl@0: { sl@0: CSMPSoakProcess smptimerthread[KNumTimerThreads]; sl@0: for (TInt i = 0; i < KNumTimerThreads; i++) sl@0: smptimerthread[i].DoCreateThread(&KTimerTable[i]); sl@0: for (TInt i = 0; i < KNumTimerThreads; i++) sl@0: smptimerthread[i].ResumeThread(); sl@0: } sl@0: else if (aThreadType == _L("-O")) sl@0: { sl@0: CSMPSoakProcess smpoomthread[KNumOOMThreads]; sl@0: for (TInt i = 0; i < KNumOOMThreads; i++) sl@0: smpoomthread[i].DoCreateThread(&KOOMemoryTable[i]); sl@0: for (TInt i = 0; i < KNumOOMThreads; i++) sl@0: smpoomthread[i].ResumeThread(); sl@0: } sl@0: /* else sl@0: { sl@0: test.Printf(_L("Invalid Argument for Soak Process \n")); sl@0: test(EFalse); sl@0: }*/ sl@0: } sl@0: //Command line arg to launch operation specific process sl@0: void ParseCmdLine() sl@0: { sl@0: TBuf<256> cmd; sl@0: User::CommandLine(cmd); sl@0: TLex lex(cmd); sl@0: PRINT ((_L("Command for Process = %s\n"), cmd.PtrZ())); sl@0: CSMPSoakProcess smpp; sl@0: FOREVER sl@0: { sl@0: TPtrC token=lex.NextToken(); sl@0: if(token.Length()!=0) sl@0: { sl@0: if (token.Length()==0) sl@0: break; // ignore trailing whitespace sl@0: else if (token.Mid(0) == _L("-b")) sl@0: { sl@0: test.Printf(_L("SMPSOAKPROCESS: Silent Mode\n")); sl@0: TestSilent = ETrue; sl@0: lex.SkipSpaceAndMark(); sl@0: token.Set(lex.NextToken()); sl@0: test.Printf(_L("-b Thread Type = %s\n"), token.Ptr()); sl@0: smpp.CreateThread(token); sl@0: break; sl@0: } sl@0: else if (token.Left(2) == _L("-p")) sl@0: { sl@0: test.Printf(_L("SMPSOAKPROCESS: period\n")); sl@0: lex.SkipSpaceAndMark(); sl@0: token.Set(lex.NextToken()); sl@0: TLex lexNum(token); sl@0: lexNum.Val(gPeriod,EDecimal); sl@0: test.Printf(_L("SMPSOAKPROCESS:period in mSeconds=%d \n"),gPeriod); sl@0: token.Set(lex.NextToken()); sl@0: test.Printf(_L("-p Thread Type = %s\n"), token.Ptr()); sl@0: smpp.CreateThread(token); sl@0: break; sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("-d Thread Type = %s\n"), token.Ptr()); sl@0: smpp.CreateThread(token); sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: // Child process called by (T_SMPSOAK) Main Process sl@0: TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: __UHEAP_MARK; sl@0: test.Start(_L("t_SMPSoakProcess.exe")); sl@0: test.Next(_L("Load device driver")); sl@0: TInt r = User::LoadLogicalDevice(_L("d_smpsoak.ldd")); sl@0: if (r == KErrNotFound) sl@0: { sl@0: PRINT (_L("Test not supported on this platform because the D_SMPSOAK.LDD Driver is Not Present\n")); sl@0: test(EFalse); sl@0: } sl@0: sl@0: PRINT (_L("Calling SMPStressDrv.Open\n")); sl@0: r = gSMPStressDrv.Open(); sl@0: test_KErrNone(r); sl@0: sl@0: PRINT (_L("Create/Open Global Write Semaphores\n")); sl@0: r = gWriteSem.CreateGlobal(KGlobalWriteSem,0); sl@0: if (r==KErrAlreadyExists) sl@0: { sl@0: r = gWriteSem.OpenGlobal(KGlobalWriteSem); sl@0: } sl@0: if (r!=KErrNone) sl@0: { sl@0: PRINT ((_L("Error- OpenGlobal Write Semaphore:%d\n"),r)); sl@0: test(EFalse); sl@0: } sl@0: sl@0: PRINT (_L("Create/Open Global Read Semaphores\n")); sl@0: r = gReadSem.CreateGlobal(KGlobalReadSem,0); sl@0: if (r==KErrAlreadyExists) sl@0: { sl@0: r = gReadSem.OpenGlobal(KGlobalReadSem); sl@0: } sl@0: if (r!=KErrNone) sl@0: { sl@0: PRINT( (_L("Error- OpenGlobal Read Semaphore:%d\n"),r)); sl@0: test(EFalse); sl@0: } sl@0: sl@0: PRINT (_L("Creating Global Chunk\n")); sl@0: r = gChunk.CreateGlobal(KGlobalWRChunk,KChunkSize,KChunkMaxSize); sl@0: if(r==KErrAlreadyExists) sl@0: { sl@0: test_KErrNone( gChunk.OpenGlobal(KGlobalWRChunk,EFalse)); sl@0: } sl@0: sl@0: PRINT (_L("Creating local OOM Memory semaphore\n")); sl@0: r=ooMemSem.CreateLocal(0); sl@0: if (r!=KErrNone) sl@0: { sl@0: PRINT ((_L("Error- Creating local OOM Memory semaphore:%d\n"),r)); sl@0: test(EFalse); sl@0: } sl@0: sl@0: ParseCmdLine(); sl@0: sl@0: CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler(); sl@0: test(myScheduler != NULL); sl@0: CActiveScheduler::Install(myScheduler); sl@0: CActiveScheduler::Start(); sl@0: sl@0: ooMemSem.Close(); sl@0: gWriteSem.Close(); sl@0: gReadSem.Close(); sl@0: gChunk.Close(); sl@0: gSMPStressDrv.Close(); sl@0: CActiveScheduler::Stop(); sl@0: __UHEAP_MARKEND; sl@0: test.End(); sl@0: return 0x00; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: