One: Yourself Realize:
a) j = jiffies jit_delay * hz;
While (Jiffes / * Nothing * /; // Busy, not allowed to schedule Disadvantages: If the clock is interrupted before the code execution, Jiffes will not be updated and dead! And increase the load of the system, any other program is not scheduled. b) j = jiffies jit_delay * hz; While (Jiffes Schedule (); // Allow scheduler dispathes Disadvantages: Although allowed to schedule, if there is only one process in the system (current process), it will happen to return to callback, waste system resources, and after dispatching, If the system is very busy, the time of the driver waiting may be much more than expected. Once a process is scheduled, the processor will not guarantee that some time will be reassigned to it. If the acceptable delay time has the upper limit, use this way to call Schedule, which is not a safe solution for the driver. The best way to get a delay is that the request kernel is delayed for us. Whether the driver is waiting for other events, there are two ways to set short-term delays. c) If the driver uses a wait queue waiting for an event, and you want to make sure that a certain period of time after running the driver, you can use the sleep function timeout version, sleep_on_timeout (wait_queue_head_t * q, unsigned long timeout); interruptible_sleep_on_timeout (wait_queue_head_t * Q, unsigned long timeout; d) In the usual driver, you can re-execute in two ways: a Wake_UP is called on the waiting queue, or Timout timeout. In this particular implementation, no one will call WAKE_UP (after all the other code does not know this at all), so the process always wakes up due to Timeout timeout. This is a perfect and effective implementation, but if the driver does not have to wait for other events, you can use a more direct way to get a delay, even if you use Schedule_Timeout: SET_CURRENT_STATE (Task_Interruptible); Schedule_timeout (Jit_DELAY * HZ);