Hello,
is there any sort of queue in ChibiOS where each element can have a different size?
thanks in advance.
best regards
dynamic sized queue
- 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
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
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
Re: dynamic sized queue
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
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