From owner-freebsd-current Tue Oct 15 13:30:23 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA06277 for current-outgoing; Tue, 15 Oct 1996 13:30:23 -0700 (PDT) Received: from bacall.lodgenet.com (bacall.lodgenet.com [205.138.147.242]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id NAA06268; Tue, 15 Oct 1996 13:30:19 -0700 (PDT) Received: (from mail@localhost) by bacall.lodgenet.com (8.6.12/8.6.12) id PAA03162; Tue, 15 Oct 1996 15:24:20 -0500 Received: from garbo.lodgenet.com(204.124.123.250) by bacall via smap (V1.3) id sma003149; Tue Oct 15 15:24:10 1996 Received: from jake.lodgenet.com (jake.lodgenet.com [204.124.120.30]) by garbo.lodgenet.com (8.6.12/8.6.9) with ESMTP id PAA18876; Tue, 15 Oct 1996 15:24:18 -0500 Received: from jake.lodgenet.com (localhost [127.0.0.1]) by jake.lodgenet.com (8.7.6/8.6.12) with ESMTP id PAA14536; Tue, 15 Oct 1996 15:23:51 -0500 (CDT) Message-Id: <199610152023.PAA14536@jake.lodgenet.com> X-Mailer: exmh version 1.6.9 8/22/96 To: phk@freebsd.org cc: current@freebsd.org Subject: Re: device driver open/close inconsistency In-reply-to: Your message of "Tue, 15 Oct 1996 18:34:31 +0200." <193.845397271@critter.tfs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 15 Oct 1996 15:23:50 -0500 From: "Eric L. Hernes" Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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.