Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is printf thread-safe?

Reply
Thread Tools

Is printf thread-safe?

 
 
Steven
Guest
Posts: n/a
 
      06-26-2003
Is printf thread-safe?

Someone tell me it isn't, however, I think it is.
If it isn't, then why?

Thank you in advance.
--
Steven Ding
 
Reply With Quote
 
 
 
 
Artie Gold
Guest
Posts: n/a
 
      06-26-2003
Steven wrote:
> Is printf thread-safe?


Yes. No. Maybe.
Since neither standard C nor standard C++ define a thread model, there's
no way to answer this question in the context of either newsgroup.

>
> Someone tell me it isn't, however, I think it is.
> If it isn't, then why?
>

It's an implementation issue. Please ask in a forum specific to your
platform -- or in news:comp.programming.threads.

HTH,
--ag

--
Artie Gold -- Austin, Texas



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
 
Steven
Guest
Posts: n/a
 
      06-26-2003
Artie Gold <> wrote in news::

> Yes. No. Maybe.
> Since neither standard C nor standard C++ define a thread model,
> there's no way to answer this question in the context of either
> newsgroup.
>
> It's an implementation issue. Please ask in a forum specific to your
> platform -- or in news:comp.programming.threads.
>
> HTH,
> --ag
>


I get it!
Thank you very much.

--
Steven Ding
 
Reply With Quote
 
Alexander Terekhov
Guest
Posts: n/a
 
      06-26-2003

Steven wrote:
>
> Is printf thread-safe?


http://groups.google.com/groups?selm...4E99D%40web.de

regards,
alexander.
 
Reply With Quote
 
Vijay B
Guest
Posts: n/a
 
      06-26-2003
Hi

No the printf thread is not a safe one as we always use only one
output buffer for the printf's. As a result of this the printf
statements on a multi-threaded application are not safe. resort to
other techniques or place locks before printf(check to avoid
deadlocks). Use system calls such as read and write ..reading and
writing from standard output and standard input instead as these are
multi-processor and multi-thread safe.

Vijay

Steven <> wrote in message news:<Xns93A65C98ED65STEVEN@202.108.36.140>...
> Is printf thread-safe?
>
> Someone tell me it isn't, however, I think it is.
> If it isn't, then why?
>
> Thank you in advance.

 
Reply With Quote
 
Chris Torek
Guest
Posts: n/a
 
      06-27-2003
>Steven <> wrote in message news:<Xns93A65C98ED65STEVEN@202.108.36.140>...
>> Is printf thread-safe?


In article < >
Vijay B <> writes:
> No the printf thread is not a safe one as we always use only one
>output buffer for the printf's.


I have already noted elsethread that this is system-dependent; I
will now add that, for BSD/OS, printf() *is* thread-safe.

How do you know the OP is using your particular system?
--
In-Real-Life: Chris Torek, Wind River Systems (BSD engineering)
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://67.40.109.61/torek/index.html (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printf affects following printf/s azza C Programming 0 10-17-2010 09:43 AM
Extracting printf(...) from (void) printf(....) guru Perl Misc 8 02-03-2009 10:37 PM
java printf Alex Polite Java 18 04-15-2006 04:09 AM
(void) printf vs printf whatluo C Programming 29 09-08-2005 05:42 PM
bus error with printf line included, error without printf line? ben C Programming 4 06-26-2004 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57