On Tue Feb 18 11:05:21 2025 +0000, Marc-Aurel Zent wrote:
The only thing needed on macOS to get a thread into the realtime band is the thread port, and asking the scheduler for reasonable time constraints. In my experience even putting an entire game in the realtime band works fairly well (some threads get demoted though after a while); the performance is slightly worse though than staying in the high application band. Putting taskmgr into the realtime band makes it stay there indefinitely with no issues AFAICT too. System responsiveness was also still fine, at least in my testing. It is also soft-realtime and during very high system load threads get put back to where they originally were relatively quickly (especially when not adhering to their computation constraints), which is probably why the API is so lax with permissions.
For what it's worth, Apple includes a game sample with the Game Porting Toolkit that creates a high-priority render thread using `SCHED_RR` and `sched_priority = 45` (take a look at gptk-sample/08 - MetalRendering/README.md` in `Game_Porting_Toolkit_2.0.dmg`). I can also ask our Apple contact whether they'd recommend setting priorities into the realtime band.