Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 1996 15:23:50 -0500
From:      "Eric L. Hernes" <erich@lodgenet.com>
To:        phk@freebsd.org
Cc:        current@freebsd.org
Subject:   Re: device driver open/close inconsistency 
Message-ID:  <199610152023.PAA14536@jake.lodgenet.com>
In-Reply-To: Your message of "Tue, 15 Oct 1996 18:34:31 %2B0200." <193.845397271@critter.tfs.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp writes:
>
>Why do we call a device-driver->open() on all opens, but only ->close()
>once on the last close ?
>

That's a good one.  Near as I can tell it's been that way since
the epoch ;-)  The only hint of an explanation I can find is in
_Writing Device Drivers: Tutorial and Reference_; Burke, et al.
Sect 3.5.2 that says: 

The `open' interface is called every time that any user initiates
an action that invokes the `open' system call.  The `close' interface,
however, is called only when the last user initiates an action that
closes the device.  The reason for this difference is to allow the
driver to take some special action when there is no work
left to perform.

I'd say that's a pretty weak explanation though. You could do the
same (and more) with a simple semaphore or reference count.

>--
>Poul-Henning Kamp           | phk@FreeBSD.ORG       FreeBSD Core-team.
>http://www.freebsd.org/~phk | phk@login.dknet.dk    Private mailbox.
>whois: [PHK]                | phk@ref.tfs.com       TRW Financial Systems, Inc
>.
>Future will arrive by its own means, progress not so.
>

eric.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610152023.PAA14536>