Martien van Deth wrote this RTOS for BASCOM-AVR. It can be extended to handle more tasks.
Download source code in an106.zip