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 (works fine on 328p and atmega2560 )...
I built many of those little kernels for different cpu over the years (there is also many os outthere too).
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 - prototype file
osp.c - c code
zosavr.ino a silly test for testing the kernel.
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
I built many of those little kernels for different cpu over the years (there is also many os outthere too).
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 - prototype file
osp.c - c code
zosavr.ino a silly test for testing the kernel.
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