Subject: Re: dev/audiobell.c proposal
To: None <tech-kern@NetBSD.org>
From: Quentin Garnier <netbsd@quatriemek.com>
List: tech-kern
Date: 01/15/2004 23:17:43
Le Thu, 15 Jan 2004 16:59:02 -0500 (EST)
der Mouse a ecrit :
> > FreeBSD has a flag in the devsw structure to allow the close function
> > to be called at each close call on the device.
> 
> > Couldn't we do that, too, either adding a field at the end of struct
> > {c,b}devsw or using a special value for d_type?
> 
> Probably, but would it do what you want?  It's entirely possible to
> have multiple closes for a single open; consider a process that forks.
> 
> Unless you call close once per open file table entry rather than once
> per descriptor.  I would expect that be very hard to define the
> semantics of, short of resorting to describing the kernel internals in
> question.  It also amounts to cloning devices, as I understand them,
> only more difficult for the driver to deal with.

The point is to make it optional, in order to have it used by devices for
which it makes sense.  It means that the device is very likely to keep
state through the struct proc pointer it gets in the functions (and
indeed, that's precisely what NVidia does).

Most devices just need to release resources once unused, because the
amount of user processes it has doesn't really matter, but it would make
sense for an audio device to keep per process state.  If we'd go on the
in-kernel mixer road, each feeder would have its own rate, gain and such. 
The device would have to keep track of all of this, even though there
would be only one audio device behind.

-- 
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.