Jam*_*mie 11 linux delay linux-device-driver linux-kernel
我正在为一个设备编写一个内核驱动程序,该驱动程序会定期生成定期读取数据.用户空间程序非常适合使其成为阻塞驱动程序.
有什么方法可以在驱动程序中暂停4到100ms(即执行" 块 ")?在用户空间中,我会做类似于:
tv.tv_sec = microsecond_delay / 1000000ul;
tv.tv_usec = microsecond_delay % 1000000ul;
(void)select(0, NULL, NULL, NULL, & tv);
Run Code Online (Sandbox Code Playgroud)
要么
gettimeofday(tv,NULL);
Run Code Online (Sandbox Code Playgroud)
并比较结构.
[编辑 - 我自己的回答]
我将在我的驱动程序中使用以下代码:
#include <linux/jiffies.h>
...
schedule_timeout(file->private_data->my_driver_struct.read_pause_jiffies);
Run Code Online (Sandbox Code Playgroud)
瞧!我现在要测试......