Re: cvs commit: src/sys/kern kern_proc.c

From: Julian Elischer (julian_at_elischer.org)
Date: 06/09/04

  • Next message: Julian Elischer: "Re: reference counting.. continued.."
    Date: Wed, 9 Jun 2004 12:00:30 -0700 (PDT)
    To: Pawel Jakub Dawidek <pjd@FreeBSD.org>
    
    

    On Wed, 9 Jun 2004, Pawel Jakub Dawidek wrote:

    > On Wed, Jun 09, 2004 at 11:23:48AM -0700, Julian Elischer wrote:
    > +> I do actually agree that a general purpose reference counting
    > +> API is very difficult to use in every situation and that there
    > +> are situations where you just HAVE to roll your own..
    >
    > Maybe we can use macros to do this, something like:
    >
    > #define REFCNT_MTX(foo, prefix, type, mtx_field, refcnt_field, destroy_func) \
    > foo void \
    > prefix ## _hold(type *obj) \
    > { \
    > \
    > mtx_lock(&obj->mtx_field); \
    > obj->refcnt_field++; \
    > mtx_unlock(&obj->mtx_field); \
    > } \
    > \
    > foo void \
    > prefix ## _free(type *obj) \
    > { \
    > int refcnt; \
    > \
    > mtx_lock(&obj->mtx_field); \
    > refcnt = --obj->refcnt_field; \
    > mtx_unlock(&obj->mtx_field); \
    > if (refcnt == 0) \
    > destroy_func(obj); \
    > }
    >
    > And the same for REFCNT_ATOMIC() and REFCNT_SPIN()?
    > 'foo' could be for example 'static' or 'static __inline'.

    I certainly agree that there is the possibility that there may need to
    be several kinds of refcounts..

    there are also examples where several operations need to be done
    "atomically" but only one of those operations is the reference count.
    Such cases need a lock to be held anyhow. (or a critical section or
    something)
    For these sorts of things plain increments and decrements would
    suffice.

    As I mentionned before, it is also tricky how one handles
    the freeing of a reference to an object
    when you are in some spinlock'd region or an interrupt handler..

    These various cases may require reference counts of different types.

    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Julian Elischer: "Re: reference counting.. continued.."

    Relevant Pages

    • Re: How to make custom linked cross-references?
      ... two macros \extractrefnum and \extractpagerefnum. ... If somebody wants the package on CTAN, ... A reference to section~of this book ... You might wish to take reference to yet another label within ...
      (comp.text.tex)
    • Re: VBA to remove modules in .DOT
      ... The macros remain in the .DOT with a reference back to the template. ... >>> Sub DeleteProcedure() ...
      (microsoft.public.word.vba.beginners)
    • PATCH, RFC: Version 5 of 2.6 Codingstyle
      ... have a reference count on it, you almost certainly have a bug. ... inline functions are preferable to macros resembling functions. ... -must enclose the expression in parentheses. ... +gcc internals and indent, all available from www.gnu.org. ...
      (Linux-Kernel)
    • Re: uppercase + ef = undefined reference
      ... this can cause errors in the headers/section titles/ToC. ... temporary macros in the right places in order to ... This reference to is OK. ... The second possibility is saving stuff like label-names away ...
      (comp.text.tex)
    • Setvalue action - 2 seperate macros using same column?
      ... I have 2 macros which open 2 different forms but ... my ClientID number to the new form (spouse details) using the SetValue ... opens but I get an error saying "You ... The macro's item value has been changed to reference the correct form name ...
      (microsoft.public.access.macros)