We can see quite often on RTL discussion lists questions: "I want to call
xxxx function, can I do it from RT task?". Often the answer is: "no, you can
not, but pend a soft IRQ with your code as handler".
RTL:rtl_get_soft_irq(linux_handler,name) + rtl_global_pend_irq(srq)
RTAI:rt_request_srq(label,rtai_handler,user_handler) + rt_pend_linux_srq(srq)
I thought OK, I have a function, but it should be called with some variable
parameters. Then I saw this code in rtlinux-2.3:rtl_get_soft_irq (...)
request_irq (i, handler, 0, devname, 0)
This is bad, bad, bad. I have some understanding why flags=0, but why
dev_id parameter is not passed? There is no way to use the same function in
different contexts. This can be circumevented by using rtl_get_soft_irq,
free_irq, request_irq with all parameters.
In RTAI I do not understand what happens when both rtai_handler (void) and
user_handler (unsigned long) are given? Also, in my opinion, just one "long"
could be not enough. There is quite often the need to pass an pointer (OK,
this can be cast to long, but is that portable?).
Anyway, since I do not want to register separate IRQ for every value of
parameters I have implemented the following function:
int rt_pend_call(void (*func)(int arg1, void * arg2), int arg1, void * arg2)
If you like it, you can insert attached code into RTL and RTAI. It is not
well tested yet, I will tell you when I try it.
Any comments? Am I reinventing the wheel? I think this is what RT-FIFO code
is doing, but just in a way usable in other places.
Best regards,
--
Tomek
rt_pend_tq.tgz