On Fri, 4 May 2001, Chris Stith wrote:

> My suggestion is to let libraries that are threadsafe (system
> libraries as well as Perl moduels would be nice) be used as such
> so the advantages of that can be realized, while at the same time
> defaulting to serialized calls for libraries which are not, so
> your threaded programs which need to call nonreentrant functions
> can do so with some level of safety.

I still don't buy it.  Consider a non-thread-safe getpwnam(), and
serialized access from two threads:

Thread | Operation
  1    | struct passwd *ent = getpwnam("valid");
  2    | struct passwd *ent = getpwnam("invalid");
  1    | printf("home: %s\n", ent->pw_dir);  /* boom; ent is NULL */

So to make the Perl code C<$id = getpwnam()> safe, I think perl would not
only have to serialize calls, but copy the data from the static pointer
into thread-local storage.

Should perl be given this overhead on all platforms just for the benefit
of those with non-thread-safe libcs?  Probably not; it should probably
call a reentrant interface if available.  But the reentrant interfaces are
all different.  Hence the foam frothing from Jarkko's mouth.

Cheers,
-Ben

-- 
signer: can't create ~/.sig: Wrong medium type




Reply via email to