Is printf thread-safe?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven

    Is printf thread-safe?

    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
  • Artie Gold

    #2
    Re: Is printf thread-safe?

    Steven wrote:[color=blue]
    > Is printf thread-safe?[/color]

    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.
    [color=blue]
    >
    > Someone tell me it isn't, however, I think it is.
    > If it isn't, then why?
    >[/color]
    It's an implementation issue. Please ask in a forum specific to your
    platform -- or in news:comp.progr amming.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 =---

    Comment

    • Steven

      #3
      Re: Is printf thread-safe?

      Artie Gold <agold@bga.co m> wrote in news:3EFA49BE.9 060509@bga.com:
      [color=blue]
      > 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.progr amming.threads.
      >
      > HTH,
      > --ag
      >[/color]

      I get it!
      Thank you very much. :)

      --
      Steven Ding

      Comment

      • Alexander Terekhov

        #4
        Re: Is printf thread-safe?


        Steven wrote:[color=blue]
        >
        > Is printf thread-safe?[/color]



        regards,
        alexander.

        Comment

        • Vijay B

          #5
          Re: Is printf thread-safe?

          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 <wjding@szapsof t.com> wrote in message news:<Xns93A65C 98ED65STEVEN@20 2.108.36.140>.. .[color=blue]
          > 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.[/color]

          Comment

          • Chris Torek

            #6
            Re: Is printf thread-safe?

            >Steven <wjding@szapsof t.com> wrote in message news:<Xns93A65C 98ED65STEVEN@20 2.108.36.140>.. .[color=blue][color=green]
            >> Is printf thread-safe?[/color][/color]

            In article <65637de2.03062 61424.50869384@ posting.google. com>
            Vijay B <vijbala@hotmai l.com> writes:[color=blue]
            > No the printf thread is not a safe one as we always use only one
            >output buffer for the printf's.[/color]

            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.

            Comment

            Working...