Arduino Due Scheduler: how to stop scheduler tasks prematurely?

hello,

I'm about to design a program based on a subsumption architecture (sensor-event-based behaviour) for the Due.
My questions:

1.) once having started a Scheduler task by

Scheduler.startLoop(taskName);

  • how is it possible to make this task stop prematurely and thus release it from the timeslice scheduler (in case it must be superseded by a higher priority task) ?

sort of
Scheduler.stopLoop(taskName); // stop completely until restarted by ...startLoop()

or at least make it inactive / idle, e.g. by something like
Scheduler.idleLoop(taskName); // make it sleep until awakened again (how?)

?

2.) Next question:
Scheduler tasks are designed to run forever, but how is it possible to make it run just a couple of times, depending on flanking (environmental) conditions or depending on semaphore values ?

AFAIK, there is no built--in function to do that, but you can simply use a volatile boolean variable that is checked by the task. If that variable is true, the task does its thing. If that variable is false, the task simply returns without doing anything.

Regards,
Ray L.

hey,
thanks, but what do you mean by
"the task simply returns without doing anything"

how would the scheduler task "return" ? return to what?
do you mean: one could jump out of a Scheduler loop (task) by a "return" command like for (void) functions?

And by that the scheduler task will be stopped then and removed from the time slice scheduler and all the task stack and heap will be cleaned?

So that afterwards, it can be re-started anew?