clone() + glibc thread safe?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

clone() + glibc thread safe?

Russell Leighton

Can you safely use glibc functions in a thread safe way (e.g., malloc()
and friends) from threads generated by:

     clone(f, stack, CLONE_FS|CLONE_FILES|CLONE_VM, t)

Thx


Russ


Reply | Threaded
Open this post in threaded view
|

Re: clone() + glibc thread safe?

Arjan van de Ven-4
On Wed, 2006-01-11 at 20:40 -0500, Russell Leighton wrote:
> Can you safely use glibc functions in a thread safe way (e.g., malloc()
> and friends) from threads generated by:
>
>      clone(f, stack, CLONE_FS|CLONE_FILES|CLONE_VM, t)

no

unless you tell glibc you're using threads (by using the glibc threading
primitives) glibc doesn't provide such thread safety.
(glibc at runtime knows you have threads and switches to thread-safe
operations)