<?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>How does a thread suspend itself?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/126214/how-does-a-thread-suspend-itself</link><description>Hi, 
 (I&amp;#39;m assuming that the main() function of an application is actually executed as a thread.) I can&amp;#39;t find any clear documentation that describes how a thread can suspend itself via k_thread_suspend(). What&amp;#39;s the value of the &amp;quot;thread&amp;quot; argument in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Dec 2025 07:28:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/126214/how-does-a-thread-suspend-itself" /><item><title>RE: How does a thread suspend itself?</title><link>https://devzone.nordicsemi.com/thread/557290?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 07:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25740346-752c-400c-8bcf-c0343fa0fed8</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Typically, from the thread itself you would like to take a semaphore (&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_semaphore_apis.html#gac71e2383c1920dddc45a561cacfef090"&gt;k_sem_take()&lt;/a&gt;) or suspend for a given amount of time before the thread automatically resumes (&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#ga117b26f8569ec3045ead1fad1851663d"&gt;k_sleep()&lt;/a&gt;). Sometimes you just want other threads to start executing, if there are any, and therefore stop the execution of the current thread early (&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#ga08a3484c33444ecedc2d71d78495a295"&gt;yield()&lt;/a&gt;). Sometimes you might want the thread to stop and never start again (return from the entry point function of the thread).&lt;/p&gt;
&lt;p&gt;If you want to suspend the thread from itself, then you can do so with &lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#ga66cf8682fb65870eceb5e57d667a8d4e"&gt;k_thread_suspend()&lt;/a&gt;, yes, but please note that then some other thread must later call &lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#ga117b26f8569ec3045ead1fad1851663d"&gt;k_thread_resume()&lt;/a&gt; on the thread for it to get back from the suspended state. The argument for &lt;code&gt;k_thread_suspend()&lt;/code&gt;, of type &lt;code&gt;k_tid_t&lt;/code&gt;, is the thread ID which you got from the call to &lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#gad5b0bff3102f1656089f5875d999a367"&gt;k_thread_create()&lt;/a&gt;. From within the thread itself, you can get this ID from a call to&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_thread_apis.html#ga7ef1ed0fb9513df8096ede1e52fc76b2"&gt;k_current_get()&lt;/a&gt;.&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: How does a thread suspend itself?</title><link>https://devzone.nordicsemi.com/thread/557276?ContentTypeID=1</link><pubDate>Wed, 17 Dec 2025 22:13:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab2faedc-2cf7-4d87-b0f7-2775bb267aa1</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Why would one want to do that? Use &lt;code&gt;k_sem_take()&lt;/code&gt; instead. That one allows other threads to wake you back up rather easy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>