Date: Tue, 1 Apr 2008 07:23:58 -0700 From: "Rao, Nikhil" <nikhil.rao@intel.com> To: "Roman Divacky" <rdivacky@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: RE: pfind() and the proc structure Message-ID: <12A5C15467D5B94F8E0FF265D9498ADD02CBF949@orsmsx419.amr.corp.intel.com> In-Reply-To: <20080401075623.GA19770@freebsd.org> References: <20080329120018.0A8F5106567F@hub.freebsd.org> <12A5C15467D5B94F8E0FF265D9498ADD02CBF8FF@orsmsx419.amr.corp.intel.com> <20080401075623.GA19770@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Ok, I should have caught that :-( Another question -=20
Now that the PROC_LOCK on p is obtained the all_proc lock is released
and the function returns, at this point can't the proc get deallocated ?
Nikhil
242 struct proc *
243 pfind(pid)
244 register pid_t pid;
245 {
246 register struct proc *p;
247=20
248 sx_slock(&allproc_lock);
249 LIST_FOREACH(p, PIDHASH(pid), p_hash)
250 if (p->p_pid =3D=3D pid) {
251 if (p->p_state =3D=3D PRS_NEW) {
252 p =3D NULL;
253 break;
254 }
255 PROC_LOCK(p);
256 break;
257 }
258 sx_sunlock(&allproc_lock);
259 return (p);
260 }
-----Original Message-----
From: Roman Divacky [mailto:rdivacky@freebsd.org]=20
Sent: Tuesday, April 01, 2008 12:56 AM
To: Rao, Nikhil
Cc: freebsd-hackers@freebsd.org
Subject: Re: pfind() and the proc structure
On Mon, Mar 31, 2008 at 11:03:31PM -0700, Rao, Nikhil wrote:
> Hi List,
>=20
> The pfind(..) (in kern_proc.c) function below returns the proc
structure
> for the PID passed in
>=20
> Say the thread that calls pfind() gets blocked at PROC_LOCK(p) (line
255
> below), in the meantime what prevents the process from exiting and
> deallocating the proc structure ? Maybe I am missing something simple
or
> the answer requires knowledge of the mutex implementation.
thats what the allproc_lock is there for
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12A5C15467D5B94F8E0FF265D9498ADD02CBF949>
