[openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Tue, 10 Dec 2002 17:49:35 +0100 CET

argent@xxxxxxxxxxxxxxxxxx wrote:
> I think there may be a confusion here between "reentrant" and
> "thread-safe".  IIRC, reentrant functions produce the same result 
> each
> time they are called with identical arguments (e.g. sqrt(8)).  strtok
> is an example of a non-reentrant function (look at it's definition to
> see why).  Thread-safe functions are functions which can be called
> from several threads simultaneously.  IMHO, all the BeOS library
> functions should be thread-safe, although many may not be re-entrant.

I really don't think that's the idea behind it.

> Although the POSIX standard may declare that these functions need not
> be thread-safe, an implementation where they are thread-safe would
> certainly satisfy POSIX.  In BeOS, where threads are pervasive, I'd
> argue that all of the standard library should be thread-safe.

No, those functions *can't* be made thread-safe easily, just have a 
look at their prototypes - they depend on global data. You would need 
to put all global data/strings into fixed TLS slots which is certainly 
not desirable.

Adios...
   Axel.



Other related posts: