On Sat, Aug 13, 2011 at 3:50 PM, Isaac Marino Bavaresco < isaacbavaresco@yahoo.com.br> wrote: > Hello folks, > > > This week I revisited my SimpleRTOS > () > and ported it to PIC24 devices. > > The first incarnation was just a theoretical proof-of-concept, but the > new implementation is very practical. I'm planning to use it in some > real-world applications. I took some ideas from FreeRTOS > () but the entire code is my own work, together with > some new ideas from myself. > > It uses the concept of co-routines and is co-operative, which means that > all the tasks must call 'Yield' (or 'Delay', etc.) somewhere to allow > the others to run. > > Note: 'Delay' should be 'Sleep', but there is already one macro with > this name defined by MPLAB C30. > > > I got impressed myself with its performance. Some facts: > > The kernel uses just 664 program words and 16 bytes of RAM. Each task > created uses an additional 22 bytes of RAM (plus any data it needs for > doing its job). > > The task switching takes from 32 to 48 instruction cycles from the time > one task calls 'Yeld' to the time the next task is running again (may > take more for more complex tasks, with a lot of Yields, etc). > > > It is implemented in C and compiles with Microchip MPLAB C30 (GCC). It > doesn't use any 'dirty' tricks, so it should be easily ported to any > processor architecture in existence for which there is a C compiler, > even a PIC16F (for which the original version was written). > > It is a compromise between the flexibility offered by and the amount of > RAM and CPU cycles wasted by a real preemptive RTOS. Comparing with > FreeRTOS, it should be possible to run approximately five times more > tasks with the same amount of RAM. > > For now it is already complete enough for real uses, supplying 'Yield', > 'Delay' (sleep), 'CreateTask', 'DeleteTask', 'MutexTake', 'MutexGive' > and 'ResumeTask'. > > In the future I will implement mailboxes and conditional yield (to yield > only after the task has run for a minimum time) to reduce the number of > unnecessary task switching. > > Tasks that are sleeping or are waiting for some object (a mutex, for > instance) don't waste any CPU time until they are running again. > > > I will be posting the code soon on www.piclist.com. > > > Isaac > > Sweet! This is going to be very useful for me. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .