Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Q message allocation

Altera_Forum
Honored Contributor II
1,251 Views

This is just a general question about messaging and queues.  

 

How are you guys allocating Q messages? For instance, each message I send is a pointer to a struct. My struct contains an ENUM value and a pointer. In all my message structure is 8 bytes. 

 

When I post to a Q, I send a pointer to one of these message structures.  

 

Should I be using the memory management functions every time and doing dynamic memory allocation of one of these message structures? I don't really know how else to do it without allocating a bunch of global msg structs at compile time.  

 

Any insight to this would be appreciated.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
301 Views

I prefer to use ring buffers. i do a calculation what ring buffer size is needed and add some safety margin. 

Personally i am not a friend of dynamic memory allocation and freeing in embedded systems. 

Unless you have a serious memory shortage i see nothing wrong with allocating big chunks of memory at compile time. At least so see then very early were potential bottlenecks lie. 

Its also easier to test.
0 Kudos
Reply