Date: Tue, 12 Dec 2000 22:01:42 -0600 (CST) From: Jonathan Lemon <jlemon@flugsvamp.com> To: wollman@khavrinen.lcs.mit.edu, net@freebsd.org Subject: Re: MEXT_IS_REF broken. Message-ID: <200012130401.eBD41gc95284@prism.flugsvamp.com> In-Reply-To: <local.mail.freebsd-net/200012130250.VAA55319@khavrinen.lcs.mit.edu> References: <local.mail.freebsd-net/20001211014837.W16205@fw.wintelcom.net> <local.mail.freebsd-net/Pine.BSF.4.21.0012111223350.21769-100000@jehovah.technokratis.com> <local.mail.freebsd-net/20001212014429.Y16205@fw.wintelcom.net> <local.mail.freebsd-net/20001212015059.Z16205@fw.wintelcom.net> <local.mail.freebsd-net/20001212143214.H2312@canonware.com> <local.mail.freebsd-net/20001212175937.M16205@fw.wintelcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <local.mail.freebsd-net/200012130250.VAA55319@khavrinen.lcs.mit.edu> you write: ><<On Tue, 12 Dec 2000 17:59:37 -0800, Alfred Perlstein ><bright@wintelcom.net> said: > >> Actually, in truth I think you can get the code right like so: > >> long x = _mmm->m_ext.ref_cnt->refcnt; >> while (!atomic_cmpset_long(&_mmm->m_ext.ref_cnt->refcnt, x - 1, x)) >> ; > >Cool! You've just (almost) reinvented non-blocking parallel >reference-counts. Of course, what you really need is: > >long >atomic_decrement_long(long *where) >{ > long oldval; > > do { > oldval = *where; > } while (compare_exchange(where, &oldval, oldval - 1) != FAILURE); Gee, this looks suspiciously like jhb's refcount patch: +static __inline int +refcount_release(refcount_t *count) +{ + int value; + + do { + value = *count - 1; + } while (!atomic_cmpset_rel_int(count, value + 1, value)); + return (value == 0); +} Sure you haven't been peeking at it? :-) :-) :-) -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012130401.eBD41gc95284>