Roam Black came up with what looks like a god one too: http://www.romanblack.com/PICthread.htm I haven't used it personally yet but keep the link handy in case I ever need it. I have always admired and trusted his code so if anyone has used his implementation the feedback would be useful. Cheers Chris On 19 April 2013 15:16, Mike wrote: > veegee veegee.org> writes: > > > > > On 2013-04-18 10:59 AM, Joe Wronski wrote: > > > Having never worked with any RTOS due to ROM and RAM limitations, I > find > > > Protothreads fascinating. Where my cow-orkers and I had hand craft= ed > > > state machines which closely resembled the Protothreads expanded > macros, > > > using PT would have made the code more readable and maintainable. I > had > > > never considered using the __LINE__ macro for anything other than > > > compiler error and warning info. And I never realized that you could > > > put the case : argument of a switch within a while loop (Duff's > Device). > > > > Yup, C switches behave somewhat like labels. The cases are valid > > anywhere within the switch. > > > > > > Note that using Protothreads vs "hand crafted" state machines has a > potential disadvantage. The __LINE__ macro will produce case values that > will almost certainly me non-consecutive and which quite probably need 16 > bits to represent. This may prevent the switch statement being implement= ed > as a jump table, and the larger data types on an 8 bit micro will slow > things down and increase memory size. > > Cheers > > Mike > > > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .