dynamic sized queue

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
cpucooler
Posts: 4
Joined: Mon Jul 06, 2020 10:44 am

dynamic sized queue

Post by cpucooler »

Hello,
is there any sort of queue in ChibiOS where each element can have a different size?
thanks in advance.

best regards
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: dynamic sized queue

Post by Giovanni »

Hi,

Not directly, you could use mailboxes and an heap allocator in that scenario.

You may look at how Objects Queues are implemented in OSLIB and replace the pool allocator with the heap allocator. The inherent problems with this approach are:

1) You cannot use it from ISRs, heap allocator does not allow that.
2) You may hit an heap fragmentation problem, this is inherent with dynamic allocation.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: dynamic sized queue

Post by alex31 »

Hello,

I also had this need many times, I use Giovanni solution : mailboxe and heap allocator.

When I need constant time allocation and very low fragmentation, I use TLSF as heap allocator :

tlsf heap allocator github

Alexandre
Post Reply