Printf and multiple threads

Discussion to talk about software related topics only.
Post Reply
andystephenson
Posts: 5
Joined: Fri Apr 25, 2008 12:42 am

Printf and multiple threads

Post by andystephenson »

Hi,

I have read somewhere, but I can't find it now, that if you are using printf from multiple threads, you can't use buffered comms - or something to this effect.

Can someone point me to the doc that discusses this, as I want to see what exactly you have to do. When experimenting earlier, I used a critical section around my debug call to make it work, but I may have got lucky.

Do I need to post on yahoo as well, or are most people keeping an eye on both groups?

Thanks,

Andy
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Printf and multiple threads

Post by pbreed »

In some versions of the system Floating Point printf from multiple threads caused some problems.
I believe that this is resolved in the latest releases.

iprintf has always been safe (iprintf is printf without floating point, a lot smaller in the library)


It is possible that printf from multiple threads can cause output wierdness

For example task 1 is printing "The Quick brown fox jumped over the lazy dog"

and task 2 a higher priority gets woken up and prints "at the tone the time is 12:45"

What might come out the serial port is

"The Quick brown fox jat the tone the time is 12:45umped over the lazy dog"

If you need the printf's to be complete by task then you need add some protection to make sure this does not happen.
Post Reply