Skip to content

Mixer worker threads do not have rtprio on Linux #5065

@JohannesLorenz

Description

@JohannesLorenz

Calling

$ ps -o cmd,pid,pri,ni,rtprio -T $(pidof lmms)   # note: -T lists the threads
CMD                           PID PRI  NI RTPRIO
install/bin/lmms             8895  90   -     50
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   -      0
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -
install/bin/lmms             8895  19   0      -

shows that currently only 1 thread (well, 2, for some reasons, but I run this on an >=4 core) has rtprio (realtime priority). Our worker threads do not have rtprio.

The desired behavior is that all worker threads have rtprio. E.g. if you add something like

if (jack_client_create_thread (client, &tid,
        jack_client_real_time_priority (client),
        jack_is_realtime (client),
        &worker_thread, NULL))
{
        fprintf (stderr, "failed to create realtime worker thread\n");
}

to the simple client example, you can see two rtprio threads in the ps output. Many thanks to @rgareus who found this solution.

This should be fixed for jack, and also for ALSA (in the way jack does it when it uses ALSA as backend).

Background:
Realtime priority lets the kernel schedule threads before any non realtime priority threads. If a thread that shall process audio does not have this priority, it may get interrupted ("preemption") by another thread, which can cause lag when you play music while your CPU is busy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions