From now on, I must record all of the useful notes of Linux, especially about device driver, the following is the first.
It is about how to reschedule the processor in a device driver. What should be aware while calling function schedule().
You can prevent an endless loop inserting schedule invocations at strategic points. The schedule
call (as you might guess) invokes the scheduler and, therefore, allows other processes to steal CPU
time from the current process. If a process is looping in kernel space due to a bug in your driver, the
schedule calls enable you to kill the process after tracing what is happening.
You should be aware, of course, that any call to schedule may create an additional source of reentrant
calls to your driver, since it allows other processes to run. This reentrancy should not normally be a
problem, assuming that you have used suitable locking in your driver. Be sure, however, not to call
schedule any time that your driver is holding a spinlock.

