From owner-cvs-all@FreeBSD.ORG Wed Jun 9 19:03:13 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 75F3716A4D0; Wed, 9 Jun 2004 19:03:13 +0000 (GMT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2368A43D55; Wed, 9 Jun 2004 19:03:13 +0000 (GMT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 9E989AC995; Wed, 9 Jun 2004 21:02:58 +0200 (CEST) Date: Wed, 9 Jun 2004 21:02:58 +0200 From: Pawel Jakub Dawidek To: Julian Elischer Message-ID: <20040609190258.GY12007@darkness.comp.waw.pl> References: <20040609182041.GV12007@darkness.comp.waw.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="s8ux8MQukyWAm3r7" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: src-committers@FreeBSD.org cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: phk@phk.freebsd.dk cc: Bosko Milekic cc: Nate Lawson cc: "M. Warner Losh" Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 19:03:13 -0000 --s8ux8MQukyWAm3r7 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 09, 2004 at 11:54:06AM -0700, Julian Elischer wrote: +> > Ok, I get it now. Even if there will be a race between two threads, i.= e.: +> >=20 +> > [ref_cnt is 2] +> >=20 +> > thread1 thread2 +> >=20 +> > atomic_substract(obj, 1) +> > [ref_cnt is 1] +> > atomic_substract(obj, 1) +> > [ref_cnt is 0] +> > atomic_cmpset(obj, 0, 1) -> true +> > [do clean up] +> > atomic_cmpset(obj, 0, 1) -> false +> > [skip cleanups] +> >=20 +> > (thread2 sets ref_cnt to 0, but thread1 destroys objects) we free obje= ct +> > only once. Cool, I like it:) +>=20 +> The method shown above has, however the disadvantage of being +> less than obvious. ALso thread 2 is likely to get a page fault, which +> is a less than perfect result.. +>=20 +> the reference count must never be read or written after the [cleanup] +> because it may free the page on which teh counter is kept. Right... Nice catch. So Bosko probebly have to rethink his model. --=20 Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! --s8ux8MQukyWAm3r7 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAx17iForvXbEpPzQRAtIfAKDxcQ5dQYTpabZt4Gxqzt6Pls2EDACeM2b1 jIg7lzU2AlEGNXL6MhNk2o0= =99+x -----END PGP SIGNATURE----- --s8ux8MQukyWAm3r7--