How to run a custom C++ program with real-time priority?

Hi,

I’m writing a custom C++ program (using PortAudio library) to process audio. What do I need to do so that my executable runs in real-time (with real-time priority) in Patchbox OS?

Do I need to add something to the code itself?

Or do I just run the executable in certain way (and if so, what way)?

Thanks!

Hey, it’s the same way as for the rest of the Linux. :slight_smile:

Here’s some example code which raises the priority of the main thread as well as spawned threads: https://stackoverflow.com/a/49072264/7823460

Or you could use nice command to start your program with specified priority, or renice to modify the priority of an already running program: Nice and Renice Command in Linux with Examples - GeeksforGeeks

1 Like

Great, thank you! :slightly_smiling_face:

1 Like