help-hurd
[Top][All Lists]
Advanced

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

Re: Reference counting in netfs


From: Thomas Bushnell, BSG
Subject: Re: Reference counting in netfs
Date: 06 Jan 2003 20:47:23 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Ludovic Courtès <ludovic.courtes@utbm.fr> writes:

> In libnetfs, the netfs_nref, netfs_nput, etc. functions use a global spin
> lock that they acquire before changing the reference count of a node.
> First of all, it is not clear to me why the lock needs to be global.

A global is harmless, because the lock is only held for tiny amounts
of time.  No serious contention issues can arise.

Another reason is where to put the lock, if it's not a global.  It
cannot be allocated inside the node structure, or there can be a race
between deallocation and acquiring the lock.  Note that users of the
netfs library are allowed to keep nodes cached somewhere (just like
diskfs nodes), and so netfs_node_norefs is not actually required to
free anything.  

> Secondly, I have a race condition in tarfs which I believe could be avoided
> if the lock was a mutex.

mutexes and spin locks behave identically.  The only significant
difference is the respective performance costs of contention and
blocking.





reply via email to

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