AnsweredAssumed Answered

VDK Semaphore is not processed

Question asked by PeterK on Feb 8, 2010
Latest reply on Feb 18, 2010 by PeterK

Hello,

 

I working on an application which posts a semaphore in an ISR, but the pending thread does not get active!

 

Here are some details:

  • The ISR is an 8khz task. At one point this task polls a message queue and if a message was received, it will post a semaphore to start a thread (priority level 3) through VDK::C_ISR_PostSemaphore(semID);
  • The ::Run() function of the thread looks like
  • {

       while(1) {

           if (VDK::PendSemaphore(semID, 0))   {

               DoIt();

           }

        }

    }

  • This setup works fine for a while, but then, for unknown reasons, the thread just doesn't get started.
  • I added debug code which confirmed that PostSemaphore was called whenever a message was in the queue.
  • I checked the Semaphore status and Thread status. I didnot see the a state change in the semaphore (always zero) and the thread status indicated clearly, that it is waiting for a semaphore and the semaphore ID was correct as well.
  • I added a timeout of 1second to PendSemaphore (no error on timeout) and the system behaved as follows:
    • After a timeout a return value of false is returned (as stated in the manual)
    • If the semaphore is posted, the thread does not get started, but now is see clearly the semaphore status set to 1
    • If the timeout occurs, the return value is true and the DoIt(); function is executed.
    • Of course, I added an else { counter++; } section to see what happens.
  • It must be some kind of race condition, because the system runs fine for either several hours or just 10 min before the semaphore mechanism breaks!
  • A new message is queued approx. 1ms after the thread completed.

 

 

I'm using

  • VisualDSP++ 5.0 Update 4
  • Product Version 5.0.4.0
  • IDDE Version: 8.0.6.62
  • Build Date: Jul 8, 2008

 

Thanks for you help!

 

Peter

           

           

      Outcomes