我可以在我的流程中进行实时调度(但不影响其他人)吗?

标签 c linux real-time scheduling

根据我的问题here我想在 Linux 应用程序中为我的线程使用 SCHED_RRpthread_setschedparam。然而,这has effects even on kernel modules我目前无法解决。

我找到了 http://www.icir.org/gregor/tools/pthread-scheduling.html它说我可以使用 PTHREAD_SCOPE_PROCESS 属性创建我的线程,但我还没有找到这方面的更多信息。

这是否适用于 (Angstrom) Linux,内核版本 2.6.32? (如何)这会影响我的流程与其他流程竞争的方式吗?是否可以让我的进程与实时调度竞争但其他进程不会受到影响?

(因为我使用的是 boost 线程,所以我不能简单地尝试这个...)

最佳答案

使用 PTHREAD_SCOPE_PROCESS 创建的线程将共享同一个内核线程( http://lists.freebsd.org/pipermail/freebsd-threads/2006-August/003674.html )

但是,SCHED_RR 必须在 root 特权进程下运行。

Round-Robin; threads whose contention scope is system (PTHREAD_SCOPE_SYSTEM) are in real-time (RT) scheduling class if the calling process has an effective user id of 0. These threads, if not preempted by a higher priority thread, and if they do not yield or block, will execute for a time period determined by the system. SCHED_RR for threads that have a contention scope of process (PTHREAD_SCOPE_PROCESS) or whose calling process does not have an effective user id of 0 is based on the TS scheduling class.

但是,根据您的相关问题,我认为您面临着更深层次的问题。您是否尝试过将内核设置为更“抢先”?抢占应该允许内核强制停止运行您的进程,从而允许某些内核部分的响应速度更快。不过,这应该不会影响 IRQ,也许是某些东西禁用了您的 IRQ?

我正在考虑的另一件事是,您获取 SPI 数据的速度可能不够快,内核中的数据缓冲区已满,因此数据丢失。也尝试增加这些缓冲区。

关于我可以在我的流程中进行实时调度(但不影响其他人)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7685354/

相关文章:

c - 使用 time 命令了解实时时间和 cpu 时间 - 有多准确?

c++ - 如何在 makefile 中的依赖项中写入 "or"?

c - 为什么我可以在 gcc -std=c11 中使用 gets()?

c++ - 内存映射文件如何与写入文件的另一个进程同步?

java - 如何在 Play Framework 中复制上传的文件?

algorithm - 如何利用实时数据的所有可用带宽?

android - 如何将数据从一个 Activity 创建的后台线程发送到另一个已知处于 Activity 状态的 Activity ?

c - 在 for 循环中交换语句

用于标记函数开始和结束的 C 宏

python - 我们可以在 Python 中使用 C 代码吗?