SCHED_FIFO高优先级线程被SCHED_FIFO低优先级线程抢占了吗? [英] SCHED_FIFO higher priority thread is getting preempted by the SCHED_FIFO lower priority thread?

查看:186
本文介绍了SCHED_FIFO高优先级线程被SCHED_FIFO低优先级线程抢占了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Linux RT多核计算机上测试我的多线程应用程序.

I am testing my multithreaded application in Linux RT multicore machine.

但是在测试过程中,我们观察到根据SCHED_FIFO策略,Linux RT中的实时线程切换(使用SCHED_FIFO调度策略创建)并未发生.我们可以在多个地方看到,高优先级线程的执行被低优先级线程的抢占.

However during testing, we are observing that real time Thread switch(created with SCHED_FIFO scheduling policy ) in Linux RT is not happening according to the SCHED_FIFO policy. We could see in multiple places that the higher priority thread execution is getting preempted by a lower priority thread.

根据我在互联网上所做的一些研究,我们发现以下内核参数将被更改

Based on the some research i did on the internet, we found that following kernel parameters to be changed from

/proc/sys/kernel/sched_rt_period_us包含1000000/proc/sys/kernel/sched_rt_runtime_us包含950000

/proc/sys/kernel/sched_rt_period_us containing 1000000 /proc/sys/kernel/sched_rt_runtime_us containing 950000

/proc/sys/kernel/sched_rt_period_us包含1000000/proc/sys/kernel/sched_rt_runtime_us包含1000000或者/proc/sys/kernel/sched_rt_period_us包含-1/proc/sys/kernel/sched_rt_runtime_us包含-1

/proc/sys/kernel/sched_rt_period_us containing 1000000 /proc/sys/kernel/sched_rt_runtime_us containing 1000000 or /proc/sys/kernel/sched_rt_period_us containing -1 /proc/sys/kernel/sched_rt_runtime_us containing -1

我们尝试同时进行这两个操作,但有时仍然会遇到问题.即使更高优先级的线程没有被任何系统调用挂起,我们也面临着这个问题.

We tried doing both but still we are facing the problem sometimes. We are facing the issue even when higher priority thread is not suspended by any system call.

如果您知道Linux RT调度中的此类问题,并且/或者有任何解决方案可以使Linux RT调度基于优先级确定性,那就太好了.

It would be great if you could let us know if you are aware of such problems in Linux RT scheduling and/or have any solutions to make the Linux RT scheduling deterministic based on priority.

高优先级线程中没有printfs或任何系统调用,但高优先级线程仍被低优先级线程抢占.

There are no printfs or any system calls in the higher priority thread but still the higher priority thread is getting preempted by the lower priority thread.

我还使用tasket命令确保了进程中的所有线程都在单个内核上运行.

Also i have made sure all the threads in the proces are running on a single core using taskset command.

推荐答案

可能有两个原因:

  • CPU节流:调度程序旨在为非RT任务保留一些CPU时间;您已经通过对/proc/sys/kernel/条目进行操作来禁用它
  • 阻止:您的高优先级任务正在阻止
    • 某种同步机制(例如互斥量,信号量)或
    • 在某些阻塞调用(例如,malloc,printf,读取,写入等)上

    这篇关于SCHED_FIFO高优先级线程被SCHED_FIFO低优先级线程抢占了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆