**mssp704** wrote on Sunday, March 05, 2017:

Hi,

I am looking for a queue structure which can handle elements with different priorities. Let say a thread can handle three different messages A, B and C. A messages have a bigger priority than B messages and B messages have bigger priority than C message.

Here is an illustration of what I am looking for. This example is with a queue length of 6. At the beginning the queue is empty (next element popped is the one to the right):

First we add a message B noted B1 -> [0 0 0 0 0 B1]

Then message C noted C1 -> [0 0 0 0 C1 B1]

Then message A noted A1 -> [0 0 0 C1 B1 A1] -> A1 is pushed in front of the queue because the A1 priority is Higher

Now another message B noted B2 -> [0 0 C1 B2 B1 A1] -> B2 is placed before C1 because it has an higher priority than C1

An improvement could be to choose if the messages are pushed in back or in front compare to his priority:

Push another message B noted B3 in front of his priority -> [0 C1 B2 B1 B3 A1]

This kind of queue seems usefull but i didn’t find any questions or implementation of this. Is there any reasons to don’t use it?

By using one queue for each priority this problem can be solved by using several Queue with queue set but it will not be flexible and efficient.

Did someone already needed it ? How this problem is solved using freeRTOS ?

Thank you

Regards,

Mickaël