atomic reference counting primatives.
From: Julian Elischer (julian_at_elischer.org)
Date: 05/20/04
- Previous message: Robert Watson: "Network Stack Locking"
- Next in thread: M. Warner Losh: "Re: atomic reference counting primatives."
- Reply: M. Warner Losh: "Re: atomic reference counting primatives."
- Reply: Bruce Evans: "Re: atomic reference counting primatives."
- Reply: John Baldwin: "Re: atomic reference counting primatives."
- Reply: John Baldwin: "Re: atomic reference counting primatives."
- Reply: Garance A Drosihn: "Re: atomic reference counting primatives."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 20 May 2004 13:56:36 -0700 (PDT) To: arch@freebsd.org
This has been raised before but I've come across uses for it again and
again so I'm raising it again.
JHB once posted some atomic referenc counting primatives. (Do you still
have them John?)
Alfred once said he had soem somewhere too, and other s have commentted
on this before, but we still don't seem to have any.
every object is reference counted with its own code and
sometimes it's done poorly.
Some peiople indicated that there are cases where a generic refcounter
can not be used and usd this as a reason to not have one at all.
So, here are some possibilities..
my first "write it down without too much thinking" effort..
typedef {mumble} refcnt_t
refcnt_add(refcnt_t *)
Increments the reference count.. no magic except to be atomic.
int refcnt_drop(refcnt *, struct mutex *)
Decrements the refcount. If it goes to 0 it returns 0 and locks the
mutex (if the mutex is supplied)..
refcnt_init(refcnt_t *)
would simply set the counter to 0 if refcnt_t is defined as a simple
type, but could do more if a more complex refcount is used (say for
debugging)
debugging versions of the above might store all sorts of stuff in the
refcount.. (e.g. pid, __LINE__ __FUNCTION__ etc.)
vm->vm_exitingcnt)
If these were in place it would be a first step in
tightennign up some of the reference counting we see in the kernel
and there are several places I've seen over the last few years where
locks are used purely to allow reference counts to be manipulated.
thoughts....?
better ideas?
_______________________________________________
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"
- Previous message: Robert Watson: "Network Stack Locking"
- Next in thread: M. Warner Losh: "Re: atomic reference counting primatives."
- Reply: M. Warner Losh: "Re: atomic reference counting primatives."
- Reply: Bruce Evans: "Re: atomic reference counting primatives."
- Reply: John Baldwin: "Re: atomic reference counting primatives."
- Reply: John Baldwin: "Re: atomic reference counting primatives."
- Reply: Garance A Drosihn: "Re: atomic reference counting primatives."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: [rfc: patch 2/6] rcuref APIs
... Adds a set of primitives to do reference counting for objects ... that are looked
up without locks using RCU. ... * rcuref_inc - increment refcount for object. ...
* @rcuref: reference counter in the object in question. ... (Linux-Kernel) - Re: [PATCH 0/6] files: rcuref APIs
... Adds a set of primitives to do reference counting for objects ... that are looked
up without locks using RCU. ... * rcuref_inc - increment refcount for object. ...
* @rcuref: reference counter in the object in question. ... (Linux-Kernel) - Re: [OT] Re: [RFC] atomic refcounting alternative for boost shared_ptr...
... I have a version of refcount that supports process-wide atomic reference counting.
... If a process commits some shared memory, and wants to only decommit it when its no
longer being referenced by 'anything', it can registered it with my server process via. ... Can
anybody else think of practical ways to make use of process-wide atomic reference counting in
any of their "existing" applications? ... (comp.programming.threads) - Re: [OT] Re: [RFC] atomic refcounting alternative for boost shared_ptr...
... algorithms that are async safe, apart from patent issues of course? ... The
only time you can safely use my refcount algorithm in a signal-handlers context, for now, is when
a thread has "already grabbed an initial reference to a shared data-structure". ... it
kind of breaks down to sticking to "shared_ptr semantics" in a signal-handler; reference must
be owned prior to any new ones being acquired... ... (comp.programming.threads) - RE: gc assertion failure
... > cumop, thread_id, type ... the code that *can* catch a too-small refcount
before the refcount falls to ... assert triggers. ... grows an unaccounted-for
reference. ... (comp.lang.python)