Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Nov 1998 18:07:17 -0500 (EST)
From:      Brian Feldman <green@unixhelp.org>
To:        Peter Wemm <peter@netplex.com.au>
Cc:        current@FreeBSD.ORG
Subject:   Re: RFSIGSHARE: forgot patch ;) 
Message-ID:  <Pine.BSF.4.05.9811051806430.9519-100000@janus.syracuse.net>
In-Reply-To: <199811050758.PAA05054@spinner.netplex.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
*Really needs to get the BSD book* In what space do UPAGES lie?

-Brian Feldman

On Thu, 5 Nov 1998, Peter Wemm wrote:

> Brian Feldman wrote:
> > Hrmm.... I don't see why this doesn't work:
> > +     if (args->flags & CLONE_SIGHAND)
> > +       p2->p_sigacts = p->p_sigacts;
> > don't tell me it's pointing into user-space, or some other neglected part
> > of proc? I'll investigate I suppose. This is certainly helping me
> > familiarize myself with the kernel, even if these specific patches cause a
> > trap eventually (probably all the mallocing/freeing). I _really_ need to
> > buy a copy of the BSD book... quick question: zalloc and malloc should
> > each be used in what situations?
> 
> p_sigacts points into the UPAGES, beyond the pcb.. Check the p_addr 
> pointers for examples. 
> 
> The reason you can't do this is because the old proc could go away at any 
> time, the parent process's UPAGES could get swapped out, etc.  To do this, 
> you need to stop the parent from exiting until all children are gone (or 
> keep it's state around), and stop it being swapped.
> 
> > Cheers,
> > Brian Feldman
> > "gaining lots of experience"
> > 
> > On Thu, 5 Nov 1998, Peter Wemm wrote:
> > 
> > > Brian Feldman wrote:
> > > [..]
> > > > --- ./kern/kern_fork.c.orig	Wed Nov  4 20:33:11 1998
> > > > +++ ./kern/kern_fork.c	Wed Nov  4 20:44:29 1998
> > > > @@ -151,6 +151,10 @@
> > > >  		    p1->p_pid);
> > > >  		return (EOPNOTSUPP);
> > > >  	}
> > > > +	if (flags & RFSIGSHARE) {
> > > > +		printf("shared signal space attemped: pid: %d\n",
> > > > p1->p_pid);
> > > > +		return (EOPNOTSUPP);
> > > > +	}
> > > >  #endif
> > > >
> > > >  	/*
> > > 
> > > RFSIGSHARE should work fine on SMP.
> > > 
> > > > @@ -320,6 +324,16 @@
> > > >  	bcopy(p1->p_cred, p2->p_cred, sizeof(*p2->p_cred));
> > > >  	p2->p_cred->p_refcnt = 1;
> > > >  	crhold(p1->p_ucred);
> > > > +
> > > > +	if (flags & RFSIGSHARE) {
> > > > +		p2->p_sig->p_refcnt++;
> > > > +	} else {
> > > > +		p2->p_sig = malloc(sizeof(struct procsig), M_TEMP,
> > > > M_WAITOK);
> > > > +		p2->p_sig->p_refcnt = 1;
> > > > +		p2->p_sigmask = p1->p_sigmask;
> > > > +		p2->p_sigignore = p1->p_sigignore;
> > > > +		p2->p_sigcatch = p1->p_sigcatch;
> > > > +	}
> > > >  
> > > >  	/* bump references to the text vnode (for procfs) */
> > > >  	p2->p_textvp = p1->p_textvp;
> > > 
> > > Umm, you are sharing the signal masks, not the signal handler vectors 
> > > themselves.  Think p_sigacts..  Those are stored after the PCB and are 
> > > paged out.
> > > 
> > > Assuming you take a shot at sharing them, try this:  Keep p_sigacts there 
> > > by default.  If a process attempts to share the signals during a fork, 
> > > then malloc a copy and attach it to both the child and parent.  When the 
> > > reference count drops to 1, the remaining process should probably have 
> > > it's vectors copied to the upages again and the malloc space freed.  But 
> > > good stuff so far! :-)
> > > 
> > > Cheers,
> > > -Peter
> > > 
> > > 
> > > 
> > > 
> > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > with "unsubscribe freebsd-current" in the body of the message
> > > 
> > 
> 
> Cheers,
> -Peter
> --
> Peter Wemm <peter@netplex.com.au>   Netplex Consulting
> "No coffee, No workee!" :-)
> 
> 
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9811051806430.9519-100000>