os/kernelhwsrv/kerneltest/e32test/smpsoak/t_smpsoakprocess.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-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\smpsoak\t_smpsoakprocess.cpp
    15 
    16 //  User Includes
    17 #include "t_smpsoak.h"
    18 
    19 #define PRINT(args)\
    20     if (!TestSilent)\
    21         test.Printf args
    22 
    23 void ParseCmdLine();
    24 
    25 //class for soak process and same executable(t_smpsoakprocess.exe) will be lauched with different process operation
    26 //Example: IPC Read, IPC Write, File Process, Timer Process
    27 class CSMPSoakProcess
    28     {
    29 public:
    30 	CSMPSoakProcess();
    31 	~CSMPSoakProcess();
    32 	void CreateThread(TPtrC aThreadType);
    33 private:
    34     //Thread Functions
    35  	static TInt FileThread(TAny*);
    36 	static TInt TimerThread(TAny*);
    37 	static TInt MemoryThread(TAny*);
    38 private:
    39    // Thread member functions
    40     TInt DoFileThread();
    41     TInt DoTimerThread();
    42     TInt DoMemoryThread();
    43     void DoCreateThread(TAny*);
    44     void ResumeThread();
    45     //IPC's
    46     void WriteProcess();
    47     void ReadProcess();
    48     //Thread Priority
    49     void SetThreadPriority();
    50     //Utils for soak process
    51 	void SetSoakProcessPriority();
    52 	void CommitChunk(RChunk& aChunk, TInt aSize);
    53 	void ReadChunk(RChunk& aChunk, TInt aSize);
    54 	void WriteToChunk(RChunk& aChunk, TInt aSize);
    55 	void DeleteChunk(RChunk& aChunk);
    56 private:
    57     //Thread tables
    58     static TThread KOOMemoryTable[];
    59     static TThread KFileTable[];
    60     static TThread KTimerTable[];
    61 private:
    62     TThreadData iThreadData;
    63     RThread     iThread;
    64     TInt        iPriority;
    65     };
    66  
    67 //Memory thread data
    68 TThread CSMPSoakProcess::KOOMemoryTable[] =
    69     {   
    70          { _L("SMPOOMemoryThread1"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLowNormal, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}},
    71          { _L("SMPOOMemoryThread2"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}},
    72          { _L("SMPOOMemoryThread3"), CSMPSoakProcess::MemoryThread, {{EPriorityMore, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}},
    73          { _L("SMPOOMemoryThread4"), CSMPSoakProcess::MemoryThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow, EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, NULL,NULL}},
    74     };
    75 
    76 //File thread data
    77 TThread CSMPSoakProcess::KFileTable[] =
    78     {   
    79         { _L("SMPFileThread1"), CSMPSoakProcess::FileThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 11, 5}},
    80         { _L("SMPFileThread2"), CSMPSoakProcess::FileThread, {{EPriorityNormal, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 22, 10}},
    81         { _L("SMPFileThread3"), CSMPSoakProcess::FileThread, {{EPriorityMore, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 33, 15}},
    82         { _L("SMPFileThread4"), CSMPSoakProcess::FileThread, {{EPriorityAbsoluteVeryLow, EPriorityMore,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 0, 4, NULL, 44, 20}},
    83     };
    84 
    85 //Timer thread data
    86 TThread CSMPSoakProcess::KTimerTable[] =
    87     {   
    88         { _L("SMPTimerThread1"), CSMPSoakProcess::TimerThread, {{EPriorityAbsoluteLowNormal, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 1000, 2, NULL, NULL,NULL}},
    89         { _L("SMPTimerThread2"), CSMPSoakProcess::TimerThread, {{EPriorityAbsoluteLow, EPriorityAbsoluteVeryLow,   EPriorityNormal, 0}, EPriorityList, KCpuAffinityAny, 1500, 2, NULL, NULL,NULL}},
    90     };
    91 //Constructor
    92 CSMPSoakProcess::CSMPSoakProcess()
    93     { 
    94     }
    95 //Destructor
    96 CSMPSoakProcess::~CSMPSoakProcess()
    97     {    
    98     }
    99 //Set the process priority each time for each process
   100 void CSMPSoakProcess::SetSoakProcessPriority()
   101 	{
   102 	RProcess proc;
   103 	TInt priority;
   104 	static TInt priorityindex = 0;
   105 	static const TProcessPriority priorityTable[]=
   106 		{
   107 		EPriorityLow,
   108 		EPriorityBackground,
   109 		EPriorityForeground,
   110 		EPriorityHigh
   111 		};
   112 	if(++priorityindex >= 4)
   113 		priorityindex=0;
   114 	priority = priorityTable[priorityindex];
   115 	proc.SetPriority((TProcessPriority)priority);
   116 	PRINT((_L("Process Priority:%d \n"),proc.Priority()));
   117 	}
   118 //Changes the thread priority each time time, for each thread by Random, Increment, from List, Fixed.
   119 //pick up the priority option from thread table
   120 void CSMPSoakProcess::SetThreadPriority()
   121     {
   122     static TInt64 randSeed = KRandSeed;
   123     static const TThreadPriority priorityTable[]=
   124         {
   125         EPriorityMuchLess, EPriorityLess, EPriorityNormal, EPriorityMore, EPriorityMuchMore,
   126         EPriorityRealTime, EPriorityRealTime, EPriorityAbsoluteVeryLow, EPriorityAbsoluteLowNormal,
   127         EPriorityAbsoluteLow, EPriorityAbsoluteBackgroundNormal, EPriorityAbsoluteBackground,
   128         EPriorityAbsoluteForegroundNormal, EPriorityAbsoluteForeground, EPriorityAbsoluteHighNormal, EPriorityAbsoluteHigh
   129         };
   130     TInt priorityIndex = 0;
   131     switch (iThreadData.threadPriorityChange)
   132         {
   133         case EpriorityFixed:
   134             break;
   135 
   136         case EPriorityList:
   137             if (++iPriority >= KPriorityOrder)
   138                 iPriority = 0;
   139             if (iThreadData.threadPriorities[iPriority] == 0)
   140                 iPriority = 0;
   141          //   PRINT(_L("SetPriority List CPU %d index %d priority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread),iPriority, iThreadData.threadPriorities[iPriority]);
   142             iThread.SetPriority((TThreadPriority)iThreadData.threadPriorities[iPriority]);
   143             break;
   144 
   145         case EPriorityIncrement:
   146             while (priorityTable[priorityIndex] <= iPriority)
   147                 {
   148                 priorityIndex++;
   149                 }
   150             iPriority = priorityTable[priorityIndex];
   151             if (iPriority > iThreadData.threadPriorities[2])
   152                 iPriority = iThreadData.threadPriorities[1];
   153           //  PRINT(_L("SetPriority Increment CPU %d priority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread), iPriority);
   154             iThread.SetPriority((TThreadPriority)iPriority);
   155             break;
   156 
   157         case EPriorityRandom:
   158             iPriority = Math::Rand(randSeed) % (iThreadData.threadPriorities[2] - iThreadData.threadPriorities[1] + 1);
   159             iPriority += iThreadData.threadPriorities[1];
   160             while (priorityTable[priorityIndex] < iPriority)
   161                 {
   162                 priorityIndex++;
   163                 }
   164             iPriority = priorityTable[priorityIndex];
   165            // PRINT(_L("SetPriority Random CPU %d iPriority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread), iPriority);
   166             iThread.SetPriority((TThreadPriority)iPriority);
   167             break;
   168         }
   169     }
   170 //Resume each thread
   171 void CSMPSoakProcess::ResumeThread()
   172     {
   173     iThread.Resume();
   174     }
   175 // CSMPSoakProcess Thread Creation.
   176 // @param aThread thread table data          
   177 void CSMPSoakProcess::DoCreateThread(TAny* aThread)
   178     {
   179     //Initialize each thread data
   180     iThreadData = ((TThread*)aThread)->threadData;
   181     test.Next(_L("Create Thread"));
   182     PRINT ((_L("%s   CPU affinity %d  Priority %d\n"),((TThread*)aThread)->threadName.Ptr(),iThreadData.cpuAffinity,iThreadData.threadPriorities[0]));
   183     TInt r = iThread.Create(((TThread*)aThread)->threadName, ((TThread*)aThread)->threadFunction, KDefaultStackSize, KHeapMinSize, KHeapMaxSize,(TAny*)this);
   184     test_KErrNone(r);
   185     if (iThreadData.threadPriorityChange == EPriorityList)
   186         {
   187         iPriority = 0;
   188         }
   189     else
   190         {
   191         iPriority = iThreadData.threadPriorities[0];
   192         }
   193     iThread.SetPriority((TThreadPriority)iThreadData.threadPriorities[0]);
   194     //Set the thread CPU Affinity
   195     gSMPStressDrv.ChangeThreadAffinity(&iThread, iThreadData.cpuAffinity);
   196     }
   197 //Commit the chunk with aSize
   198 void CSMPSoakProcess::CommitChunk(RChunk& aChunk, TInt aSize)
   199 	{
   200 	//PRINT ((_L("Commit Chunk \n")));
   201 	test_KErrNone(aChunk.Adjust(aSize));
   202 	}
   203 //Write some data into the chunk 
   204 void CSMPSoakProcess::WriteToChunk(RChunk& aChunk, TInt aSize)
   205 	{
   206 	TUint8 *writeaddr = aChunk.Base();
   207 	TPtr8 write(writeaddr,aSize);
   208 	write.Fill('S',aSize);
   209 	write.Copy(memData);
   210 	}
   211 //Read the data from chunk and verify
   212 void CSMPSoakProcess::ReadChunk(RChunk& aChunk, TInt aSize)
   213 	{
   214 	TUint8 *readaddr = aChunk.Base();
   215 	TPtr8 read(readaddr,aSize);
   216 	test_KErrNone(read.Compare(memData));
   217 	}
   218 //Cleaunup chunk
   219 void CSMPSoakProcess::DeleteChunk(RChunk& aChunk)
   220 	{
   221 	test_KErrNone(aChunk.Adjust(0));
   222 	}
   223 //IPC Read operation
   224 void CSMPSoakProcess::ReadProcess()
   225     {
   226 	RTest test(_L("SMPSoakReadProcess"));
   227 	FOREVER
   228 		{
   229 		// SetSoakProcessPriority();
   230 		 gWriteSem.Wait(); //Wait for write completion
   231 		 PRINT((_L("Read Chunk\n")));
   232 		 ReadChunk( gChunk,KChunkSize);
   233 		 PRINT((_L("Delete Chunk\n")));
   234 		 DeleteChunk(gChunk);
   235 		 gReadSem.Signal(); //Read completion
   236 		}
   237     }
   238 //IPC Write operation
   239 void CSMPSoakProcess::WriteProcess()
   240 	{
   241 	RTest test(_L("SMPSoakWriteProcess"));
   242 	FOREVER
   243 		{
   244 		// SetSoakProcessPriority();
   245 		 CommitChunk( gChunk, KChunkSize);
   246 		 PRINT((_L("Write To Chunk\n")));
   247 		 WriteToChunk( gChunk,KChunkSize);
   248 		 gWriteSem.Signal(); //Write completion
   249 		 gReadSem.Wait(); //Wait for read completion
   250 		}
   251 	}
   252 //File Thread - creates Dir's, Files, Fileread, Filewrite and verify
   253 //param aSoakThread - CSMPSoakUtil pointer
   254 TInt CSMPSoakProcess::FileThread(TAny* aSoakThread)
   255      {
   256     CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread;
   257     __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::TimerThread Panic"),0));
   258     return self->DoFileThread();
   259      }
   260 //Member Filethread
   261  TInt CSMPSoakProcess::DoFileThread()
   262 	 {
   263  	 RTest test(_L("SMPFileThread"));
   264  	 TInt r = KErrNone;
   265  
   266  	 TFileName sessionPath;
   267  	 TBuf8<KFileNameLength> fileData;
   268  	 fileData.Copy(KFileData);
   269  	 RFs fs;
   270  	 RFile file;
   271 
   272  	 TBuf<KFileNameLength> filename;
   273  	 TBuf<KFileNameLength> directory;
   274  	 TBuf<KFileNameLength> tempdir;
   275  	 
   276  	//Setup Dir structure
   277  	 tempdir.Format(KDir,iThreadData.dirID);
   278   	 test_KErrNone(fs.Connect());
   279   	 sessionPath=KSessionPath;
   280  	 TChar driveLetter;
   281  	 
   282  	 //Setup Drive and Session
   283  	 test_KErrNone(fs.DriveToChar(EDriveD,driveLetter));
   284  	 sessionPath[0]=(TText)driveLetter;
   285  	 test_KErrNone(fs.SetSessionPath(sessionPath));
   286  	 test.Printf(_L("SessionPath=%S\n"),&sessionPath);
   287  	 directory=sessionPath;
   288  	 directory.Append(tempdir);
   289  	PRINT((_L("Dir Level =%S Creation\n"),&directory));
   290  	 
   291  	 FOREVER
   292  			{
   293  			r= fs.MkDirAll(directory);
   294  			test(r == KErrNone || r == KErrAlreadyExists);
   295  			
   296                 //Create Number of files then write data into it.
   297                 for (TInt i = 0; i < iThreadData.numFile; i++)
   298                     {	
   299                     filename.Format(KFile,iThreadData.dirID,i);
   300                     PRINT((_L("File = %S Write\n"),&filename));
   301                     test_KErrNone(file.Create(fs,filename,EFileWrite));
   302                     test_KErrNone(file.Write(fileData));
   303                     file.Close();
   304                     }
   305                 
   306                 //Read those files and verify it
   307                 for (TInt i = 0; i < iThreadData.numFile; i++)
   308                     {	
   309                     TBuf8<KFileNameLength> readData;
   310                     filename.Format(KFile,iThreadData.dirID,i);
   311                     PRINT((_L("File = %S Read/Verify\n"),&filename));
   312                     test_KErrNone(file.Open(fs,filename,EFileRead));
   313                     test_KErrNone(file.Read(readData));
   314                     test_KErrNone(readData.Compare(fileData));
   315                     file.Close();
   316                     }
   317                 
   318                 //Delete files
   319                 for (TInt i = 0; i < iThreadData.numFile; i++)
   320                     {	
   321                     filename.Format(KFile,iThreadData.dirID,i);
   322                     PRINT((_L("File = %S Delete\n"),&filename));
   323                     test_KErrNone(fs.Delete(filename));
   324                     }
   325                 
   326                 //Remove Dir's
   327                 PRINT((_L("Dir Level =%S Removed\n"),&directory));
   328  				test_KErrNone(fs.RmDir(directory));
   329  				SetThreadPriority();
   330  				if (gAbort)
   331  				    break;
   332  				User::After(gPeriod);
   333  			}
   334  	 fs.Close();
   335  	 return 0x00;
   336  	 }
   337 //Timer Thread - produces DFC's in the kernel side
   338 //param aSoakThread - CSMPSoakUtil pointer
   339  TInt CSMPSoakProcess::TimerThread(TAny* aSoakThread)
   340      {
   341      CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread;
   342      __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::TimerThread Panic"),0));
   343      return self->DoTimerThread();
   344      }
   345 //Member TimerThread
   346 TInt CSMPSoakProcess::DoTimerThread()
   347 	 {
   348  	 RTest test(_L("SMPSoakTimerThread"));
   349  	 
   350  	 RTimer timer;
   351  	 test_KErrNone(timer.CreateLocal());
   352  	 TRequestStatus status;
   353  	 
   354  	 FOREVER
   355  		{
   356  		timer.After(status, iThreadData.delayTime*1000);
   357  		User::WaitForRequest(status);
   358  		test(status == KErrNone);
   359  		PRINT((_L("$")));
   360  		SetThreadPriority();
   361  		if (gAbort)
   362  		    break;
   363  		User::After(gPeriod);
   364  		}
   365  	 
   366  	 timer.Close();
   367  	 return 0x00;
   368 	 }
   369  
   370  //OOM Thread - produces out of memory condition on SMP threads run on different cpu cores
   371  //param aSoakThread - this pointer
   372  TInt CSMPSoakProcess::MemoryThread(TAny* aSoakThread)
   373      {
   374      CSMPSoakProcess* self = (CSMPSoakProcess*)aSoakThread;
   375      __ASSERT_ALWAYS(self !=NULL, User::Panic(_L("CSMPSoakProcess::MemoryThread Panic"),0));
   376      return self->DoMemoryThread();
   377      }
   378 //Memory thread member
   379  TInt CSMPSoakProcess::DoMemoryThread()
   380      {
   381      RTest test(_L("SMPOOMemoryThread"));
   382      
   383      static TInt memOKCount =0;
   384      TAny* oomheap = NULL;
   385      TAny* prev = NULL;
   386      
   387      //Reserve the memory in heap
   388      RHeap* heap;
   389      heap = UserHeap::ChunkHeap(NULL, KHeapMinSize, KHeapMaxiSize);
   390      
   391      //Keep produce OOM condition and inform to other threads (run on different CPU cores)
   392      FOREVER
   393          {
   394           TInt allocsize = KHeapMaxiSize - KHeapReserveSize;
   395           
   396           if(memOKCount == iThreadData.numThreads-1)
   397               allocsize = KHeapMaxiSize;
   398      
   399           prev = oomheap;
   400           oomheap = heap->Alloc(allocsize);
   401           if(oomheap == NULL)
   402               {
   403               PRINT(_L("Out Of Memory\n"));
   404               heap->Free(prev);
   405               PRINT(_L("Recover Back Memory\n")); 
   406               memOKCount = 0;
   407               ooMemSem.Signal(iThreadData.numThreads - 1);
   408               }
   409           else
   410              {
   411              ++memOKCount;
   412              PRINT((_L("%d:Here MemOK\n"),memOKCount));
   413              ooMemSem.Wait();
   414              }
   415           //Change Thread Priority
   416           SetThreadPriority();
   417           if (gAbort)
   418              break;
   419           User::After(gPeriod);
   420          }
   421      if(heap != NULL)
   422      heap->Close();
   423      return 0x00;
   424      }
   425 //Create thread
   426  void CSMPSoakProcess::CreateThread(TPtrC aThreadType)
   427      {
   428      if (aThreadType == _L("-W"))
   429          {
   430          CSMPSoakProcess smpipcwrite;
   431          smpipcwrite.WriteProcess();
   432          }
   433      else if (aThreadType == _L("-R"))
   434          {
   435          CSMPSoakProcess smpipcread;
   436          smpipcread.ReadProcess();
   437          }
   438      else if (aThreadType == _L("-F"))
   439          {
   440          CSMPSoakProcess smpfilethread[KNumFileThreads];
   441          for (TInt i = 0; i < KNumFileThreads; i++)
   442              smpfilethread[i].DoCreateThread(&KFileTable[i]);
   443          for (TInt i = 0; i < KNumFileThreads; i++)
   444              smpfilethread[i].ResumeThread();
   445          }
   446      else if (aThreadType == _L("-T"))
   447          {
   448          CSMPSoakProcess smptimerthread[KNumTimerThreads];
   449          for (TInt i = 0; i < KNumTimerThreads; i++)
   450              smptimerthread[i].DoCreateThread(&KTimerTable[i]);
   451          for (TInt i = 0; i < KNumTimerThreads; i++)
   452              smptimerthread[i].ResumeThread();
   453          }
   454      else if (aThreadType == _L("-O"))
   455          {
   456          CSMPSoakProcess smpoomthread[KNumOOMThreads];
   457          for (TInt i = 0; i < KNumOOMThreads; i++)
   458              smpoomthread[i].DoCreateThread(&KOOMemoryTable[i]);
   459          for (TInt i = 0; i < KNumOOMThreads; i++)
   460              smpoomthread[i].ResumeThread();
   461          }               
   462      /* else
   463           {
   464           test.Printf(_L("Invalid Argument for Soak Process \n"));
   465           test(EFalse);
   466           }*/
   467      }
   468 //Command line arg to launch operation specific process
   469 void ParseCmdLine()
   470 	{
   471  	TBuf<256> cmd;
   472  	User::CommandLine(cmd);
   473  	TLex	lex(cmd);
   474  	PRINT ((_L("Command for Process = %s\n"), cmd.PtrZ()));
   475  	CSMPSoakProcess smpp;
   476  	FOREVER
   477  		{
   478  		TPtrC  token=lex.NextToken();
   479  		if(token.Length()!=0)
   480  			{   
   481                if (token.Length()==0)
   482  		            break;  // ignore trailing whitespace
   483  			   else if (token.Mid(0) == _L("-b"))
   484  			                {
   485  			                test.Printf(_L("SMPSOAKPROCESS: Silent Mode\n")); 
   486  			                TestSilent = ETrue;
   487  			                lex.SkipSpaceAndMark();
   488  			                token.Set(lex.NextToken());
   489  			                test.Printf(_L("-b Thread Type = %s\n"), token.Ptr());
   490  			                smpp.CreateThread(token);
   491  			                break;
   492  			                }
   493                 else if (token.Left(2) == _L("-p"))
   494                             {
   495                             test.Printf(_L("SMPSOAKPROCESS: period\n"));
   496                             lex.SkipSpaceAndMark();
   497                             token.Set(lex.NextToken());
   498                             TLex lexNum(token);
   499                             lexNum.Val(gPeriod,EDecimal);    
   500                             test.Printf(_L("SMPSOAKPROCESS:period in mSeconds=%d \n"),gPeriod);  
   501                             token.Set(lex.NextToken());
   502                             test.Printf(_L("-p Thread Type = %s\n"), token.Ptr());
   503                             smpp.CreateThread(token);
   504                             break;
   505                             }
   506                 else
   507                             {
   508                             test.Printf(_L("-d Thread Type = %s\n"), token.Ptr());
   509                             smpp.CreateThread(token);
   510                             break;
   511                             }
   512             }
   513  		 break;
   514  		}
   515 	}
   516 // Child process called by (T_SMPSOAK) Main Process
   517 TInt E32Main() 
   518 	{
   519     test.Title();
   520     __UHEAP_MARK;
   521     test.Start(_L("t_SMPSoakProcess.exe"));
   522     test.Next(_L("Load device driver"));
   523     TInt r = User::LoadLogicalDevice(_L("d_smpsoak.ldd"));
   524     if (r == KErrNotFound)
   525   		{
   526   		PRINT (_L("Test not supported on this platform because the D_SMPSOAK.LDD Driver is Not Present\n"));
   527    		test(EFalse);
   528    		}
   529     
   530     PRINT (_L("Calling SMPStressDrv.Open\n"));
   531   	r = gSMPStressDrv.Open();
   532   	test_KErrNone(r);
   533   	
   534   	PRINT (_L("Create/Open Global Write Semaphores\n"));
   535     r = gWriteSem.CreateGlobal(KGlobalWriteSem,0);
   536    	if (r==KErrAlreadyExists)
   537    		{
   538    		r = gWriteSem.OpenGlobal(KGlobalWriteSem);
   539    		}
   540    	if (r!=KErrNone)
   541    		{
   542    		PRINT ((_L("Error- OpenGlobal Write Semaphore:%d\n"),r));
   543    		test(EFalse);
   544    		}
   545   
   546    PRINT (_L("Create/Open Global Read Semaphores\n"));
   547    r = gReadSem.CreateGlobal(KGlobalReadSem,0);
   548    if (r==KErrAlreadyExists)
   549 	   {
   550    	   r = gReadSem.OpenGlobal(KGlobalReadSem);
   551 	   }
   552    if (r!=KErrNone)
   553 	   {
   554 	   PRINT( (_L("Error- OpenGlobal Read Semaphore:%d\n"),r));
   555 	   test(EFalse);
   556 	   }
   557    
   558    PRINT (_L("Creating Global Chunk\n"));
   559    r = gChunk.CreateGlobal(KGlobalWRChunk,KChunkSize,KChunkMaxSize);
   560    if(r==KErrAlreadyExists)
   561        {
   562        test_KErrNone( gChunk.OpenGlobal(KGlobalWRChunk,EFalse));
   563        }
   564   
   565    PRINT (_L("Creating local OOM Memory semaphore\n"));
   566    r=ooMemSem.CreateLocal(0);
   567    if (r!=KErrNone)
   568        {
   569        PRINT ((_L("Error- Creating local OOM Memory semaphore:%d\n"),r));
   570        test(EFalse);
   571        }
   572    
   573    ParseCmdLine();
   574    
   575    CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler();
   576    test(myScheduler != NULL);
   577    CActiveScheduler::Install(myScheduler);
   578    CActiveScheduler::Start();
   579  
   580    ooMemSem.Close();
   581    gWriteSem.Close();
   582    gReadSem.Close();
   583    gChunk.Close();
   584    gSMPStressDrv.Close();
   585    CActiveScheduler::Stop();
   586    __UHEAP_MARKEND;
   587    test.End();
   588    return 0x00; 
   589 	}
   590 
   591 
   592 
   593 
   594 
   595 
   596