I am puzzled over this:You set the state of your task to TASK_INTERRUPTIBLE, that is, not valid to run and then call scheduler to give control to some other task. You don't include any code that actually sets the task state back to TASK_RUNNING, that is legible for scheduling so the schedule will never enter your task again. It effectively sleeps for ever.
The module just consist of three function:
static int myfunction(void)
{
dbg("%s - enter....", __FUNCTION__);
while (!kthread_should_stop()) {
dbg("%s - executing....", __FUNCTION__);
set_current_state(TASK_INTERRUPTIBLE);
printk("sssssssssssssssssssssssssssssssss\n");
schedule(); ======> ////// removed for part 2
printk("sssssssssssssssssssssssssssssssss\n");======>//////
removed for part 2
msleep(1000);
schedule();
}
return 0;
dbg("%s exit", __FUNCTION__);
...
For part 1:
After printing one line, the program never seemed to continue anymore.
why? It got stuck in the first schedule().
For part 2:
Just remove the "remove for part 2". And u can immediately see that
it starts to loop forever. So effectively there is only one
schedule() in the while loop.
Why?Thats' because msleep() changes your task state to TASK_RUNNING when it finishes sleeping, so you're calling the scheduler with a TASK_RUNNING state and it will schedule your task back sometime (perhaps even immediately).
I am quite puzzled......thanks in advance for the help. :-).Go read chapter 7 of "Linux Device Drivers, Third Edition" :-)