What are task queues?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What are task queues?

2,613 Views
MQXuser
Contributor III

Im new to RTOS and I am looking for information about task queues.
Where can I find basic information about how task queues work or can somebody explain it?

 

Regards

0 Kudos
15 Replies

858 Views
DavidS
NXP Employee
NXP Employee

Hi MQXuser,

Best location is to look in the ~Freescale MQX 3.x\doc\mqx\MQXUG.pdf section 3.7.8.  It explains the fifo ask and reviews the example that is in the ~Freescale MQX 3.x\mqx\examples\taskq directory.

Regards,

David

0 Kudos

858 Views
MQXuser
Contributor III

I read the documentation before but there are still some questions. To be more specific:

Can I place the same task two times into the task queue?

I need to synchronize a task with an ISR but I need that the task executes 1 time by everytime the interrupt is triggered. If the interrupt gets triggered faster than the task: Can I still make the task run all the times the interrupt have been triggered?

 

Regards,

0 Kudos

858 Views
EAI
Contributor IV

A task may only be enqueued once before a corresponding dequeue.

You want a lwSem. The ISR posts for every interrupt occurrence. The tasks waits on the LWsem.

0 Kudos

858 Views
MQXuser
Contributor III

Of course that is what I need. Sometimes its hard to start thinking in terms of RTOS.

 

Many thanks.

0 Kudos

858 Views
MQXuser
Contributor III

I am not sure what my problem is but I have certain clues.

My interrupt post a semaphore.

 

This interrupt gets triggered about every 2ms for a period of around 50ms. The last time the interrupt gets triggered(from each 50ms group) must post a semaphore but for some reason I get an Unhandled Interrupt comming from shell task. It is like if the interrupt didnt have enough time to run before the next interrupt pulse comes. How can I overcome this?

The code works fine without posting the semaphore, like if the semaphore post instruction is making the interrupt too long. Could be this causing the problem?

 

 

 

void GPT_C0F_ISR(pointer dummy_param){   Door3Counter++;   if(Door3Counter >= 26){//When is the last bit
       Door3Counter = 0;//Reestart the counter
      FifoInsertDataID(codeReadD3, 8); //Codigo y La Puerta      _lwsem_post(&sem_cardRead); //Posts the semaphore
   }   readCounter(0); //Clears the Interrupt flag
   return;}

 

 

 

0 Kudos

858 Views
JuroV
NXP Employee
NXP Employee
Assuming there is not bug in embedded functions of ISR, the ISR is written well.
0 Kudos

858 Views
MQXuser
Contributor III
I dont think there is a bug in the embedded functions since the ISR works without a problem when I dont use the post semaphore function. Does this make sense?
0 Kudos

858 Views
EAI
Contributor IV

1. Did your create the semaphore before using it?

2. Set a breakpoint on the _lwsem_post. Use Task Aware Debugging to display LW semaphores. Ensure the semaphore is listed and is valid.

3. Is your interrupt stack big enough?

 

0 Kudos

858 Views
MQXuser
Contributor III

Thank you for your help.

 

1.-Yes I did.

2.-Yes, semaphore is listed and is valid.

3.-How can I check that? The error that comes is unknown error and not Interrupt stack overflow.  What I see on hyperterminal is the following:

 

***UNHANDLED INTERRUPT ***

Vector #: 2 0x2

Offset    : 8 0x8

Task Id: 0x10002 Td_ptr 0x20001b68 Stack Frame: 0x20001030

Interrupt_nesting level: 2    PC:  0x00040ccc   SR:   0x2600

 

How can I check if I have enough stack?

How can I increase it?

 

Thanks

0 Kudos

858 Views
MQXuser
Contributor III

Another thing.

Semaphore post works fine the first time. It fails the second time although the semaphore is valid before trying to post it.

 

Regards

Message Edited by MQXuser on 2009-10-13 06:22 PM
0 Kudos

858 Views
JuroV
NXP Employee
NXP Employee
Can you step in the _lwsem_post() and find out the reason of failure?
0 Kudos

858 Views
MQXuser
Contributor III
QUEUE_ELEMENT_STRUCT_PTR  _queue_dequeue
   (
      /* [IN] the queue to use */
      QUEUE_STRUCT_PTR q_ptr
   )
{ /* Body */
   QUEUE_ELEMENT_STRUCT_PTR e_ptr;
  
   _int_disable();
   if (q_ptr->SIZE == 0) {
      _int_enable();
      return(NULL);
   } /* Endif */
  
  _QUEUE_DEQUEUE(q_ptr, e_ptr);
   _int_enable();
   return(e_ptr);

} /* Endbody */

 

Second time I try to post the semaphore the UNHANDLED INTERRUPT shows in hyperterminal.

 

When debugging I cant step into _QUEUE_DEQUEUE  function. And thats when the error shows.

 

I have set a breakpoint in that instruction line and the semaphore is valid.

 

 

0 Kudos

858 Views
MQXuser
Contributor III
How can I add more stack to INTERRUPTS?
0 Kudos

858 Views
JuroV
NXP Employee
NXP Employee
0 Kudos

858 Views
MQXuser
Contributor III
I know JuroV, thank you. Unfortunately increasing the Interrupt Stack didnt solve the problem. I am still trying to solve this.
0 Kudos