Results 1 to 1 of 1
Hello everyone!
I need help on how to execute this process. The goal is to execute a user space function in a kernel space task. Of course I know that ...
- 11-13-2007 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 2
User callback function execution while in kernel space
Hello everyone!
I need help on how to execute this process. The goal is to execute a user space function in a kernel space task. Of course I know that a user space function cannot be exported to the kernel space so I have tried using signals (and placing that user space function as a sighandler in user space) and scheduling (placing the kernel process to sleep, then run schedule). But these two methods did not work for me.
The kernel space process is not in interrupt context, and the flow of the program in kernel space simple and is somewhat like this:
where i is a value copied from the user space, and this task is initiated through an ioctl call.Code:while(i < count) { read data execute callback write data }
When I tried to use signals, I used kill_fasync() invoked the signal before the execution of the callback (wherein this callback is set as the signal handler in user space).
As a result, the callback function is not executed between the read and write transactions, instead it is executed i-times after the ioctl call has returned. Why is this so?
Now when I tried to use scheduling, I used the sleeping method:
As a result, this behaves like the ioctl call was cancelled andCode:printk("callback"); kill_fasync() add_wait_queue() set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current) { return -ERESTARTSYS; } schedule(); set_current_state(TASK_RUNNING); remove_wait_queue()
the "callback" string was printed i-times also and the registered signal handler in the user space function was not executed.
I am quite new to the method of scheduling in the kernel space so I am not sure if my problem is possible to have a solution.
Anyhow I hope someone can help me figure this out or suggest an alternate solution. Thanks!
Here is the algorithm of what I wanted to do:
1. In user space there is a callback function.
2. User task will enter the kernel space through ioctl.
3. Task in kernel executes reading some data.
4. Callback function must be executed.
5. After the callback function is executed, resume in kernel with writing some data.
6. Do number 3-5 n times as specified by a count argument in the ioctl command.
I would greatly appreciate anyones comment. Thank you!
-archie


Reply With Quote