[IGSTK-Developers] Tracker update question

Patrick Cheng cheng at isis.georgetown.edu
Fri May 22 19:19:57 EDT 2009


Hi Andinet and others,

In igstkTracker.cxx function
Tracker::TrackingThreadFunction(void* pInfoStruct)

around line 1067, we have a while loop:

   int activeFlag = 1;
   while ( activeFlag )
     {
     ResultType result = pTracker->InternalThreadedUpdateStatus();
     pTracker->m_ConditionNextTransformReceived->Signal();

     totalCount++;
     if (result != SUCCESS)
       {
       errorCount++;
       }

     // check to see if we are being told to quit
     pInfo->ActiveFlagLock->Lock();
     activeFlag = *pInfo->ActiveFlag;
     pInfo->ActiveFlagLock->Unlock();
     }


This is forcing the tracker thread to update continuously, which causes 
a lot of waste of system resource.

The internal pulse generator at the same time is trying to update at 
30Hz/sec, and have to wait a lot for the tracker thread to unlock the 
memory.  This is why when our tracker is slower running under 
multi-threaded mode than single thread mode.

I think we should fix this by adding another PulseGenerator in that 
TrackingThreadFunction() call, set its call back function to be 
pTracker->InternalThreadedUpdateStatus(). and we have a while loop to 
check out the time outs.

   int activeFlag = 1;
   while ( activeFlag )
     {
     SomeWaitFunction(0.01);
     igstk::PulseGenerator::CheckTimeouts();

     // check to see if we are being told to quit
     pInfo->ActiveFlagLock->Lock();
     activeFlag = *pInfo->ActiveFlag;
     pInfo->ActiveFlagLock->Unlock();

     if(activeFlag)
       {
        Stop the pulse generator and unhook the callback.
       }
     }
   SomeWaitFunction(0.01);
   igstk::PulseGenerator::CheckTimeouts();

Let me know if you agree with this or not. We can start testing this 
next week.

Patrick



More information about the IGSTK-Developers mailing list