<?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>Is SEGGER_RTT_printf() thread safe with FreeRTOS?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32579/is-segger_rtt_printf-thread-safe-with-freertos</link><description>Hey Guys, 
 
 I have 3 tasks running on FreeRTOS, SDK v14.0.0. In each task, I want to use SEGGER_RTT_printf() to debug. 
 I currently just call SEGGER_RTT_printf() without any semaphores or mutexes, but I assume this is a bad idea. 
 Should I be grabbing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Mar 2018 16:31:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32579/is-segger_rtt_printf-thread-safe-with-freertos" /><item><title>RE: Is SEGGER_RTT_printf() thread safe with FreeRTOS?</title><link>https://devzone.nordicsemi.com/thread/125408?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 16:31:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f509286c-9cb1-49d9-b853-78480ab9c0fb</guid><dc:creator>leonhart88</dc:creator><description>&lt;p&gt;Great!&amp;nbsp; Thanks for confirming this.&amp;nbsp; As an aside, are the NRF_LOG functions also thread safe?&amp;nbsp; I&amp;#39;m assuming yes for RTT as they probably use the same RTT functions, but am not sure about UART logging.&amp;nbsp; Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is SEGGER_RTT_printf() thread safe with FreeRTOS?</title><link>https://devzone.nordicsemi.com/thread/125392?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 15:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c284a1a-d635-47a0-8fbc-59c55fb5cfe7</guid><dc:creator>natersoz</dc:creator><description>&lt;p&gt;Ah, that is what is going on with the call to d_nvic_critical_region_enter(nested)&lt;/p&gt;
&lt;p&gt;It is easier to understand once the motivation is known. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is SEGGER_RTT_printf() thread safe with FreeRTOS?</title><link>https://devzone.nordicsemi.com/thread/125359?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 13:04:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba930937-5615-4532-b219-59f4186cdac3</guid><dc:creator>Rune Holmgren</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I agree with Nathaniel here. It should be safe both with and without the SoftDevice enabled.&amp;nbsp;sd_nvic_critical_region_enter will still allow interrupts reaching the SoftDevice, but there will not be any events for the application in the critical region. This means that timing is not reliable even in critical regions, but that shouldn&amp;#39;t be a problem for RTT since it&amp;#39;s essentially just data being pushed.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Rune Holmgren&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS Tasks, SEGGER_RTT_printf() and semaphores</title><link>https://devzone.nordicsemi.com/thread/125238?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 00:40:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88515520-7e1b-4150-b30d-34b4e4ba6d33</guid><dc:creator>leonhart88</dc:creator><description>&lt;p&gt;You&amp;#39;re right that does seem to be the case.&amp;nbsp; I didn&amp;#39;t bother to step that deep into the definitions initially.&lt;/p&gt;
&lt;p&gt;Hopefully a Nordic support member can comment and confirm this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS Tasks, SEGGER_RTT_printf() and semaphores</title><link>https://devzone.nordicsemi.com/thread/125236?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 00:17:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35fa64b1-c1f8-4bc2-b50f-72bc5190919f</guid><dc:creator>natersoz</dc:creator><description>&lt;p&gt;Actually, you should be safe. Here is why:&lt;/p&gt;
&lt;p&gt;SEGGER_RTT_printf() calls into&lt;/p&gt;
&lt;p&gt;unsigned SEGGER_RTT_Write(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes)&lt;/p&gt;
&lt;p&gt;file: SEGGER_RTT.c&lt;/p&gt;
&lt;p&gt;And here SEGGER_RTT_LOCK() is called, which is #defined to CRITICAL_REGION_ENTER() and there is an UNLOCK which is #defined to _EXIT() ...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;// This gets weary, all the sdk_config.h, macro hell.&lt;/p&gt;
&lt;p&gt;This gets #defined to app_util_critical_region_enter()&lt;/p&gt;
&lt;p&gt;If SOFTDEVICE_PRESENT is defined then sd_nvic_critical_region_enter(nested) is called which looks quite deliberate and scary. (Someone appears to either really know what they are doing or ... I&amp;#39;ll assume they know what they are doing).&lt;/p&gt;
&lt;p&gt;if not defined then app_util_disable_irq() is calledwhich is #defined to the intrinsic __disable_irq();&lt;/p&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;So bottom line: they took care of it. Just so long as you have your sdk_config.h set they way Nordic expects and did not over-write something critical. The C preprocessor is a horrible tool.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>