> 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