On Thu, Feb 13, 2014 at 01:22:41PM -0800, Richard Henderson wrote:
> > +/* This is to enable best-effort cleanup after fork.  */
> > +static int gomp_we_are_forked = 0;
> 
> bool, no explicit initialization, possible removal, see below.
> 
> > +static void
> > +gomp_free_thread_pool (int threads_running)
> 
> bool for threads_running.  It looks like a count otherwise.
> 
> > +gomp_after_fork_callback ()
> 
>  (void)
> 
> > +      pthread_atfork (NULL, NULL, &gomp_after_fork_callback);
> 
> & not needed.
> 
> Any reason not to just run gomp_free_thread_pool from gomp_after_fork_callback
> directly?  I see no restrictions on what kind of code is allowed to execute
> during that callback.

Well, fork is async signal safe function, so calling malloc/free, or any
kind of synchronization primitives is completely unsafe there.

The only safe thing could be to atomically or in some global flag (or set
some TLS flag?) and deal with the freeing next time you encounter omp
parallel.  But, the state of the old thread pool may be in some inconsistent
shape.

        Jakub

Reply via email to