Subject: clone()
To: None <tech-kern@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 09/16/2007 02:47:59
Hi,

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 scheme,
so the reference counting and locking gets complicated.

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 face
of it that makes a lot of sense. It would remove some the complexity around
sharing those data structures.

That would create problems for threaded applications that use kill() to post
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.

Are there any other potential problems with this? How would it affect Irix
emulation?

Thanks,
Andrew