Common name for a "Task Loop"

So, this is the third time in a month or so that I've needed to tell someone "use a task loop" -- but I'm not sure if I can say "just Google it".

So: When I say "task loop" I mean that I'm _not_ using an RTOS, but rather that I'm doing some small thing in a small processor, and somewhere in my code there's a loop that goes:

for (;;) { if (task_1_ready) { task_1_update(); } else if (task_2_ready) { task_2_update(); } else if (task_3_ready) // et cetera }

The "task_n_ready" variables are set offstage (in an ISR, or by one of the task_n_update functions) and reset within the tasks.

So -- is there a common Google-able term for this?

--
Tim Wescott 
Wescott Design Services 
 Click to see the full signature
Reply to
Tim Wescott
Loading thread data ...

formatting link

Reply to
Lanarcam

How about round-robin scheduling?

It includes the idea of allocating time slices to tasks, which a simple task loop does not do.

--

-TV
Reply to
Tauno Voipio

I've seen:

- task loop

- The Big Loop

- "bare metal"

- A "no O/S" solution.

Google is no help at all.

It's apparently sufficiently obscure to defy standard naming.

--
Les Cargill
Reply to
Les Cargill

That's kind of what I found, too.

It's a form of non-preemptive multitasking, but it's by no means the only way to implement that, so you can't really call it that.

Which is odd, because if you were to count actual processors out there then some variant of it is probably the most Embedded architecture.

--
Tim Wescott 
Control systems, embedded software and circuit design 
 Click to see the full signature
Reply to
Tim Wescott

I've always called it while(1)OS.

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
 
Email address domain is currently out of order.  See above to fix.
Reply to
Rob Gaddi

Hmm. That actually gets some hits. There seems to be no consensus on these terms, though.

--
Tim Wescott 
Control systems, embedded software and circuit design 
 Click to see the full signature
Reply to
Tim Wescott

Rob - that's what I've always called it too. Not really Google-able however...

--Mark

Reply to
Mark Curry

I'd call that a polling loop, since it polls each task to see if it's ready. But I don't know if that's a standard term. There's a DSL for generating these things (see "Atom" under

formatting link
and the slide presentation doesn't seem to use any particular name for the main loop.

Reply to
Paul Rubin

Until I read your reply, this was _exactly_ what I was going to say.

It _is_ a polling loop (or polling architecture if you want to distinguish it from an interrupt architecture.)

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP 
Microsoft: Bringing you 1980s technology to a 21st century world
Reply to
Simon Clubley

Kludge?

OK, OK, I've done it too...

Reply to
Dave Nadler

I don't think it's a klugde in a small enough application. It has it's downsides, true, but it works just fine if you're careful.

--
Tim Wescott 
Control systems, embedded software and circuit design 
 Click to see the full signature
Reply to
Tim Wescott

Nah. It's anything but, really. There's just a slightly ... jerky continuum of increasing abstraction starting with a big loop being the least abstract ( and potentially the most deterministic ).

--
Les Cargill
Reply to
Les Cargill

Assuming a single thread, I would just call this a 'super loop', and, to the best of my knowledge, believe that is the common way of describing it. A quick google for '"super loop" software' brings the following:

formatting link
formatting link

which I think is inline with your structure.

Regards, Richard.

  • formatting link
    The de facto standard, downloaded every 4.2 minutes during 2015.

  • formatting link
    IoT, Trace, Certification, TCP/IP, FAT FS, Training, and more...

Reply to
FreeRTOS info

I guess I'm going to have to be happy with "Superloop". It doesn't seem to capture the more-disciplined nature of what I was expressing, which basically implements a cooperative multitasking scheduler.

Mostly I need something to point to when some newbie on a forum is looking for an alternative to doing most of their processing in ISRs, because they can't imagine the "set a flag and do it later" notion.

--
Tim Wescott 
Control systems, embedded software and circuit design 
 Click to see the full signature
Reply to
Tim Wescott

Tim, the "Superloop" is quite ok as a term. I'm using "main loop" by myself

- I don't know why exactly, maybe because it resides in main() ? :D - and because the "super" in superloop seems to me too strong. What's so "super" about it?

However, you use "task" for a finite state machine. The "cooperative" thing has nothing to do with your code, basically because there aren't "tasks". "Cooperative" term is used on real multi-tasking systems in opposition to "preemtive". But I think you know very well that.

For me a "task" is a code that has (or can have) an infinite loop inside, and usually doesn't return. A cooperative multitasking system is exactly like a preemtive one, but just without the preemtion. The only way to give control to other tasks is with some yield() routine. The scheduler is simpler than for a preemtive system, but it is no way close to what you are describing in your example.

Reply to
raimond.dragomir

What you describe is a round robin scheduler, with each task running to completion once it has something to do. It's a common technique where you don't want or need the complexity of a real time OS. For a slightly more formal solution, you can encapsulate that idea into a variable length table of function pointers, where tasks can be set sleeping, ready, running etc. Include a count of clock ticks that say how often the task runs to provide priority scheduling. Implement each task as a state machine, with simple message passing between tasks, always dependent on the next message to run and you have a compact and efficient real time OS applicable to any processor. The advantage is that it can all be written in C, with no fussy processor specific context switching code.

You can do all that in not much more than a page of C :-)...

Regards,

Chris

Reply to
Chris

I always called it a "Round Robin" type, but I could be wrong.

Reply to
WangoTango

That's one I'll actually disagree with. Round robin to me implies a lack of prioritization, whereas this is explicitly priority based. It's the difference between:

while(1) { for {task=tasklisthead; task->fptr != NULL; task++) { if (task->readyflag) { task->fptr(); /* The break makes it priority, without it is round robin. */ break; } } }

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
 
Email address domain is currently out of order.  See above to fix.
Reply to
Rob Gaddi

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.