pthread_set_qos_class_self_np
Thanks Quinn! That seems to be working.
This stuff was surprisingly difficult to find out about. The developer.apple.com search can't find anything for pthread_set_qos_class_self_np even if I know the name of the function. DuckDuckGo found this page: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html which is quite useful, but it's in the "documentation archive" (i.e. documents that look like they were written by intelligent humans, not just scraped from headers by a bot) and I think is therefore excluded from search. But that suffers from the usual problem of telling you everything except the name of the header that you need to include. Sigh.