Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set thread priority pthreads on Mac OS

Tags:

c++

pthreads

I've found:

pthread_setschedprio() 

here: http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_setschedprio.3.html

But I can't find any valid values for thread priority. For Windows I've found very clear possible value, like:

THREAD_PRIORITY_BELOW_NORMAL
THREAD_PRIORITY_NORMAL
THREAD_PRIORITY_ABOVE_NORMAL

but for Mac OS I didn't found anything. I can't use Cocoa NSThreads class, I need to use POSIX threads.

Do you know how to set thread priority pthreads on Mac OS?

like image 725
Mircea Ispas Avatar asked Mar 30 '26 21:03

Mircea Ispas


1 Answers

AFAIK pthread_setschedprio() doesn't exist on macOS. You can only set the priority of a thread when you create it using pthread_setschedparam().

And as for priority, see documentation for pthread_setschedparam():

Valid thread priorities (accessed via param->sched_priority) must be within the range returned by the sched_get_priority_min(2) and sched_get_priority_max(2) system calls.

like image 65
Mecki Avatar answered Apr 02 '26 11:04

Mecki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!