Date: Wed, 9 Jun 2004 21:02:58 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Julian Elischer <julian@elischer.org> Cc: "M. Warner Losh" <imp@bsdimp.com> Subject: Re: cvs commit: src/sys/kern kern_proc.c Message-ID: <20040609190258.GY12007@darkness.comp.waw.pl> In-Reply-To: <Pine.BSF.4.21.0406091151050.57882-100000@InterJet.elischer.org> References: <20040609182041.GV12007@darkness.comp.waw.pl> <Pine.BSF.4.21.0406091151050.57882-100000@InterJet.elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040609190258.GY12007>