Subject: Re: clone()
To: Andrew Doran <ad@netbsd.org>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 09/15/2007 19:51:31
--m51xatjYGsM+13rf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Sep 16, 2007 at 02:47:59AM +0100, Andrew Doran wrote:
> Hi,
>=20
> The clone() syscall means that we need to share some data structures among
> processes like the limits. Those structures can also be shared among LWPs
> within those processes, and are usually subject to some kind of COW schem=
e,
> so the reference counting and locking gets complicated.
>=20
> A while back rmind@ suggested changing changing clone() to create new LWPs
> within the same process (instead of creating a new process), and on the f=
ace
> of it that makes a lot of sense. It would remove some the complexity arou=
nd
> sharing those data structures.
>=20
> That would create problems for threaded applications that use kill() to p=
ost
> signals to other threads within the same process (well, to other processes
> really). I think we could work around that by checking to see if a process
> has created a new thread using clone(), and if it has, then allocate a PID
> from the proc table for each thread, but with no associated process. The =
PID
> could then be mapped onto an LWP in the process for sending signals.

As I understand it, clone() really exists to support older Linux threading=
=20
models. I'm not sure how much their threading still needs this.

If thread-in-process-that-also-has-a-PID-that-points-to-it gives the same=
=20
environment that Linux apps want, do it.

But do we really need this complexity for shared structures? If you use=20
clone(), I think it's reasonable that your "process" is single-threaded.=20
Since your threads are separate processes. Likewise I think it'd be=20
reasonable to prohibit a multi-lpw process from calling clone().

Take care,

Bill

--m51xatjYGsM+13rf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iD8DBQFG7JoyWz+3JHUci9cRAh8GAJwPJyhp9Ju/PV5YYTjoGu6XEDsypgCeOj8r
OWpmQ08h2QuDiOP2bDCs6is=
=CJyA
-----END PGP SIGNATURE-----

--m51xatjYGsM+13rf--