linux - wait_event_interruptible 和 wake_up_interruptible 需要 20 毫秒到 30 毫秒
问题描述
我正在研究 PCIe 卡。当 PCIe 卡引发 MSI 中断时,将调用 ISR 处理程序。在 ISR 例程中,wake_up_interruptible 将唤醒 V4L2 线程。然而,ISR 中的 wake_up_interruptible 和 v4l2 线程中的 wait_event_interruptible 之间的持续时间在 20 毫秒到 30 毫秒之间。时间是使用 linux 内核中的 do_gettimeofday() 函数测量的。下面是代码片段:
文件1.c
struct timeval t0;
irqreturn_t irq_hanlder(int irq, void *data)
{
...
...
do_gettimeofday(&t0);
printk("wake_up_interruptible: Time in micro_sec:%d\n",t0.tv_usec);
atomic_set (&flag, 1);
wake_up_interruptible(&my_wq);
...
...
return IRQ_HANDLED;
}
文件2.c
struct timeval t1;
static int v4l2_thread(void *handle)
{
...
while(1)
{
...
wait_event_interruptible(my_wq, (atomic_read (&flag)));
atomic_set (&flag, 0);
do_gettimeofday(&t1);
printk("wait_event_interruptible: Time in micro_sec:%d\n",t1.tv_usec);
...
}
...
return 0;
}
执行上述代码段后,wake_up_interruptible 和 wait_event_interruptible 之间的持续时间约为 20 毫秒到 30 毫秒。我使用了wake_up_interruptible_sync()而不是wake_up_interruptible,那么它也是相同的行为。
查询:
1) 为什么 linux 内核需要大约 20 毫秒到 30 毫秒,只是为了唤醒在 file2.c 中休眠的线程?
2)在linux中有没有其他处理唤醒线程的方法?
3) 如何减少 wake_up_interruptible 和 wait_event_interruptible 之间的时间?
提前致谢。
问候,库尔卡尼。
解决方案
推荐阅读
- r - mutate & rowwise & grepl 的替代品
- php - 创建 Veloconnect 服务器(使用 PHP),尝试从 xsd-schemas 生成 xml 文件
- java - 如何检查字符串是否包含没有正则表达式的拉丁字母
- javascript - 我如何解决 Javascript Fetch 的问题
- javascript - 如何根据点条件动态启用/禁用系列工具提示
- reactjs - 来自 DRF 的图像未在反应 js 中加载
- git - 为什么window git Bash中只有两个PS命令?如图所示
- python - 使用 Python SDK 和 Azure Functions 将元数据添加到 Azure Blob
- mongodb - Mongoose - 子文档数组问题
- java - IntelliJ 中的 mvn spring-boot:run 和“run”有什么区别