On Linux SCHED_FIFO and SCHED_RR

后端 未结 4 1241
陌清茗
陌清茗 2020-12-29 12:03

I\'m writing a a very small daemon that must remain responsive even when a system is under severe stress. I\'m looking at the differences between SCHED_FIFO and SCHED_RR in

相关标签:
4条回答
  • 2020-12-29 12:39

    SCHED_FIFO can't be preempted (context switched to another process) unless another process of higher priority shows up in the execution queue.

    SCHED_RR can be preempted by a time quantum (delay given to a process to execute).

    They are both "real-time" priorities of linux based schedulers.

    0 讨论(0)
  • 2020-12-29 12:39

    I'm not an expert for scheduling schemes, but have a look at

    man sched_setscheduler
    

    it details what the difference between the different scheduling algorithms are, and provide links to other scheduling functions. SCHED_FIFO actually sounds pretty dangerous, but is described as the most aggressive scheduling:

    A SCHED_FIFO process runs until either it is blocked by an I/O request, it is preempted by a higher priority process, or it calls sched_yield(2).

    Beware not to lock up your system. I would personally do some empirical tests to see what priority fits the best and how they behave exactly.

    0 讨论(0)
  • 2020-12-29 12:47

    The infamous pchdtvr program, which captures digital TV signals, uses SCHED_FIFO to make sure that the TV packets are written to disk no matter what. It can capture 4 shows at once while playing Doom on an old computer.

    The program is infamous because it was released under GPL and the author tried to revoke the GPL retroactively. This act provoked a minor firestorm. Anyway, you can find a recent version to study at http://frequal.com/pmn/pchdtvr.html.

    0 讨论(0)
  • 2020-12-29 12:50

    If all your other tasks use the standard scheduler, it makes no difference; SCHED_FIFO and SCHED_RR only affect the scheduling of these tasks with each other.

    So on a normal system it makes no difference. FIFO is easiest to understand, so use that I guess.

    If you have several tasks of different priorities, only the higher one will be run if they are all ready to be run (and there is only one CPU core)

    0 讨论(0)
提交回复
热议问题