[PVFS-developers] libpvfs and threads

Rob Ross rross at mcs.anl.gov
Wed Apr 21 17:59:59 EDT 2004


Applied.  Thanks!

Rob

On Fri, 16 Apr 2004, Porter Don wrote:

> 
> Hello,
> 
> We had a threaded application that needed to use the pvfs library.  Clearly
> the library is not threadsafe and we have not attempted to tackle that one.
> We did find, at least in the old Linux threading model, that we couldn't
> even get the library to work in a simple threaded application with a mutex
> around every pvfs_* call.  This is because of some code that tries to detect
> a fork.  
> 
> The library keeps a global pid.  If it detects that the current process's
> pid is different than the stored pid, all mgr/iod connections are closed in
> the child and reopened.  Because threads get a new pid but share memory, two
> threads will thrash each other's sockets with the manager/iods.  
> 
> Stuart White fixed this by associating a pid with each socket rather than
> having one global pid.  When a process sees that it has sockets
> corresponding to a different pid, it simply ignores them and opens new ones
> for itself.
> 
> Once again, this patch does not in any way make libpvfs threadsafe.  This
> patch does allow one to use libpvfs in an application that is threaded (for
> some reason other than pvfs i/o) with locking around all libpvfs calls.
> 
> Any feedback is appreciated as usual.
> 
> Thanks,
> don
> 
> 



More information about the PVFS-developers mailing list