<?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>Spawn multiple threads dynamically from inside a loop.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108304/spawn-multiple-threads-dynamically-from-inside-a-loop</link><description>I would like to spawn multiple threads dynamically from inside a loop to create a simulation. 
 t0s: TaskA.0 runs for 4sec t1s: TaskA.1 runs for 4sec t2s: TaskA.2 runs for 4sec t3s: TaskA.3 runs for 4sec t4s: TaskA.4 runs for 4sec ... t50s: TaskA.50 runs</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Feb 2024 10:19:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108304/spawn-multiple-threads-dynamically-from-inside-a-loop" /><item><title>RE: Spawn multiple threads dynamically from inside a loop.</title><link>https://devzone.nordicsemi.com/thread/468981?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 10:19:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a69c902-71d0-4c63-b5d4-5c46e72aca38</guid><dc:creator>mej7000</dc:creator><description>&lt;p&gt;Thanks for your reply! I ended up creating additional threads with individual stacks statically, which removed the timing overlap and that worked as expected. I also suspect that with my dynamic approach the common stack is the&amp;nbsp;problem. That makes sense... But Zephyr is new to me too and I wanted to get feedback on if I might be missing something obvious. If I have to readdress this I will update this post with anything I learn.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spawn multiple threads dynamically from inside a loop.</title><link>https://devzone.nordicsemi.com/thread/468969?ContentTypeID=1</link><pubDate>Thu, 15 Feb 2024 09:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:837abb54-3bc9-4400-9980-da9e9ad70f95</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I never tried this, but I think having a common stack during the overlap period is the problem. Either split the stack into number of parts that you can have maximum number of overlaps at a time (which is 3 overlaps at a time) or have separate tasks.&lt;/p&gt;
[quote user=""], to accomplishing this with a single thread definition and without statically creating multiple threads to handle the overlap?[/quote]
&lt;p&gt;I think Zephyr is designed to best think in a statically creation of stuff. This was pretty evident when I started to use Zephyr for Bluetooth and saw the way the services were defined (statically)..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;No I can&amp;#39;t think of any way but I do not think that I have thought this through. If you manage to find a way, Please write it here so that I can learn a thing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>