diff options
-rw-r--r-- | gruel/src/lib/realtime.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gruel/src/lib/realtime.cc b/gruel/src/lib/realtime.cc index 1de8b6dc0..d1907b3c1 100644 --- a/gruel/src/lib/realtime.cc +++ b/gruel/src/lib/realtime.cc @@ -70,19 +70,20 @@ namespace gruel { { int policy = p.policy == RT_SCHED_FIFO ? SCHED_FIFO : SCHED_RR; int min_real_pri = sched_get_priority_min(policy); - int max_real_pri = sched_get_priority_min(policy); + int max_real_pri = sched_get_priority_max(policy); int pri = rescale_virtual_pri(p.priority, min_real_pri, max_real_pri); - pthread_t this_thread = pthread_self (); // this process struct sched_param param; memset (¶m, 0, sizeof (param)); param.sched_priority = pri; - int result = pthread_setschedparam (this_thread, policy, ¶m); + int result = pthread_setschedparam (pthread_self(), policy, ¶m); if (result != 0) { - if (errno == EPERM) + if (result == EPERM) // N.B., return value, not errno return RT_NO_PRIVS; else { - perror ("pthread_setschedparam: failed to set real time priority"); + fprintf(stderr, + "pthread_setschedparam: failed to set real time priority: %s\n", + strerror(result)); return RT_OTHER_ERROR; } } @@ -102,7 +103,7 @@ namespace gruel { { int policy = p.policy == RT_SCHED_FIFO ? SCHED_FIFO : SCHED_RR; int min_real_pri = sched_get_priority_min(policy); - int max_real_pri = sched_get_priority_min(policy); + int max_real_pri = sched_get_priority_max(policy); int pri = rescale_virtual_pri(p.priority, min_real_pri, max_real_pri); int pid = 0; // this process |