Date: Sun, 2 Feb 1997 01:08:40 +1100 From: Bruce Evans <bde@zeta.org.au> To: current@freebsd.org, phk@freebsd.org Subject: Re: device driver open semantics... Message-ID: <199702011408.BAA23346@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>The way things work now, this scenario exists: > > > Proc A Proc B Device foo > ------------------------------------------ > > open(foo,RD) > \__________________ > \ > ->open(foo, RD,A) > > open(foo,WR) > \__ > \ > ->open(foo, WR,B) > > close(foo) > > >>nothing<< > > close(foo) > \____________________ > \ > ->close(foo,A) > > >I'm dissatisfied with the >>nothing<< step. At this time >there is nobody who has the device open for writing but >we fail to communicate this to the driver. I don't follow the diagram. I still use my 1.1.5 hack for not counting opens until the device open has returned. This fixes the problem of the device close never getting called and sleeping openers never getting woken up if process B completes an open and a close while process A is sleeping in open on some condition that doesn't prevent the open by process B). Lately I've been worrying about the problem of the device open being called while another process is sleeping in close. This state is easy to set up by outputting something to a tty with crtscts enabled and CTS off, then killing the process (it sleeps in close() and opening the tty in another process. A similar state can probably be set up for syscons using scroll lock instead of CTS. If the open sleeps and the close returns, then (I think) the process in open() won't get woken up (device drivers could handle this, but generally don't). If the open completes first, the device mode often gets clobbered when the close completes. >Many drivers don't really care who opened them, and it would >generally be sufficient to be informed of the current agregate >open mode: > > Proc A Proc B Device foo > ------------------------------------------ > > open(foo,RD) > \__________________ > \ > ->isopen(foo, RD) > > open(foo,WR) > \__ > \ > ->isopen(foo, RD|WR) >... Always call the device close(), and check the open count there? Where is isopen()? My hack makes vfs count processes sleeping in open. This is easier than changing 100 device drivers. More is required for devices that support aliases and/or slices, but vfs can handle the easy cases. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702011408.BAA23346>