Subject: Re: Device drivers and threads/locking?
To: Gary Thorpe <gat7634@hotmail.com>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-kern
Date: 06/08/2002 11:02:15
In some email I received from Gary Thorpe, sie wrote:
> Hi,
> 
> I have a general question about drivers: is it necessary or good practice to 
> put locking/synchronization in functions used to manipulate a device? In 
> other words, is it possible or will it be possible in the future for two or 
> more different threads of control (this actually includes two or more 
> seperate processes as well) to attempt to manipulate or use the services of 
> a single device? If so, what facilities does the kernel provide for this?

Since nobody else has replied, I will...but I'm not the best person to
answer this.

Drivers which are talking to devices are (obviously) going to need to
order themselves so that only one thread of execution is talking to one
device at any one time.  If a driver has more than one device then it
stands to reason that different threads should be able to talk to
different devices, concurrently - eg. using wd0 & wd2 on a "standard"
PC.

I don't believe we (NetBSD) have started on anything resembling a design
on how to recognise drivers that are capable of working concurrently
with different devices vs those that can not, or even those that are
able to support multiple threads despite there being only one device.
This isn't a bad time for us to start thinking about it, however, as
i386 SMP is nearing a point where it may end up in -current.

Darren