Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Apr 2000 10:57:58 -0700 (PDT)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        Greg Lehey <grog@lemis.com>, current@FreeBSD.ORG
Subject:   Re: cvs commit: src/sys/i386/i386 support.s src/sys/kern init_sysent.c kern_prot.c kern_sig.c
Message-ID:  <200004061757.KAA89372@apollo.backplane.com>
References:  <200004021752.KAA13175@freefall.freebsd.org> <20000402163552.P21029@fw.wintelcom.net> <200004022312.QAA51299@apollo.backplane.com> <20000402164700.R21029@fw.wintelcom.net> <200004022338.QAA51565@apollo.backplane.com> <20000402172349.T21029@fw.wintelcom.net> <20000404100911.C53037@freebie.lemis.com> <20000405111950.F20770@fw.wintelcom.net>

next in thread | previous in thread | raw e-mail | index | archive | help

:The version of Linux kernel source that I have uses the first:
:
:asmlinkage long sys_getppid(void)
:{
:	int pid;
:	struct task_struct * me = current;
:	struct task_struct * parent;
:
:	parent = me->p_opptr;
:	for (;;) {
:		pid = parent->pid;
:#if __SMP__
:{
:		struct task_struct *old = parent;
:		mb();
:		parent = me->p_opptr;
:		if (old != parent)
:			continue;
:}
:#endif
:		break;
:	}
:	return pid;
:}
:
:I like it.  mb() is most certainly a "memory barrier" inline to
:force ordering constraints.  interesting how they don't use
:volatile for the pointer though:

    mb() just prevents the compiler from optimizing access to the
    structural fields (otherwise it might move the accesses outside
    the for() loop and you would get an infinite loop.  From the
    compiler's point of view, mb() is a subroutine call (I assume
    in the headers it's a volatile __asm).

    We can either use an mb() type of thing, or we can declare the structural
    field volatile, or we can cast the access to be volatile.

:     /* 
:      * pointers to (original) parent process, youngest child, younger sibling,
:      * older sibling, respectively.  (p->father can be replaced with 
:      * p->p_pptr->pid)
:      */
:     struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
:
:I prefer this method, we can't copy _everything_ into the child struct
:so we might as well do it this way.
:
:Feeling lazy, i'm wondering if we have the equivenlant of a mb()
:macro/inline we'll need one.
:
:-- 
:-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>


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?200004061757.KAA89372>