This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

task que hanging problem



Hi.


/*
 * ======== main ========
 */
void main() {

    LOG_printf(&trace,"Start of semaphore. \n");
    printf("Preview Application\n");
    fflush(stdout);
    return;
}


void initTSK()   // Priority 15.
{                                                  
  
    // Init queue.
                                                                  
}


void uartTSK(void) // Priority 1.
{
   while(1)
   {
 msg = QUE_get(&freequeue); 
 // DO something with msg.
 QUE_put(&queue,msg);
 SEM_post(&sem);
   }   
}
 
 
void SomeTask(void)  // Priority 2.
{

   // Some commands that uses interrupt or dma.
   while(1)
   {
 SEM_pend(&sem,SYS_FOREVER);
 if(QUE_empty(&queue))
 {
  LOG_printf(&trace,"Empty free queue!\n");
  SYS_abort("Empty free queue!\n");
 }
 msg = QUE_get(&queue);
 // Here some manipulation with msg.
 QUE_put(&freequeue,msg);
   }
}

 

This programm works fine , It switches between 2 tasks and moves data  from void uartTSK(void) to void SomeTask(void)  .

However if I enable the line // Some commands that uses interrupt or dma.

in void SomeTask(void) , then the programm is stuck.

Please Advise.

 

  • Does the "// Some commands that uses interrupt or dma" commands block (call SEM_pend() or something else that waits for an interrupt?).   I suspect that the uartTask drains the freequeue and since you are not checking for empty queue on that side, you are corrupting the queues.  You need to use "if !QUE_empty()" before calling QUE_get().  Or, you need to check the return value from QUE_get() to make sure it doesn't match the QUE_Handle.    I think you are corrupting the queues.  Add this and you should be OK.

     

       while(1)
       {
         

        if (!QUE_empty(&freequeue) {
            msg = QUE_get(&freequeue); 
            // DO something with msg.
            QUE_put(&queue,msg);
         
            SEM_post(&sem);
          }
       }   

     

    Sorry if the formatting got whacked.

    -Karl-