Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2008 21:45:49 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-threads@freebsd.org
Cc:        David Xu <davidxu@freebsd.org>
Subject:   Re: pthread_cleanup_push as a macro
Message-ID:  <200805302145.49524.jhb@freebsd.org>
In-Reply-To: <20080530184141.GG48790@elvis.mu.org>
References:  <483FA1C0.2010506@freebsd.org> <20080530184141.GG48790@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 30 May 2008 02:41:41 pm Alfred Perlstein wrote:
> * David Xu <davidxu@freebsd.org> [080529 23:40] wrote:
> > I would like to make pthread_cleanup_push and pthread_cleanup_pop as a
> > pair of macros, the current implementation has to malloc() and free() a
> > pthread_cleanup memory block everytime, this is slow, the new one
> > simply uses stack space, note that other OSes have already done it in 
> > this way. The patch keeps old functions and should not have binary
> > compatible problem.
> > 
> > http://people.freebsd.org/~davidxu/patch/pthread_cleanup_push.patch
> 
> Heh, when I had to use QNX on a project this totally confused
> me, but if others are doing it then go for it.
> 
> Does Solaris do it?

It's explicitly documented in the standard that push and pop may be 
implemented as macros and that they have to be paired at the same block level 
(i.e. it's permitted for push to start a new block and declare a new local 
variable and for pop to end that block similar to DROP_GIANT/PICKUP_GIANT in 
the kernel).  Internally the thread libraries already do this for internal 
push/pops to avoid deadlocks.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805302145.49524.jhb>