test/demo patch for pthread manager

Pavel Krauz xkr@nettest.dk
Tue Mar 28 01:15:00 GMT 2000


Hello

This is a test/demo patch to glibc-linuxthreads-2.1.3. It requires
kernel 2.3.99
- particularly for (CLONE_PARENT and (2) prctl).

1. It makes manager a parent of all threads including main.
    This is achieved through clone2 (see further)

2. Thread creation and deletion is performed by the thread
who calls pthread_create/join thus the request is not transferred to
manager

3. Manager distributes signals across all threads (including main), so
the manager pid
serves as the pid of the process.

4. The original manager is preserved for backward compatibility.
   The decision whether to use new manager is done currently in
init_rtsigs() (assumption
that if the RT signals are present then CLONE_PARENT and (2) prctl is
also supported).


Possible enhancements that are not implemented:
1. The fork() in pthread lib. should do CLONE_PARENT, so the new process
will become a child of
the thread manager, and not the child of the thread who calls fork() -
thus preserve
parent/child relationship across processes (because the manager pid
serves as process pid).

2. exec could be transferred to thread manager and executed there after
killing all threads.
This way the parent-child relationship (for example shell - pthread
program that execs)
will be preserved.

3. The meaning of getpid() is the pid of manager and getppid() is the
parent of the manager
for all threads.


about clone2
----------
The clone2 is standard clone except that it switches stacks (in user
space, no kernel
patches required). It is currently implemented only for i386
architecture. For example:

void main()
{
    clone2(f, stack, flags, NULL);
}

The main with its original stack will run in child process after
executing clone2.
The f() will run with supplied stack in parent process (the process that
calls main).


Any ideas, comments or feedback would be appreciated.

regards
Pavel



More information about the Libc-alpha mailing list