<?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>nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39606/nrf-mesh-sdk-race-conditions</link><description>Hello, 
 During development with the Mesh SDK, we realized that it would not be possible to use a vast number of functions, even those relating to message publishing, without incurring in the potential for race conditions, unless synchronization with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Nov 2018 10:28:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39606/nrf-mesh-sdk-race-conditions" /><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/159530?ContentTypeID=1</link><pubDate>Thu, 29 Nov 2018 10:28:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33fad678-4339-452f-a09f-589f6fb5249e</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for letting us know!&lt;/p&gt;
&lt;p&gt;I am happy to hear that your solution to the issue worked out nicely, and I have reported your findings back to our mesh team.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/158694?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 15:08:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10d1d566-85b8-436b-adea-8ed6096f7408</guid><dc:creator>adrfc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;After further testing and analysis, we concluded that suspending Mesh and SoftDevice event processing, thus creating a mutual exclusion condition identical to same-priority interrupts, is indeed an adequate solution in place of the ones officially suggested. We have found no apparent downside to such approach.&lt;/p&gt;
&lt;p&gt;Alberto&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/154714?ContentTypeID=1</link><pubDate>Fri, 26 Oct 2018 15:24:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:842d3038-3e42-435f-899d-25b763cd61dc</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, I agree that the issues you are facing are the same ones as if one wants to call the functions outside of the required priority level.&lt;/p&gt;
&lt;p&gt;As expected the Mesh team didn&amp;#39;t have any specific suggestions or definite recommendations, as the nRF5 SDK for Mesh was not intended to be used with FreeRTOS.&lt;/p&gt;
&lt;p&gt;As long as the mesh API and the handling of the mesh stack happens &lt;em&gt;as if&lt;/em&gt; it was running in the same interrupt context, then at least in theory you should be fine. It would be interesting to know how well your suggested approach works in practice.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/154613?ContentTypeID=1</link><pubDate>Fri, 26 Oct 2018 07:29:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:213d43e8-7709-490e-a907-67df85682a5a</guid><dc:creator>adrfc</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thank you for taking the time to look into this. I should remark that, as would be expected, these issues do present themselves just the same even when using the SDK in its intended interrupt-driven mode, if one should wish to call most SDK functions outside the priority of said interrupt.&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt; Alberto&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/154561?ContentTypeID=1</link><pubDate>Thu, 25 Oct 2018 16:21:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad88c46a-509d-49b6-8457-2da4053bcfc0</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the explanations. I have asked the mesh team for input, and I will get back to you when they have responded. Please note however that the nRF SDK for Mesh was not written with thread safety in mind, and we cannot give any definite answers without actually making (and testing) a thread safe release. Currently, unfortunately, we do not have any such plans.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/154167?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 16:06:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35224900-5ec8-4df3-82ee-0c76d33e3b79</guid><dc:creator>adrfc</dc:creator><description>&lt;p&gt;I will gladly elaborate,&lt;/p&gt;
&lt;p&gt;By &amp;ldquo;fully disabling mesh processing&amp;rdquo; I mean disabling the mesh processing interrupt, which is the QDEC interrupt or SWI0, depending on the configuration, when running the stack in interrupt mode. I have also been using FreeRTOS and running &lt;em&gt;nrf_mesh_process()&lt;/em&gt; in a task &amp;ndash; in that case I disable mesh processing using a mutex.&lt;/p&gt;
&lt;p&gt;I disable mesh processing at mesh start-up (same as the examples) and when calling message-publishing functions, which are the only functions in the Mesh SDK invoked in the main application. The idea is to do so before any SDK function.&lt;/p&gt;
&lt;p&gt;The potential race conditions are quite broad, since most of the mesh state is stored in static variables. From a brief analysis, I do believe it would be possible, for example, to create issues in the packet buffer by sending a message without synchronizing accesses. A more notable case is &lt;em&gt;stdlib.h&lt;/em&gt; dynamic allocations, which normally require locking for multi-threaded use (and, thus, use within ISRs).&lt;/p&gt;
&lt;p&gt;A general warning against these issues is provided in the &amp;ldquo;Interrupt priority levels&amp;rdquo; of the Mesh SDK documentation.&lt;/p&gt;
&lt;p&gt;My question is whether the stated approach is adequate, since having to use a specific priority to trigger most mesh-related calls, especially in the interrupt-based mode, requires quite a complicated approach in most non-trivial applications.&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;br /&gt; Alberto&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Mesh SDK Race Conditions</title><link>https://devzone.nordicsemi.com/thread/154158?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 15:15:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9faab260-55c7-42f2-ad18-fd708046e03c</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you elaborate a bit on what potential race conditions you are thinking of?&lt;/p&gt;
&lt;p&gt;Also, what you mean by &amp;quot;fully disabling mesh processing&amp;quot; and before what set of functions?&lt;/p&gt;
&lt;p&gt;I want to better understand the problem before discussing with our Mesh team what can be done about it.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>