The direction of malloc?
Ondřej Bílka
neleai@seznam.cz
Wed Dec 18 12:21:00 GMT 2013
On Wed, Dec 18, 2013 at 01:01:24AM +0100, Torvald Riegel wrote:
> On Tue, 2013-12-17 at 20:08 +0100, OndÅej BÃlka wrote:
> > On Tue, Dec 17, 2013 at 01:59:57PM +0100, Torvald Riegel wrote:
> > > On Mon, 2013-12-16 at 22:23 +0100, OndÅej BÃlka wrote:
> > > > Please explain how spinning could improve performance in single thread
> > > > applications.
> > >
> > > You spoke about lockless code, so obviously concurrent code. My comment
> > > was thus referring to concurrent code. If you have a single-threaded
> > > program, then you can avoid synchronization, obviously (ignoring
> > > synchronization just for reentrancy...).
> > >
> > And we for malloc use a switch variable to avoid lock path and set it
> > when pthread_create is called? For reentancy a ordinary variable suffices.
>
> Depending on the algorithm, even for reentrancy you might need atomic
> operations (eg, to keep under control what the compiler does with the
> code, or using a CAS to avoid pending stores).
For reordering barrier it suffices to use
__asm__ __volatile__( "" : : :"memory");
Could a pending write really happen, it is kernel responsibility to do
serialization which includes waiting for pending stores?
More information about the Libc-alpha
mailing list