<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>zephyr message queue buffer alignment</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99260/zephyr-message-queue-buffer-alignment</link><description>Hi, 
 The description for k_msgq_init() states that 
 To Quote: 
 &amp;quot;...... 
 
 /** 
 * @brief Initialize a message queue. 
 * 
 * This routine initializes a message queue object, prior to its first use. 
 * 
 * The message queue&amp;#39;s ring buffer must contain</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 May 2023 09:32:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99260/zephyr-message-queue-buffer-alignment" /><item><title>RE: zephyr message queue buffer alignment</title><link>https://devzone.nordicsemi.com/thread/423937?ContentTypeID=1</link><pubDate>Fri, 05 May 2023 09:32:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:203b067a-729e-4b20-b0e0-0244e62e4cee</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;I believe that is a correct interpretation yes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zephyr message queue buffer alignment</title><link>https://devzone.nordicsemi.com/thread/423597?ContentTypeID=1</link><pubDate>Wed, 03 May 2023 13:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68ebfd02-3bbd-4504-8ef0-5ac6fc448635</guid><dc:creator>Mathi</dc:creator><description>&lt;p&gt;Hi Einar,&lt;br /&gt;&lt;br /&gt;What do you mean by &amp;#39;full bytes&amp;#39;? (Sorry, if iam being slow here)&lt;br /&gt;&lt;br /&gt;Does that mean, the constaint here is that - the &amp;#39;buffer&amp;#39; has to be aligned to an address that is a multiple of 2, but the value of msg_size need not be a power of 2?&lt;br /&gt;&lt;br /&gt;For example, is the following valid:&lt;br /&gt;&lt;br /&gt;msg_size = 5;&amp;nbsp;&lt;br /&gt;max_msgs = 5:&lt;br /&gt;alignas(myroundtonexthighpowerof2(msg_size)) char buffer[max_msgs * msg_size);&lt;br /&gt;&lt;br /&gt;Is this a correct interpretation?&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Mathi.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: zephyr message queue buffer alignment</title><link>https://devzone.nordicsemi.com/thread/423485?ContentTypeID=1</link><pubDate>Wed, 03 May 2023 10:01:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9220628-8bab-4498-815e-8b9a34ff23c7</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;q_msg_size only refers to the size of a message in the queue, not the size of the buffer:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__msgq__apis.html#ga95ef93002766901511d09c8cd8f8293b"&gt;https://docs.zephyrproject.org/apidoc/latest/group__msgq__apis.html#ga95ef93002766901511d09c8cd8f8293b&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So the way I understand it the only real restraint is that the buffer should contain a number of full bytes, which sounds reasonable for a ring buffer.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>