Subject: Re: Implementation question
To: Filka Michal <michal.filka@strom.cz>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-kern
Date: 04/11/2006 08:42:46
On Tue, 11 Apr 2006 11:20:49 +0200, "Filka Michal" <michal.filka@strom.cz>
wrote:

> Hi all,
> I'm looking for as many different solutions of my problem as possible.
> The problem is:
> - I want to read data into application from my device driver using read
> call
> - data may be (or not) available
> 
> I want to block the call of read in my driver until data becomes
> available. Only ideas I have are to do active waiting (bad) or use
> locking internal to driver (better). However, I know very little about
> NetBSD's internals, so I don't know if there is any other (usual) way
> how to satisfy my requirement.
> 
Let me be sure I understand the requirements here.  You're writing a
device driver for some device?

In all Unix drivers I've ever looked at, read calls block in the driver if
there's no data available.  The interrupt routine would wake the sleeping
process, which would then copy the data to userspace and return.

		--Steven M. Bellovin, http://www.cs.columbia.edu/~smb