<?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>Do threads yield during synchronous operations?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114661/do-threads-yield-during-synchronous-operations</link><description>I have a very simple and general question about Zephyr and nRF Connect SDK. When I am running a thread with high priority that uses I2C and call a blocking synchronous function, i.e. i2c_write_dt or i2c_burst_read_dt , does the thread yield so that another</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Sep 2024 13:12:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114661/do-threads-yield-during-synchronous-operations" /><item><title>RE: Do threads yield during synchronous operations?</title><link>https://devzone.nordicsemi.com/thread/502144?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2024 13:12:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f42d184-a966-416c-b6f4-0b0644a57fd8</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When a thread calls a blocking synchronous function, such as&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;i2c_write_dt&lt;/code&gt;&lt;span&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;i2c_burst_read_dt&lt;/code&gt;&lt;span&gt;, the thread will indeed yield and another thread can run while the first one is blocked. This is because these high-level calls accessed through device-specific APIs are usually intended as synchronous and thus, they should be blocked. See &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-1-zephyr-rtos-advanced/topic/threads-life-cycle/"&gt;Thread life cycle&lt;/a&gt;&lt;/span&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can take a look at the&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-7-multithreaded-applications/" rel="noopener noreferrer" target="_blank"&gt;nRF Connect SDK Fundamentals course&lt;/a&gt;&amp;nbsp;and &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-1-zephyr-rtos-advanced/"&gt;nRF Connect SDK Intermediate course&lt;/a&gt;&lt;/span&gt;&amp;nbsp;which&amp;nbsp;&lt;span&gt;provides a comprehensive overview of these topics, including hands-on exercises to practice creating threads, thread yielding and sleeping, and offloading work to a workqueue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Amanda H.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>