Task Scheduler

jimLee:
But even sudo multitasking makes those little jobs SO much easier!

jimLee:
My example

a cell phone isn't a "little job". When I worked on a CDMA phone, the control processor guys used an OS but we didn't use one the DSP.

What? Sure it is, just a lot of small jobs in one package.

Every item on the screen is an "idler" so that it takes care of itself. The piece of code that watches for calls and SMS message is an "idler". Its a fine example how handling the small jobs well, can let you scale up to more complex things easily.

Just because the theory was proved out, doesn't mean it its an invalid example.

-jim lee

sorry. i thought it was a cell phone, not a messaging device

It is a cell phone.

jimLee:
Actually I followed the same path awhile ago. I wrote a class idler that has a method void idle(void); Anything that is derived from this class has an idle() method you can inherit and fill in to do whatever you want. Along with all this, comes a function idle() I put in my loop() function. This autamatically calls al my myriad of "ilders" each time through.

If you want to deal with time, as in "lets only look every 100ms" I wrote a class timeObj that works like an egg timer. Set it for a time and it has a method ding() that returns true if the time has expired. Between the two, all of the worries about doing multiple things at once, just evaporated.

I tried to share this stuff, but was basically told I was stupid for writing such drivel.

Since then I've noticed, its common for people to write stuff that really helps them, but just confuses the heck out of everyone else. So I guess begin called dumb, is a somewhat common response.

-jim lee

Well thought. I think I might implement something similar to that idle function, as I have some tasks that need to run with a very precise timing, but others can fit in any idle cycle. At the moment, with my library it is up to the developer to figure out the order of execution of every single tsk, and I am finding it more and more troublesome as I add more and more tasks. I tried to make it as simple as possible, so you only need to add or remove tasks, no need for inheritance or other fuzzy concepts for beginners. Ideally, it would be better to do some sort of preemptive multitasking, for example measuring how long each task takes to run (maybe running a number of times each task in the setup()) and calculating an average time, and later fit the task in the best idle slot. I am pretty sure that is easier said than done, there are some statistics and OS concepts to take into account that are above my level.