From owner-freebsd-net Tue Dec 12 20: 5: 3 2000 From owner-freebsd-net@FreeBSD.ORG Tue Dec 12 20:05:01 2000 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from prism.flugsvamp.com (cb58709-a.mdsn1.wi.home.com [24.17.241.9]) by hub.freebsd.org (Postfix) with ESMTP id 8856E37B400 for ; Tue, 12 Dec 2000 20:05:00 -0800 (PST) Received: (from jlemon@localhost) by prism.flugsvamp.com (8.11.0/8.11.0) id eBD41gc95284; Tue, 12 Dec 2000 22:01:42 -0600 (CST) (envelope-from jlemon) Date: Tue, 12 Dec 2000 22:01:42 -0600 (CST) From: Jonathan Lemon Message-Id: <200012130401.eBD41gc95284@prism.flugsvamp.com> To: wollman@khavrinen.lcs.mit.edu, net@freebsd.org Subject: Re: MEXT_IS_REF broken. X-Newsgroups: local.mail.freebsd-net In-Reply-To: References: Organization: Cc: Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org In article you write: >< 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