Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Apr 2008 20:58:03 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        "Rao\, Nikhil" <nikhil.rao@intel.com>
Cc:        freebsd-hackers@freebsd.org, Roman Divacky <rdivacky@freebsd.org>
Subject:   Re: pfind() and the proc structure
Message-ID:  <878wzxa250.fsf@kobe.laptop>
In-Reply-To: <12A5C15467D5B94F8E0FF265D9498ADD02CBF949@orsmsx419.amr.corp.intel.com> (Nikhil Rao's message of "Tue, 1 Apr 2008 07:23:58 -0700")
References:  <20080329120018.0A8F5106567F@hub.freebsd.org> <12A5C15467D5B94F8E0FF265D9498ADD02CBF8FF@orsmsx419.amr.corp.intel.com> <20080401075623.GA19770@freebsd.org> <12A5C15467D5B94F8E0FF265D9498ADD02CBF949@orsmsx419.amr.corp.intel.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 1 Apr 2008 07:23:58 -0700, "Rao, Nikhil" <nikhil.rao@intel.com> wrote:
> Ok, I should have caught that :-( Another question - 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
> 248         sx_slock(&allproc_lock);
> 249         LIST_FOREACH(p, PIDHASH(pid), p_hash)
> 250                 if (p->p_pid == pid) {
> 251                         if (p->p_state == PRS_NEW) {
> 252                                 p = NULL;
> 253                                 break;
> 254                         }
> 255                         PROC_LOCK(p);
> 256                         break;
> 257                 }
> 258         sx_sunlock(&allproc_lock);
> 259         return (p);
> 260 }

Not until you unlock the specific proc entry.  You are holding a lock
for the specific proc entry, so anyone trying to `reap' the process
would have to wait until you are done with what you are doing.




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