zephyr message queue buffer alignment

Hi,

The description for k_msgq_init() states that 

To Quote:

"......

/**
 * @brief Initialize a message queue.
 *
 * This routine initializes a message queue object, prior to its first use.
 *
 * The message queue's ring buffer must contain space for @a max_msgs messages,
 * each of which is @a msg_size bytes long. The buffer must be aligned to an
 * N-byte boundary, where N is a power of 2 (i.e. 1, 2, 4, ...). To ensure
 * that each message is similarly aligned to this boundary, @a q_msg_size
 * must also be a multiple of N.
 *
* @param msgq Address of the message queue.
 * @param buffer Pointer to ring buffer that holds queued messages.
 * @param msg_size Message size (in bytes).
 * @param max_msgs Maximum number of messages that can be queued.
 */
....."
Could you please clarify,
(a) what is @a q_msg_size being referred to here(highlighted above)?
(b) And assuming it is the size of the buffer, then because the buffer is a char *, why should it be aligned to be a multiple of N?, Because for big sized buffers, this can result in a lot of wastage of memory for the sake of alignment.
Also, Are there any restrictions for unaligned accesses on cortex-m33? If not, could you confirm whether this alignment can be skipped on nRF5340. 

Thanks,
Mathi.
Parents Reply Children
No Data
Related