Linux 中常见实时进程的一些示例
Linux 中常见的 SCHED_FIFO 和 SCHED_RR 进程有哪些?用户输入是否属于实时进程类别?
What are some of the common SCHED_FIFO and SCHED_RR processes in Linux? Does user input falls under the cantegory of Real Time processes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个问题。 “实时”(对于进程)指的是调度算法,或者内核在决定运行哪个进程时所做的思考。实时进程将抢占所有其他进程(当收到中断并且需要运行时,调度权重较小。
仅接受用户输入的程序将在等待输入时甚至在击键之间(具体取决于)进入睡眠状态(阻塞)。这样的程序不需要有这么高的调度优先级。 RT 进程应该需要先于系统上的所有其他进程运行。这可能是因为该进程对于某些关键目标至关重要,或者需要高性能计时器(在这种情况下,您需要一个实时操作系统,而标准 Linux 则不然)。
无论如何,有关 SCHED_FIFO 和 SCHED_RR 之间差异的概述,请参阅我链接的问题。如果考虑其中一个而不是程序需要作为 RT 运行,那么您应该做出的决定,这是一项基本的工程决策。在两者之间做出选择只是您希望您的流程如何与其他流程合作的问题。
如果我使用标准内核来控制电梯,则为微开关的硬件中断提供服务的进程可能会在 RT 权重下使用 SCHED_FIFO。话又说回来,我可能不会为此使用标准 Linux。
如果我正在编写一个电子邮件客户端,我会使用标准调度程序并让用户
nice
他们认为合适的运行程序。Have a look at this question. "Real time" (for a process) refers to the scheduling algorithm, or the thinking the kernel does when it decides which process gets to run. A real time process will preempt all other processes (of lesser scheduling weight) when an interrupt is received and it needs to run.
A program that just accepts user input is going to go to sleep (block) while waiting for the input, or even between keystrokes (depending). Such a program does not need to have such a high scheduling priority. RT processes should need to run ahead of every other process on the system. This could be because the process is critical to some crucial goal, or high performance timers are needed (in which case, you'd want a real time OS, which standard Linux is not).
Anyway, for an overview of the differences between SCHED_FIFO and SCHED_RR, see the question that I linked. The decision you should be making if contemplating one over the other is not if the program needs to run as RT, thats a fundamental engineering decision. Deciding between the two is just a matter of how you want your process to cooperate with others.
If I was using a standard kernel to control an elevator, the process that serviced hardware interrupts from the micro switches would probably be using SCHED_FIFO at a RT weight. Then again, I probably would not use standard Linux for that.
If I was writing an e-mail client, I'd use the standard scheduler and let the user
nice
their running programs as they saw fit.