Let's Make Robots!

A silly really small co-operative kernel ... in case you need one :o)


so ... one of my friend needed a little help with concurrency so last weekend I chopped out one silly little co-operative kernel for his arduino applications...

I built many of those little kernels for different cpu over the years.

they are usually simple ( not time sliced ) and they work fine with ucontroller and few cooperative tasks.

this silly one is as much thin you can go, only simple tasks( with their own stack) and semaphore (with P and V) , all in C, and using for context switching setjump() and longjump().

my current bot used a more extended version of this one,  but this code can give to some people a good starting point...

so there is 3 files attached:

osp.h - (  added has osp.txt ) prototype file,  it seems we can't attach .h file :o/

osp.c - c code

zosavr.ino  (  added has zosavr.txt )  a silly test for testing the kernel. it seems we can't attach .ino file :o/

the test is basically 3 tasks

taskIdle will emulate the arduino main function.

task0 ans task1 will synchronize themself with semaphores and blink the pin13 led ...

of course in the real word, the led should be a ressource and it should be gated be semaphore...  but this is just a demo so ...

enjoy :o)


zosavr.txt1.39 KB
osp.c2.13 KB
osp.txt225 bytes