Re: request for help



On Tue, 21 August 10:57 Pawel Salek wrote:
> 
> On 2001-08-21 11:27 Brian Stafford wrote:
> > On Tue, 21 August 10:01 christophe barbé wrote:
> > Can't help there, sorry.  Using uname() avoids the fork/exec and
> > associated
> > threading problems - I know there are pthreads functions designed to
> > prevent
> > potential deadlock when threaded processes fork but I forget what they
> > are.
> 
> I wonder whether we need these functions to fix this gnome_async_exec()
> hang people experience?

I remembered the name of the function: its pthread_atfork().

>From "man pthread_atfork"

       To  understand  the purpose of pthread_atfork, recall that
       fork(2)  duplicates  the  whole  memory  space,  including
       mutexes in their current locking state, but only the call­
       ing thread: other threads are not  running  in  the  child
       process. Thus, if a mutex is locked by a thread other than
       the thread calling fork, that  mutex  will  remain  locked
       forever in the child process, possibly blocking the execu­
       tion of the child process. To avoid this, install handlers
       with  pthread_atfork as follows: the prepare handler locks
       the global mutexes (in locking order), and the parent  and
       child  handlers  unlock  them (in reverse order). Alterna­
       tively, prepare and parent can be set to NULL and child to
       a  function  that  calls  pthread_mutex_init on the global
       mutexes.

Hope this is of use.

Brian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]