??? 08/07/08 23:24 Read: times |
#157312 - small multitasker Responding to: ???'s previous message |
I wrote a small multitasking exec in C for 8051 and it handles timing including longer times pretty well I think. I have two time delay functions in units of either 10ms or seconds and the exec lets the task sleep while others do their thing until the time expires. Tasks can signal other tasks too.
I don't copy much of the stack (I think just return address) to achieve context switching so it can't slow it down much, though I haven't worked it out. I allocate task data as global data so the compiler doesn't try to overlay it. I mostly run things with a few (<5 so far) simple tasks, in under 2kb including scheduler. It could do more but I wanted to get it running in a really small memory and was ok in 128 bytes of RAM. I had thought of posting a copy somewhere here but I'm sure others could do better and it would need a bit of tidying anyway. |