Gerhard Fiedler escreveu: > William "Chops" Westfield wrote: > > = >> On Jun 14, 2009, at 8:21 AM, Isaac Marino Bavaresco wrote: >> >> = >>> This is basic, usually the designer must ensure only one task uses >>> each resource (serial port, etc.) at any given time (just one task >>> use each resource ever or using a mutex/open, close, etc.). >>> = >> Which designer are YOU talking about? I'm claiming that the designer >> of the C18 libraries is unlikely to have taken into account all >> possible implementations of the multitasking operating systems that >> might run on the same software, and so the C18 library itself is VERY >> unlikely to be "thread safe" in most of its functions. = >> = > > AFAIK, thread safety is not part of the C standard, so whether or not a > specific compiler or library is or is not thread-safe needs to be > deduced from the guarantees the compiler or library gives. If they don't > give any, this is probably not a good sign. Even if a given version is, > this could be by accident and could be broken by any future update if > it's not guaranteed by the designers. > > Gerhard > = I use MPLAB-C18 with FreeRTOS in a daily basis, and most of the MPLAB-C18 library is thread safe and re-entrant. Several of the assembly files are explicitly documented as being re-entrant. The only clearly non-reentrant functions are strtok (strtok.c), strtokrampgm (stokrp.c), strtokpgmram (stokpr.c), strtokpgm (stokpgm.c) and the busy-wait functions (Delay1KTCYx, Delay10KTCYx, Delay10TCYx, Delay100TCYx), because they use static variables. The math functions and built-in operations use static variables in the section MATH_DATA, but FreeRTOS saves and restores this section in the context switch. The peripheral library functions must be considered non-reentrant and the programmer must provide sinchronization using mutexes or critical sections. Best regards, Isaac __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist