kerneltest/e32test/thread/smpsafe.cpp
changeset 45 329ab0095843
parent 44 36bfc973b146
equal deleted inserted replaced
44:36bfc973b146 45:329ab0095843
    84 	TRequestStatus s;
    84 	TRequestStatus s;
    85 	t.Logon(s);
    85 	t.Logon(s);
    86 	t.SetPriority(EPriorityLess);
    86 	t.SetPriority(EPriorityLess);
    87 	t.Resume();
    87 	t.Resume();
    88 
    88 
       
    89 	TInt a = 1;
    89 	for (TInt i = KLoopTries; i>0; --i)
    90 	for (TInt i = KLoopTries; i>0; --i)
    90 		{
    91 		{
    91 		Affinity = 1; // assume we are locked to a single cpu
    92 		Affinity = 1; // assume we are locked to a single cpu
    92 		Start.Signal(); // tell the other thread to run
    93 		Start.Signal(); // tell the other thread to run
    93 		TUint32 target = User::NTickCount() + 10;
    94 		TUint32 target = User::NTickCount() + 10;
    94 		while (User::NTickCount() < target)
    95 		while (User::NTickCount() < target)
    95 			{
    96 			{
    96 			// spin, waiting to see if the other thread actually *does* run
    97 			// spin, waiting to see if the other thread actually *does* run
    97 			}
    98 			}
    98 		if (Affinity == 0)
    99 		a = Affinity;
       
   100 		if (a == 0)
    99 			break;
   101 			break;
   100 		Stop.Wait(); // We didn't see it this time, but try again in case of scheduling fluke
   102 		Stop.Wait(); // We didn't see it this time, but try again in case of scheduling fluke
   101 		}
   103 		}
   102 
   104 
   103 	t.Kill(0);
   105 	t.Kill(0);
   104 	User::WaitForRequest(s);
   106 	User::WaitForRequest(s);
   105 	t.Close();
   107 	t.Close();
   106 
   108 
   107 	return Affinity;
   109 	return a;
   108 	}
   110 	}
   109 
   111 
   110 #ifndef OMIT_MAIN
   112 #ifndef OMIT_MAIN
   111 GLDEF_C TInt E32Main()
   113 GLDEF_C TInt E32Main()
   112 	{
   114 	{