Updated thread priorities for Apple operating systems
authorSam Lantinga
Wed, 01 Apr 2020 16:39:05 -0700
changeset 1368531702522ddbc
parent 13684 aecf8c5a136a
child 13686 42ef99a1bde2
Updated thread priorities for Apple operating systems
src/thread/pthread/SDL_systhread.c
     1.1 --- a/src/thread/pthread/SDL_systhread.c	Wed Apr 01 13:43:53 2020 -0400
     1.2 +++ b/src/thread/pthread/SDL_systhread.c	Wed Apr 01 16:39:05 2020 -0700
     1.3 @@ -220,9 +220,22 @@
     1.4      } else {
     1.5          int min_priority = sched_get_priority_min(policy);
     1.6          int max_priority = sched_get_priority_max(policy);
     1.7 -        sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
     1.8 -        if (priority == SDL_THREAD_PRIORITY_HIGH) {
     1.9 -            sched.sched_priority += ((max_priority - min_priority) / 4);
    1.10 +
    1.11 +#if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__TVOS__)
    1.12 +        if (min_priority == 15 && max_priority == 47) {
    1.13 +            /* Apple has a specific set of thread priorities */
    1.14 +            if (priority == SDL_THREAD_PRIORITY_HIGH) {
    1.15 +                sched.sched_priority = 45;
    1.16 +            } else {
    1.17 +                sched.sched_priority = 37;
    1.18 +            }
    1.19 +        } else
    1.20 +#endif /* __MACOSX__ || __IPHONEOS__ || __TVOS__ */
    1.21 +        {
    1.22 +            sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
    1.23 +            if (priority == SDL_THREAD_PRIORITY_HIGH) {
    1.24 +                sched.sched_priority += ((max_priority - min_priority) / 4);
    1.25 +            }
    1.26          }
    1.27      }
    1.28      if (pthread_setschedparam(thread, policy, &sched) != 0) {