[NCLUG] serialization question
Matthew Wilcox
willy at debian.org
Thu Jun 27 07:11:15 MDT 2002
On Wed, Jun 26, 2002 at 02:42:36PM -0600, Larry Butler wrote:
> First, I'm looking at some code that suggests that calls to open and release
> are serialized in a given driver. Please confirm or deny.
This is a struct file_operations, right? If so, the locking rules are
(tersely) documented in Documentation/filesystems/Locking. I believe that
open and release are _not_ serialised wrt each other and you will need to
perform your own form of exclusion.
> Second, if I deny multiple openers and don't sleep in write or ioctl, can I
> expect that calls to write and ioctl to be serialized? I would expect not
> (even with the restriction on multiple openers) since a process can fork and
> its child could write while the parent is writing. However, I have at least
> one example of code that does some pretty involved poking at hardware without
> any precautions.
Definitely unsafe. fork() is one case where an fd can be shared,
and another is unix domain socket fd passing. You're going to need
a spin_lock_irq()/spin_unlock_irq() style construct while you poke at
device registers.
> Third, where in the Rubini book are the answers? I must be blind. I can't
> find them.
Hmm.. not sure. I've only looked at the bits of the 2nd edition Rubini
book where I want to make changes (to see what driver authors are being
told to rely on ;-)
Best of luck.
--
Revolutions do not require corporate support.
More information about the NCLUG
mailing list