As promised, here is a test between protosthreads and CoOS, on the ghetto board (STM32F030F running at 24Mhz). Compiler is gcc under CoIDE.
First, CoOS:
GCC / CoOS O0 O1 O2 O3 Os
Freq_rtos 789 1,320 1,319 1,319 1,485
Freq_naked 800 1,332 1,331 1,331 1,498
Efficiency 98.6% 99.1% 99.1% 99.1% 99.1%
Ticks on switch 324 204 215 211 215
Size 7868 4920 4980 5340 4476
Generally in line with the numbers I had for STM32F100RB.
Now, the numbers for protothread:
GCC / Protothreads O0 O1 O2 O3 Os
Freq_rtos 352 705 877 878 1,027
Freq_naked 800 1,332 1,331 1,331 1,498
Efficiency 44.0% 52.9% 65.9% 66.0% 68.5%
Ticks on switch 13,437 11,295 8,185 8,169 7,556
Size 3084 1796 1928 1912 1636
A few things:
1) the libraries used are identical;
2) the user tasks are "largely" identical - 6 tasks blinking the same led. Because the way protothread is configured, you have to set the conditions on each run so the mcu is not blinking the led as fast as it could and you can see that in the efficiency measurements.
3) The foot print of protothread is minimum, as we had expected. The difference is approximately the size of CoOS.
4) Because of structural differences, "ticks on switch" measurements make no sense for protothread. The more meaningful measurements are efficiency: how much time the mcu is actually doing your task, vs. running the OS: switching context in the case of CoOS or testing exit conditions in the case of protothreads.
In the end, I think a lightweight "OS" like protothreads has value on small devices where your tasks are quite similar in execution time. If that's indeed the case, writing your own scheduler or just sequentializing the tasks isn't a bad idea.
For larger chips, a real OS is likely to be more useful.