help-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Soft and hard references


From: Thomas Bushnell, BSG
Subject: Re: Soft and hard references
Date: 19 Oct 2002 23:05:57 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Wolfgang Jaehrling <pro-linux@gmx.de> writes:

> On Tue, Oct 08, 2002 at 09:28:35AM -0400, Neal H. Walfield wrote:
> > In what context?  Do you mean, for instance, libdiskfs' hard and weak
> > reference counting system?
> 
> As Marco cannot reply to this mail currently due to technical
> problems, he asked me to answer for him.  The answer is: Yes, he was
> speaking about this reference counting system.
> 
> I am very interested in learning about this stuff myself, BTW.

In the case of diskfs, hard references are the *real* ones.

Weak references are for "users" of the node, whose "use" should not
count when considering whether the node is actually being used.  The
idea is that the pager, for example, keeps a weak reference.  The mere
fact of the pager's existence is not enough to keep the node "open"
and live in the system (or, if there are no links, to keep it from
being deleted).

The pager needs a reference, because the pager structure has a link to
the node structure, and you have to hold a reference to be allowed to
have such a pointer.  But if it were a hard reference, then nodes
wouldn't get deleted on time.  So the pager holds a soft reference.

When all the hard references go away, diskfs tells the soft references
"ok, time to drop your reference", and then once they've done that,
completes the deletion.

The terminology comes from some Lisp systems, in which there are
strong and weak pointers.  An object in such systems can be GCd even
if there are weak pointers to it, and the weak pointers get
automagically set to nil.

What diskfs does is like this, except much more ad-hoc, and also
includes some finalization semantics too.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]