EmbeddedRelated.com
Forums

Thread safe printf?

Started by JeGy December 18, 2008
JeGy wrote:
> Hi, > > does anyone here know > if the IAR AVR C-compiler sprintf() and associated functions > are thread safe in in multi-tasking, e.i. FreeRTOS? > > Regards > > Jens
Sorry I didn't think of checking this when you first posted. I checked the source, none of the printf variants in the IAR libraries are thread safe, this includes sprintf. -- Scott
"Not Really Me" <scott@validatedQWERTYsoftware.XYZZY.com> wrote in message 
news:6r9q9gF5k0vU1@mid.individual.net...
> JeGy wrote: >> Hi, >> >> does anyone here know >> if the IAR AVR C-compiler sprintf() and associated functions >> are thread safe in in multi-tasking, e.i. FreeRTOS? >> >> Regards >> >> Jens > > Sorry I didn't think of checking this when you first posted. I checked > the source, none of the printf variants in the IAR libraries are thread > safe, this includes sprintf.
According to their AVR compiler documentation their sprintf() implementation is thread safe - so it is interesting if your inspection shows otherwise. The FreeRTOS download includes a mini implementation of sprintf() that is thread safe. I normally use that regardless as it uses much less stack than standard library variants. -- Regards, Richard. + http://www.FreeRTOS.org Designed for microcontrollers. More than 7000 downloads per month. + http://www.SafeRTOS.com Certified by T&#4294967295;V as meeting the requirements for safety related systems.