lkml.org 
[lkml]   [2001]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] processes with shared vm
On Fri, 17 Aug 2001, Dave McCracken wrote:

> --On Friday, August 17, 2001 22:55:37 +0200 Andi Kleen <ak@suse.de> wrote:
>
> > Even with a tgid you would need some way to avoid its counter wrapping
> > and getting reused.
>
> While in theory the pid that is used for tgid should never die while the
> thread group exists, this case needs to be handled for thread groups in
> general. The number shouldn't be re-used for a pid as long as it's in use
> as a tgid.

Be careful, I tested by using _clone() dircetly and let a proc A
create two clones B and C. I then let A die, and B &C's ppid was now 1.
Attaching this code, you may find it useful for your tgid patch.
(this code is pretty unclean, ran into the problem that if A cloned B
and B cloned C, and now B died B remained a zombie and I didn't seem to
be able to catch SIGCHLD in A. (wanted to se C's ppid go to 1), probably
something stupid, just didn't bother to pursue it....)

THeory is correct if every one is using pthreads...
(exactly how many thread libs are ut there.....??)

>
> > Also gtop should display correct results even with the programs
> > that don't use CLONE_THREAD.
>
> Are there any programs that use CLONE_VM and not CLONE_THREAD?

attached program ;-)
Maybe not, but *the kernel allows it*!

>
> Actually I think we should make tgid visible in /proc in general because
> it's a useful thing to know, whether it's the right mechanism for gtop or
> not. I'll work up a patch.

Looking forward to it!

>
> Dave McCracken
>
> ======================================================================
> Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
> dmccr@us.ibm.com T/L 678-3059
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>



TJ

--
_________________________________________________________________________

Terje Eggestad terje.eggestad@scali.no
Scali Scalable Linux Systems http://www.scali.com

Olaf Helsets Vei 6 tel: +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud +47 975 31 574 (MOBILE)
N-0621 Oslo fax: +47 22 62 89 51
NORWAY
_________________________________________________________________________
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <signal.h>
#include <sched.h>


pid_t pid0, pid1, pid2;
char * stack1, * stack2;

#define STACKSIZE 1024*8*4

struct sigcall{
int sig;
pid_t pid;
} siglist[1024];
int nsig = 0;

printfsiglist()
{
int i;
for (i = 0; i< nsig; i++)
printf("%d:: %d: %d %d\n", getpid(), i, siglist[nsig].pid, siglist[nsig].sig);
};

void sighand(int sig)
{
siglist[nsig].pid = getpid();
siglist[nsig].sig = sig;
nsig++;
}

int clone2()
{

pid2 = getpid();
printf("clone2 has pid %d\n", pid2);

sleep(100);
printfsiglist();
};


int clone1()
{
char * stack;

pid1 = getpid();
printf("clone1 has pid %d\n", pid1);

sleep(10);
printfsiglist();
return;
exit(0);
};

main()
{
char * stack;
int x, rc;
pid0 = getpid();
printf("clone0 has pid %d\n", pid0);

signal(SIGCHLD, sighand);
signal(SIGALRM, sighand);
stack1 = malloc(STACKSIZE);
stack2 = malloc(STACKSIZE);
stack1 += STACKSIZE;
stack2 += STACKSIZE;
pid1 = __clone(clone1, stack1, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND, NULL);
pid2 = __clone(clone2, stack2, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND, NULL);

sleep(1);
printf("master: clone0 has pid %d\n", pid0);
printf("master: clone1 has pid %d\n", pid1);
printf("master: clone2 has pid %d\n", pid2);

exit(2);


};

\
 
 \ /
  Last update: 2005-03-22 12:57    [W:0.075 / U:1.980 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site