<?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>Thread blocking</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86233/thread-blocking</link><description>Hi Everyone, 
 I&amp;#39;m using nrfConnect Sdk v1.7.0 with vs code for nrf52833 chip. 
 I&amp;#39;m new to developing rtos applications, here I tried to to poll out some uart tx data using threads. 
 from some examples I&amp;#39;ve picked two methods of thread creation and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Mar 2022 05:16:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86233/thread-blocking" /><item><title>RE: Thread blocking</title><link>https://devzone.nordicsemi.com/thread/360135?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2022 05:16:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b2ad82d-a7e0-49a8-9018-1876193e2905</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;I assume your question is about why the threads with same priority doesn&amp;#39;t yield to each other and require you to do either k_sleep or k_yield.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is what I needed.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll try your suggestion and get back to you. Thank you.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Visweswara Sarma&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thread blocking</title><link>https://devzone.nordicsemi.com/thread/360020?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2022 13:31:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb0942fa-8404-46b6-a459-b1857b22abfc</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Viswa,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I still don&amp;#39;t know how you configure the Threads and what inside them in both Method 1 and Method 2. Please elaborate a little bit more.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you are running a Thread at non-negative priority it will be executed as &amp;quot;pre-emptive&amp;quot; thread and &amp;quot;&lt;span&gt;a preemptible thread may be supplanted at any time if a cooperative thread, or a preemptible thread of higher or equal priority, becomes ready.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;See the documentation on Thread priority&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/zephyr/reference/kernel/threads/index.html#thread-priorities"&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I assume your question is about why the threads with same priority doesn&amp;#39;t yield to each other and require you to do either k_sleep or k_yield.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The important part here is that it only automatically yield to same priority thread when time slice scheduling is used. See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.1/zephyr/reference/kernel/scheduling/index.html#preemptive-time-slicing"&gt;here.&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As far as I know by default&amp;nbsp;&lt;/span&gt;CONFIG_TIMESLICING=y, however,&amp;nbsp;CONFIG_TIMESLICE_SIZE=0 by default.&amp;nbsp;&lt;br /&gt;&amp;nbsp;CONFIG_TIMESLICE_SIZE=0 means there will be no time slice (&lt;span&gt;A time slice size of zero means &amp;quot;no limit&amp;quot; (i.e. an infinitely large time slice).)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I tried to set&amp;nbsp;&lt;span&gt;CONFIG_TIMESLICE_SIZE=100 (100ms/slice) and it seems to work for me. The Thread with no yield or sleep will be preempted by other thread when it&amp;#39;s ready.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Anyway doing a Thread without proper yielding is not a good practice.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>