<?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>Schedular vs RTOS vs Blocking, need scheduler clarification.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19060/schedular-vs-rtos-vs-blocking-need-scheduler-clarification</link><description>EDITTED- 
 I have a project coming up that uses: 
 
 BLE Softdevice, a fair amount of GATT data 
 SPIM with a fairly high data rate, slave has a RDYN (data ready now) IO to the rnf52 
 UART 
 some application subfunctions that need to run every</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 Jan 2017 17:59:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19060/schedular-vs-rtos-vs-blocking-need-scheduler-clarification" /><item><title>RE: Schedular vs RTOS vs Blocking, need scheduler clarification.</title><link>https://devzone.nordicsemi.com/thread/73707?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 17:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:563a7728-fba2-44fc-b13d-42bba2c1f912</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;ol&gt;
&lt;li&gt;avoid using delays using busy wait by executing NOP, use timers instead.&lt;/li&gt;
&lt;li&gt;correct&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Schedular vs RTOS vs Blocking, need scheduler clarification.</title><link>https://devzone.nordicsemi.com/thread/73706?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 21:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bd02fc7-eeaa-417a-b3df-6b2b3f2b5485</guid><dc:creator>SRA</dc:creator><description>&lt;p&gt;1.) Ok, so if I did want to make things easier on myself and did want to delay(1Second) it would maybe be in my best interest to make sure that my delay function wasn&amp;#39;t just a NOP loop for x cycles, but instead was a main context subloop that called SchedulerExecute. Is this even semi-legit or just a really hacky way to avoid re-entering the superloop when I really just want to stay at the current place in code for awhile?&lt;/p&gt;
&lt;p&gt;2/3/4). I think I understand.&lt;/p&gt;
&lt;p&gt;5.) Ok, so because execute will run from whatever context it&amp;#39;s called from, it&amp;#39;s almost always best to call it from the main context. Which is why in order for my delay example to work, my delay function would have to repetitively be calling sched_execute.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Schedular vs RTOS vs Blocking, need scheduler clarification.</title><link>https://devzone.nordicsemi.com/thread/73705?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 09:56:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d4b356b-786f-48fc-bc28-3e74d686970a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Your main function will be running at the least priority &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.sds%2Fdita%2Fsoftdevices%2Fs130%2Fprocessor_avail_interrupt_latency%2Fexception_mgmt_sd.html&amp;amp;resultof=%22interrupt%22%20%22priority%22%20%22prioriti%22%20%22main%22%20"&gt;look here&lt;/a&gt;. This means that the scheduler_execute is popping any functions at the lowest priority. All FreeRTOS tasks run as thread mode, so any ISR will pre-empt them. Any ISR will only put your subfunction1 into the scheduler.  You sybfunction1 will only execute when your main function gets a chance to run (when all other ISR have exited) and pops your function from scheduler by scheduler_execute() as per your example.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You subfunction1 might need some data to process and this data can be anything and of any size depending on the application requirement. I suggest you to read my most regarding the scheduler to understand its basic design and why we need to allocate this data and how &lt;a href="https://devzone.nordicsemi.com/question/38180/sdk-app-scheduler/#38216"&gt;here&lt;/a&gt;. Since we are pushing into scheduler from different ISR context and popping it in other thread like main or any other lower priority interrupt, we need to reserve this space before hand in the stack and Scheduler does this at the time of scheduler init.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I did not quite understand what you mean by &amp;quot;main code need to be an element in scheduler&amp;quot;. Scheduler is independent, it is not necessary that you have to use only main to pull the functions out of scheduler. I think the post i mentioned above will also answer this question. If not , let me know.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The difference is in simplicity and the ability to pass arguments between contexts. Using a flag in ISR and waiting in main, you cannot pass a lot of arguments between these two contexts (unless you want to use unnecessary global space). The difference is also in the design in how generic it is designed to fit any application that want to postpone the execution of some function with data exchange between these contexts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It does not matter if you are calling it in main or any ISR, once the context within which the scheduler_execute is running, it will be synchronous execution and will pop the function (in your example subfuntion1) and execute it before exiting that ISR. (main cannot exit , so its a super loop)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Yes, I also have suggested that if your application can be kept simple without the use of RTOS, then prefer not to use it and use the scheduler efficiently. May be &lt;a href="https://devzone.nordicsemi.com/question/109826/nrf52-running-rtos-vs-sdk-scheduler/"&gt;this&lt;/a&gt; thread is interesting for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>