Is printf thread-safe?

Discussion in 'C++' started by Steven, Jun 26, 2003.

  1. Steven

    Steven Guest

    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
    Steven, Jun 26, 2003
    #1
    1. Advertising

  2. Steven

    Artie Gold Guest

    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 =---
    Artie Gold, Jun 26, 2003
    #2
    1. Advertising

  3. Steven

    Steven Guest

    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
    Steven, Jun 26, 2003
    #3
  4. Alexander Terekhov, Jun 26, 2003
    #4
  5. Steven

    Vijay B Guest

    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.
    Vijay B, Jun 26, 2003
    #5
  6. Steven

    Chris Torek Guest

    >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.
    Chris Torek, Jun 27, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven

    Is printf thread-safe?

    Steven, Jun 26, 2003, in forum: C Programming
    Replies:
    12
    Views:
    2,614
    Mark McIntyre
    Jun 29, 2003
  2. ben
    Replies:
    4
    Views:
    610
    Martin Ambuhl
    Jun 26, 2004
  3. nrhayyal
    Replies:
    2
    Views:
    2,004
    BigBrian
    Nov 3, 2005
  4. Gabriel Rossetti
    Replies:
    0
    Views:
    1,310
    Gabriel Rossetti
    Aug 29, 2008
  5. John Nagle
    Replies:
    5
    Views:
    463
    John Nagle
    Mar 12, 2012
Loading...

Share This Page