: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 - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
-Matt
Matthew Dillon
<[EMAIL PROTECTED]>
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message