From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 1 06:03:34 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA1D9106564A for ; Tue, 1 Apr 2008 06:03:34 +0000 (UTC) (envelope-from nikhil.rao@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx1.freebsd.org (Postfix) with ESMTP id A55878FC41 for ; Tue, 1 Apr 2008 06:03:34 +0000 (UTC) (envelope-from nikhil.rao@intel.com) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 31 Mar 2008 23:03:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.25,585,1199692800"; d="scan'208";a="363875546" Received: from orsmsx334.amr.corp.intel.com (HELO orsmsx334.jf.intel.com) ([10.22.226.45]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2008 23:03:34 -0700 Received: from orsmsx419.amr.corp.intel.com ([10.22.226.88]) by orsmsx334.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 31 Mar 2008 23:03:33 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Mon, 31 Mar 2008 23:03:31 -0700 Message-ID: <12A5C15467D5B94F8E0FF265D9498ADD02CBF8FF@orsmsx419.amr.corp.intel.com> In-reply-to: <20080329120018.0A8F5106567F@hub.freebsd.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: pfind() and the proc structure Thread-Index: AciRlVXRan1T6qPHQM+SE5skl3WtfwCJwAKw References: <20080329120018.0A8F5106567F@hub.freebsd.org> From: "Rao, Nikhil" To: X-OriginalArrivalTime: 01 Apr 2008 06:03:33.0875 (UTC) FILETIME=[1E232C30:01C893BE] Subject: pfind() and the proc structure X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Apr 2008 06:03:34 -0000 Hi List, The pfind(..) (in kern_proc.c) function below returns the proc structure for the PID passed in 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. Thanks, 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 }