[uClinux-dev] Re: question about Interrupt handler

Greg Ungerer gerg at snapgear.com
Mon Nov 26 19:26:26 EST 2001

Hi Vladimir,

Vladimir Vorobyov wrote:
> > Vladimir Vorobyov wrote:
> > > Continuing Interrupt handlers topic I want to ask some questions:
> > > 2) On the other hand, I work on the rocessor without MMU and
> > > transferring data to/from user space from interrupt handler works
> properly,
> > > but
> > > is it correct to do it (write to user space directly)?
> > For sufficiently fuzzy values of correct :-)
> > Fundamentally it is a bad thing to do. What if the app dies for some
> > reason?  The interrupt could be writing into someone else memory space.
> > What if one day you want to switch to a VM processor?
> OK, but if I need to perform asynchronous reading:
> Buffering data within driver will be useless.
> Writing from interrupt handler happens only after application has called
> read function.
> 1) application calls read
> 2) driver initializes reading sequence and returns
> 3) application does some computations
> 4) application polls driver (or calls IOCTL) to check for completion of data
> transfer and goes to 1)
> how can I avoid writing to user space ?

I don't see why you need to write directly to use space from
this description?

I would have suggested something like:

1.  app does an ioctl to driver to tell it to start read sequence
    (ioctl returns immediately to app)
    a)  app does its computations
    b)  driver is reading data into its local _kernel_ buffer
3.  app calls read
    a) if driver has completed read all data is copied into
       user space buffer and read returns
    b) if not all data is ready then read call sleeps.
       driver wakes up read when all data is read, read then
       copies all data from kernel buffer to user space buffer

This sequence has the advantage of not busy waiting.
It requires to memory tricks, this is very standard
driver stuff.

Tom gave a pretty complete decsiption of the problems
of writing direct to user space.

If you want to write to user space go right ahead :-)
The great thing about open source is you can see how everything
is done...

Greg Ungerer  --  Chief Software Wizard        EMAIL:  gerg at snapgear.com
SnapGear                                       PHONE:    +61 7 3435 2888
825 Stanley St,                                  FAX:    +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia              WEB:   www.snapgear.com
This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/

More information about the uClinux-dev mailing list