Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Oct 2000 13:17:42 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Chuck Paterson <cp@bsdi.com>
Cc:        John Baldwin <jhb@freebsd.org>, arch@freebsd.org, John Polstra <jdp@polstra.com>, Daniel Eischen <eischen@vigrid.com>, Matt Dillon <dillon@earth.backplane.com>, Greg Lehey <grog@lemis.com>
Subject:   Re: Mutexes and semaphores
Message-ID:  <20001003131741.K27736@fw.wintelcom.net>
In-Reply-To: <200010032001.OAA12968@berserker.bsdi.com>; from cp@bsdi.com on Tue, Oct 03, 2000 at 02:01:02PM -0600
References:  <20001003121604.H27736@fw.wintelcom.net> <200010032001.OAA12968@berserker.bsdi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Chuck Paterson <cp@bsdi.com> [001003 13:01] wrote:
> 
> concerning asmlinkage long sys_getppid(void)
> 
> 
> 	I would point out that the kernel could be pre-empted
> for an arbitrary long period of time and that by the time
> you look at the pointer it may no longer point at anything
> usefull, and could even fault. With the multi-threaded kernel this
> can happen just from interrupts, you don't even have to wander
> into the much less likely, but still possible, case of having
> a top half preempt.

The idea is that the parent pointer will always reference something,
'struct proc' in Linux and I'm pretty sure FreeBSD is never free'd
back to the system, therefore one can safely dereference the pointer
at any time, you just need to make sure it didn't change afterwards.

You also need to order your assignment of ppid properly and at all
times make sure it's either pointing to it's parent, or init.

-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001003131741.K27736>