This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Schedular vs RTOS vs Blocking, need scheduler clarification.

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 1-5ms
  • a main application that will be immensely easier to code if I can hang out in it's loop for seconds at a time

I'm trying to balance a superloop state machine with a way to easily code the main application. Ideas include SWI, PPI to trigger SPIM with DMA, and Scheduler. I'm having a comprehension issue with the scheduler.

For example:

void SomeSWI_orOtherISR() {
<call scheduler_put for subfunction1>
}

void subfunction1 () {
<toggle LED>
}


<main application code>
do {
  Scheduler_execute();
while(1SecondHasntPassedYet);
<rest of main code>
  1. So this must preempt other main application tasks right? If I'm at that 1 Second Delay in the main context, and the SWI/Timer/OtherISR triggers and puts a scheduler task, does that fire up my subfunction1 right now in the main context, and when done return me to my delay(1Second) where I left off?

  2. Scheduler has arguments for size. What does the size of event mean? Is this in reference to the size on the stack that will need to be pushed/popped in order to shift the context? How do I determine size like that? What if subfunction1 in my example had a 5kB array it uses, is the size of that event over 5k large then?

  3. When using the scheduler like this (if I have the idea right) does my main code need to be an element in scheduler as well? Or is it alright to just "schedule-ize" the tasks that will interrupt?

  4. I kinda get the idea I think - but what is the difference between scheduler and just writing my own ISR flags or polling flags in the main context?

  5. If I were to call scheduler_execute from an ISR... would it immediately start code from its que in the interior context? Or would it finish the current ISR code and then start new code in the main context?

If I'm understanding this correctly, it seems I have enough of an option to write "blocking" code without resorting to an RTOS. I have. Ask ally unlimited power, so I'm not terribly worried about issues there. I'm aware the timing of tasks will be a little off and this isn't for precision timing, but nothing I have requires that. How close am I to how this works?

Thank You!

Related