Q on ThreadX Qs

Hi,

I'm using ThreadX in a multi-threaded application and am using queues to communicate between the different threads.

It seems that the ThreadX manual says that when a queue is empty, any message written to it will be sent straight to the destination (bypassing the queue) if the recipient thread is suspended.

What seems to be happening in the application is that several messages are sent to the queue while the recipient thread is suspended... this means that the destination is being overwritten (possibly several times) and messages are being lost (because the queue is being bypassed).

Can anyone tell me if this is expected behavior and, if so, what is the work around to ensure that messages do not get lost?

If it's not expected behavior, can someone point out what I might be doing wrong (or mis-interpreting) ?

Thanks in advance for any pointers,

Byyy.

Reply to
boyoyoyo
Loading thread data ...

IIRC, what happens is that when the Queue write executes and finds a higher priority thread waiting on the Queue, it will suspend the calling thread and wake the higher priority thread without actually copying the data to the queue, this is really just to save the time needed to copy the data to the queue before suspending the calling thread and then copying it from the queue after waking the higher priority thread.

If the waiting thread is lower priority then the data is copied to the queue.

I'm not sure how this can happen - if the sending thread is lower priority than the recipient, then as soon as the first message is passed the sending queue will be suspended - so no more messages can be sent. If the recipient is lower priority then the data is copied to the queue (since the recipient won't be woken by the message) and, as long as the queue has the space, all the messages will be placed in the queue. If the queue runs out of space then the sending thread will be suspended until the receiving thread has removed a message from the queue.

This is definitely not expected behaviour, I've been using queue on ThreadX for several years without seeing this problem. As to what you might me doing wrong - I have no idea - you need to post the code that is failing.

Stan Katz

Reply to
Stan Katz

queue

OK, thanks.

OK.

No problem, thanks heaps for the detailed response. It seems that we'll have to look a little higher in the application to find the cause of the problem. Your commentary makes sense.

Yo,

Byyy

Reply to
boyoyoyo

We played around with various configurations, mostly just time-sliced it.

Yes, there is no error.

Large enough, it seems.

The third question makes me wonder... I was under the impression that there was only one message buffer?

Thanks heaps for the response! Much appreciated.

Yo,

Byyy

Reply to
boyoyoyo

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.