Subject: Re: locking out device attach/detach?
To: Iain Hibbert <plunky@rya-online.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 12/06/2005 12:17:15
--WplhKdTI2c8ulnbP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Dec 05, 2005 at 10:06:10PM +0000, Iain Hibbert wrote:
> Hi,
>    How should I lock out device attach/detach routines while for example
> walking a device list that I've added to in said routines in order to
> protect against the list being modified while I use it? (only short scans)

Today, you don't have to. We still have one kernel biglock, so your access=
=20
will be single-threaded.

The right way will be some form of spinlock.

>    looking at the master ifnet list in net/if.c for instance:
>=20
> 	ifunit() uses TAILQ_FIRST/TAILQ_NEXT with no protection (?)
>=20
> 	if_attach() uses TAILQ_INSERT_LAST with no protection
>=20
> 	if_detach() uses TAILQ_REMOVE inside splnet()
>=20
> when device attach/detach functions are called, how are they triggered and
> at what priority is the call? (is pcmcia different to usb?)
>=20
> I'm not using the ifnet code any more (I think bluetooth device is not
> exactly an interface), but am doing much the same thing with another list
> head..

Take care,

Bill

--WplhKdTI2c8ulnbP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDlfHKWz+3JHUci9cRAsqSAJ9teFSb/zYFlTHu7QI/pl1bBAx1PwCeKahA
WiMdswiST2W1t7hR5mDseT8=
=NT4Y
-----END PGP SIGNATURE-----

--WplhKdTI2c8ulnbP--