may i write ISR in user space?

may i write ISR in user space?

Post by simo » Tue, 19 Jun 2001 11:43:45



i have a problem about interrupt handler
how can i write in user space,because i am writing stepper motor driver
every time the interrupt happend , i have to run some code in user space
,but i just can find source about kernel space interrupt handler ,
may i wirte it in user space? please help thanks

simon

 
 
 

may i write ISR in user space?

Post by cLIeNUX us » Fri, 22 Jun 2001 12:06:45



Quote:>i have a problem about interrupt handler
>how can i write in user space,because i am writing stepper motor driver
>every time the interrupt happend , i have to run some code in user space
>,but i just can find source about kernel space interrupt handler ,
>may i wirte it in user space? please help thanks

>simon

You want to look into rtlinux
and H3rL at ftp://linux01.gwdg.de/pub/cLIeNUX/interim/ABOUT

and also look into writing device drivers.

Rick Hohensee
www.clienux.com

 
 
 

may i write ISR in user space?

Post by Josef Moeller » Fri, 22 Jun 2001 15:21:37



> i have a problem about interrupt handler
> how can i write in user space,because i am writing stepper motor driver
> every time the interrupt happend , i have to run some code in user space
> ,but i just can find source about kernel space interrupt handler ,
> may i wirte it in user space? please help thanks

No, you can't write an interrupt handler in user space.

For one, user space virtual memory is paged, i.e. the code your
interrupt handler needs to call may just have been paged out.
You might, of course, lock pages into memory, but then, when the
interrupt occurs, a context switch is nonetheless necessary, causing
huge latency times and the whole purpose of an interrupt handler is to
act upon the cause of an interrupt as fast as possible.
Last (I'm sure there are a lot of other reasons), calling user space
code from the kernel is straight forward but returning to the kernel
afterwards might pose a security risk, because your user land code might
mangle the return address or register contents.

You might consider splitting the handler code into two bits: a first
stage handler that resides in a kernel module (these are non-paged, run
in kernel virtual space and will only be accepted from a trusted source,
i.e. only root can load a kernel module) and a second stage handler that
runs in user land, calling the module code to wait for an interrupt and
return all information required to handle the interrupt.

--
Josef M?llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

 
 
 

may i write ISR in user space?

Post by Dmitry Fedor » Fri, 22 Jun 2001 19:45:18




>> i have a problem about interrupt handler
>> how can i write in user space,because i am writing stepper motor driver
>> every time the interrupt happend , i have to run some code in user space
>> ,but i just can find source about kernel space interrupt handler ,
>> may i wirte it in user space? please help thanks

>No, you can't write an interrupt handler in user space.

But you can receive interrupt notifications:

http://www.ibiblio.org/pub/Linux/kernel/irq-1.68.2.tar.gz
 ftp://ftp.inp.nsk.su/export/fedorov/soft/irq-1.68.2.tar.gz

(2.0.x - 2.2.x kernels only)

kernel module to delivery hardware interrupts to user space
programs. Hardware interrupts (IRQ) are accessible by
character devices /dev/irq[0-15]. Interrupts delivered by
signals and select(2)/poll(2)

And run user space driver at real time priority with
http://www.ibiblio.org/pub/Linux/system/admin/rt-2.2.tar.gz
 ftp://ftp.inp.nsk.su/export/fedorov/soft/rt-2.2.tar.gz

 
 
 

1. ISR: Kernel->User space call

Hi

I'm writing a kernel space device driver.
In my interrupt service routine (kernel space) I want to notify user's
programm, that the data has arrived. How can I do this?

I want the user to register a function (in user space), which will be
than called from my ISR. Is this possible? Or is there another way?
Semaphores etc.?

Thanks
--
 Milos Dedecek

2. Cylinder 781 beyond end of media(628)

3. Writing Data from Kernel Space to User Space.

4. Updating the Kernel

5. Mounting a dos filesystem so that normal users may write to it???

6. How to configure pure IPv6

7. Q: How to mount an MSDOS partition so that ordinary users may write?

8. trident 1024k pb with X11r6

9. LOCAL: Washington DC Linux User Group May meeting (Wednesday May 21)

10. user space device driver can't write to isa device

11. Writing data from Kernel to a data file in user space

12. How to write a 'user space' mouse driver??

13. Writing data from Kernel to a data file in user space