O PulseAudio requer prioridade mais alta do que outros programas da área de trabalho, principalmente para evitar problemas de latência e obter uma reprodução de áudio sem interrupções. Mas o processo que permite que o PulseAudio tenha uma prioridade mais alta é bastante complexo.
Para obter essa prioridade especial, ele usa o processo RealtimeKit ( rtkit-daemon
). Este serviço D-Bus permite que alguns programas de usuário usem o agendamento em tempo real e impõe algumas políticas rígidas para evitar abusos:
- Only clients with RLIMIT_RTTIME set will get RT scheduling.
- RLIMIR_RTIME: Specifies a limit on the amount of CPU time that a process scheduled under a real-time scheduling policy may consume without making a blocking system call
- RT scheduling will only be handed out to processes with SCHED_RESET_ON_FORK set to guarantee that the scheduling settings cannot 'leak' to child processes, thus making sure that 'RT fork bombs' cannot be used to bypass RLIMIT_RTTIME and take the system down.
- SCHED_RESET_ON_FORK: If set this will make sure that when the process forks a) the scheduling priority is reset to DEFAULT_PRIO if it was higher and b) the scheduling policy is reset to SCHED_NORMAL if it was either SCHED_FIFO or SCHED_RR.
- Limits are enforced on all user controllable resources, only a maximum number of users, processes, threads can request RT scheduling at the same time.
- Only a limited number of threads may be made RT in a specific time frame.
- Client authorization is verified with PolicyKit.
[...] it includes a canary-based watchdog that automatically demotes all real-time threads to SCHED_OTHER should the system overload despite the logic pointed out above. For more information regarding canary-based RT watchdogs [...]
Mais informações relacionadas: