I was wondering, right now, xQueueGenericCreate calls pvPortMalloc to allocate a Queue_t, then calls it again to allocate the storage space for the queue data. If you have a lot of semaphores, this means a lot of calls to pvPortMalloc all asking for one-byte heap blocks, which will waste quite a bit of space on heap metadata! Wouldn’t it be more efficient to pack the Queue_t and its data area into a single heap allocation, of size (sizeof(Queue_t)+uxQueueLength*uxItemSize+1), and have the data area live immediately after the Queue_t in RAM?
I think this very topic was discussed a few months back, you might find it in the archive somewhere. Yes it is a good idea, but again because the code is so mature and known to be good at the moment there is some reluctance to make changes right now. Ideally it should have been done before the version 8 release candidates were provided for public review, but there is always very limited time and getting the new features out was priority. Again I would request a feature request is logged for this.
In general you can run into alignment problems with adding a data block after a structure like this, unless you use the C99 feature of being able to add a
statement to the end of the structure. But since FreeRTOS only adds arrays of char to the end, and uses memmove (which can’t have alignment issues) it should be safe.
I am not sure if it would cause problems with porting that change over to SafeRTOS, which I understand doesn’t used dynamic allocations for stuff like this (but I suspect it needs a different interface anyway).